Skip to content

Instantly share code, notes, and snippets.

View futureshocked's full-sized avatar

Peter Dalmaris futureshocked

View GitHub Profile
@futureshocked
futureshocked / asbsgs_array_ex3.ino
Created October 26, 2019 04:45
Control an LED using an array.
/*
* Control an LED using an array.
*
* Create a pattern with LED on and off information in one array,
* and on/off durations in a second array.
*
*
*/
const int ledPin = 7;
@futureshocked
futureshocked / asbsgs_array_ex1.ino
Created October 26, 2019 04:48
An example of how to create an use an array of integers
/*
* An example of how to create an use an array of integers
* We'll declare an array of 5 integers.
* We'll print the contents in the serial monitor.
* We'll do some calculations, store the results, and print the results in the serial monitor.
*
*/
int my_integers[6] = {1, 2, 3, 4, 5} ; // We want this array to contain 5 integers,
// so we'll declare it with size 6.
@futureshocked
futureshocked / asbsgs_array_ex2.ino
Created October 26, 2019 04:49
n example of how to create an use an array of chars
/*
* An example of how to create an use an array of chars
* We'll declare an array of 5 chars.
* We'll print the contents in the serial monitor.
*
* The table of ASCII character from https://en.wikipedia.org/wiki/ASCII
* is useful.
*
*/
@futureshocked
futureshocked / asbsgs_array_ex4.ino
Created October 26, 2019 04:49
Control an LED using an array
/*
* Control an LED using an array, like in example 3, but the
* pattern is configurable.
*
* Create a pattern with LED on and off information in one array,
* and on/off durations in a second array.
*
*
*/
@futureshocked
futureshocked / bare_receiver.ino
Created January 6, 2020 00:31
An updated version of bare_receiver.ino to work with newer versions of the RF24 library.
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
class RF24Test: public RF24
{
public: RF24Test(int a, int b): RF24(a,b) {}
};
RF24Test radio(9,10);
@futureshocked
futureshocked / blink.ino
Created January 6, 2020 03:33
This sketch makes an LED connected to pin 9 to blink on and off every 1 sec
@futureshocked
futureshocked / fade_led.ino
Last active January 6, 2020 04:06
This sketch makes an LED connected to Arduino pin 9 to fade on and off
int led = 9; // the pin that the LED is attached to
int brightness = 0; // the bigger this number, the brighter the LED is
int fadeAmount = 5; // the bigger this number, the faster the the LED will fade on or off
// the setup routine runs once when you press reset:
void setup() {
pinMode(led, OUTPUT); // declare pin 9 to be an output:
}
// the loop routine runs over and over again forever:
@futureshocked
futureshocked / line_sensor.ino
Created January 6, 2020 04:59
This sketch implements a simple line sensor for the Arduino
// Line Sensor Breakout - Analog
int out;
void setup()
{
Serial.begin(9600); // sets the serial port to 9600
}
void loop()
{
@futureshocked
futureshocked / light-sensor.ino
Created January 6, 2020 05:14
This sketch reads the light intensity values from a photo-resistor connected to pin A0 of an Arduino.
// the setup function runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
@futureshocked
futureshocked / tilt.ino
Created January 6, 2020 05:39
Use this sketch to detect when your Arduino is tilted. Connect a tilt sensor to Analog pin 0 (A0)
int out;
void setup()
{
Serial.begin(9600); // sets the serial port to 9600
}
void loop()
{
out = analogRead(0); // read analog input pin 0