Skip to content

Instantly share code, notes, and snippets.

View futureshocked's full-sized avatar

Peter Dalmaris futureshocked

View GitHub Profile
@futureshocked
futureshocked / analog_acceleration.ino
Created January 6, 2020 05:44
With this sketch your Arduino can detect acceleration using an analog accelerometer
int x, y, z;
void setup()
{
Serial.begin(9600); // sets the serial port to 9600
}
void loop()
{
x = analogRead(0); // read analog input pin 0
@futureshocked
futureshocked / distance.ino
Created January 6, 2020 05:49
This sketch uses an ultrasonic distance sensor to calculate the distance between the sensor and an object in front of it
#define trigPin 13
#define echoPin 12
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
long duration, distance;
digitalWrite(trigPin, LOW);
@futureshocked
futureshocked / pir_sensor.ino
Created January 6, 2020 05:54
This sketch reads the state of a PIR sensor
/*
* PIR sensor tester
*/
int ledPin = 13; // choose the pin for the LED
int inputPin = 2; // choose the input pin (for PIR sensor)
int pirState = LOW; // we start, assuming no motion detected
int val = 0; // variable for reading the pin status
void setup() {
@futureshocked
futureshocked / bme280_sensor.ino
Created January 6, 2020 05:59
This sketch uses a BME280 sensor to report temperature, humidity, and atmospheric pressure.
#include <Wire.h> //*Include the Wire library which allows to use the I2C interface*
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h> //*library to easily take readings from the sensor*
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme; //*Declare the bpm variable, an easy to remember reference for the device*
unsigned long delayTime;
@futureshocked
futureshocked / button.ino
Created January 6, 2020 23:50
This sketch reads the state of a button (pressed or unpressed) and turns on an LED when the button is pressed.
/*
Pushbutton sketch a switch connected to pin 2 lights the LED on pin 13
*/
const int ledPin = 13; // choose the pin for the LED
const int inputPin = 2; // choose the input pin (for a
// pushbutton)
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
@futureshocked
futureshocked / potentiometer.ino
Created January 7, 2020 00:28
This sketch reads the value of a potentiometer and controls the brightness of an LED
int potentiometerPin = 0;
int ledPin = 11;
int potentiometerVal = 0;
void setup()
{
Serial.begin(9600); // setup serial
}
void loop()
@futureshocked
futureshocked / CheckWifi101FirmwareVersion.ino
Last active January 12, 2020 20:57
CheckWifi101FirmwareVersion for my ATWINC1500 breakout
/*
* This example check if the firmware loaded on the WiFi101
* shield is updated.
*
* Circuit:
* - WiFi101 Shield attached
*
* Created 29 July 2015 by Cristian Maglie
* This code is in the public domain.
*/
@futureshocked
futureshocked / ATWINC1500_firmwareUpdater.ino
Created January 12, 2020 20:59
ATWINC1500 firmwareUpdater
/*
FirmwareUpdate.h - Firmware Updater for WiFi101 / WINC1500.
Copyright (c) 2015 Arduino LLC. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
@futureshocked
futureshocked / test-Wi-Fi.ino
Created January 12, 2020 21:21
My test sketch for the ATWINC1500 Wifi breakout for the Arduino Uno.
/*
Web client
This sketch connects to a website (http://www.google.com)
using a WiFi shield.
This example is written for a network using WPA encryption. For
WEP or WPA, change the WiFi.begin() call accordingly.
This example is written for a network using WPA encryption. For
int led = 9; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
}