Skip to content

Instantly share code, notes, and snippets.

View futureshocked's full-sized avatar

Peter Dalmaris futureshocked

View GitHub Profile
@futureshocked
futureshocked / refs_vs_pointers.ino
Last active April 20, 2016 21:30
A sketch written to help people understand the use of references and pointers
/*
* ref_vs_pointers
* A sketch written to help people understand the use of references and pointers
* Written by Peter Dalmaris, April 8 2016.
* Arduino Tips and Tricks
* txplore.com
*
* Requirements: MemoryFree from https://github.com/McNeight/MemoryFree
*/
/*
* multitasking_demo
* A sketch written to help people understand how to implement basic multitasking on the Arduino
* Written by Peter Dalmaris, April 21 2016.
* Arduino Tips and Tricks
* txplore.com
*
* Requirements: An Arduino, two LEDs, two 220Ohm resistors, a breadboard, wires.
* Play around with the variables in lines 18 to 26 to create different light show patterns.
*/
@futureshocked
futureshocked / scheduler_due_example.ino
Created June 6, 2016 02:29
This sketch demonstrates the use of the Scheduler library.
/*
*
* This sketch demonstrates the use of the
* Scheduler library.
*
* To use, you will need an Arduino Due or Zero,
* four LEDs, four 220Ohm resistors, jumper wires
* and a breadboard.
* Connect the LEDs to a resistor, and the resistors
* to pins 11, 10, 9, 8 on the Due.
void setup(){
Serial.begin(9600);
}
void loop (){
a_function();
// Serial.print("In loop: ");
// Serial.println(local_variable); // local_variable is out of scope so compilation will produce an error message
delay(1000);
}
int local_variable = 0;
void setup(){
Serial.begin(9600);
}
void loop (){
a_function();
Serial.print("In loop: ");
Serial.println(local_variable);
static int local_variable = 0;
void setup(){
Serial.begin(9600);
}
void loop (){
a_function();
Serial.print("In loop: ");
Serial.println(local_variable);
void setup(){
Serial.begin(9600);
}
void loop (){
a_function();
// Serial.print("In loop: ");
// Serial.println(local_variable); // local_variable is out of scope so compilation will produce an error message
delay(1000);
}
int a; //A variable which is also access by an interrupt service routine
void setup(){
}
void loop(){
a = 1;
int b;
b = a + 1;
Serial.println(b);
volatile int a; //A variable which is also access by an interrupt service routine
void loop(){
a = 1;
int b;
b = a + 1;
Serial.println(b);
}
void isr0 () {
detachInterrupt(0);
// In this file I want to show how to create an array of a struct for the Arduino.
// I create a struct that contains ints for RGB color components.
// Then, I create an array of this struct, and use it to display a color
// show on an Adafruit 40 RGB LED shield array.
// Check out my Arduino blog at txplore.com, and my video courses at txplore.tv!
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>