1
0
Fork 0

Initial commit of sample projects

This commit is contained in:
Shawn Nock 2016-05-20 15:00:36 -04:00
commit ed43635849
8 changed files with 228 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "sketchbook/libraries/IRremote"]
path = sketchbook/libraries/IRremote
url = https://github.com/z3t0/Arduino-IRremote

View File

@ -0,0 +1,37 @@
/*
RGB Blink
Alternates R, G and B LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
modified 20 May 2016
by Shawn Nock
*/
#define RED 2
#define GREEN 3
#define BLUE 4
int delay_ms = 1000; // How long to keep LEDs on and off in milliseconds (sec/1000)
void setup() {
// initialize digital pin 13 as an output.
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
}
void loop() {
digitalWrite(RED, HIGH); // turn the LED on (HIGH is the voltage level)
delay(delay_ms); // wait for a second
digitalWrite(RED, LOW); // turn the LED off by making the voltage LOW
delay(delay_ms); // wait for a second
digitalWrite(GREEN, HIGH);
delay(delay_ms);
digitalWrite(GREEN, LOW);
delay(delay_ms);
digitalWrite(BLUE, HIGH);
delay(delay_ms);
digitalWrite(BLUE, LOW);
delay(delay_ms);
}

View File

@ -0,0 +1,72 @@
/*
RGB Blink
Alternates R, G and B LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
modified 20 May 2016
by Shawn Nock
*/
#include <IRremote.h>
#include "medway-remote.h" // Button definitions for medway kit remote
#define RED 3
#define GREEN 4
#define BLUE 5
#define IR_PIN 2
#define BUZZER 10
/* Initialize the irrecv part of the IRremote library */
IRrecv irrecv(IR_PIN);
decode_results results; // This will store our IR received codes
uint16_t lastCode = 0; // This keeps track of the last code RX'd
bool power = false; // Variable to store power on/off state
void setup() {
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
pinMode(BUZZER, OUTPUT);
irrecv.enableIRIn();
}
void loop() {
if (irrecv.decode(&results)) {
uint16_t resultCode = (results.value & 0xFFFF);
switch (resultCode) {
case POWER:
power ^= 1; // Toggle power
if (!power) {
digitalWrite(RED, LOW);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, LOW);
} else {
digitalWrite(RED, HIGH);
digitalWrite(GREEN, HIGH);
digitalWrite(BLUE, HIGH);
}
break;
case ONE:
digitalWrite(RED, !digitalRead(RED));
break;
case TWO:
digitalWrite(GREEN, !digitalRead(GREEN));
break;
case THREE:
digitalWrite(BLUE, !digitalRead(BLUE));
break;
case MUTE:
digitalWrite(BUZZER, !digitalRead(BUZZER));
break;
default:
break;
}
irrecv.resume();
}
}

View File

@ -0,0 +1,23 @@
#pragma once
#define POWER 0x261b
#define MODE 0x1dbb
#define MUTE 0x6d7f
#define PLAY 0xd41f
#define PREV 0x4b1b
#define NEXT 0x4dbb
#define EQ 0xc13b
#define MINUS 0xeddb
#define PLUS 0xdb7f
#define ZERO 0xe57b
#define SHUFFLE 0x3bfb
#define USD 0x1643
#define ONE 0xbe3f
#define TWO 0xe3f7
#define THREE 0x021b
#define FOUR 0x657b
#define FIVE 0x3cbb
#define SIX 0xe79f
#define SEVEN 0xfdf7
#define EIGHT 0x157b
#define NINE 0xfc1b

View File

@ -0,0 +1,50 @@
/*
RGB Blink
Alternates R, G and B LED; vary the frequncy by the position of the potentiometer
Only activate the lights if the tilt switch is latched.
This example code is in the public domain.
modified 20 May 2016
by Shawn Nock
*/
#define RED 3
#define GREEN 4
#define BLUE 5
#define IN 8
int delay_ms = 1000; // How long to keep LEDs on and off in milliseconds (sec/1000)
void setup() {
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
pinMode(IN, INPUT_PULLUP);
}
// the loop function runs over and over again forever
void loop() {
if (digitalRead(IN) == LOW) {
delay_ms = analogRead(A0);
digitalWrite(RED, HIGH); // turn the LED on (HIGH is the voltage level)
delay(delay_ms); // wait for a second
digitalWrite(RED, LOW); // turn the LED off by making the voltage LOW
delay(delay_ms); // wait for a second
digitalWrite(GREEN, HIGH);
delay(delay_ms);
digitalWrite(GREEN, LOW);
delay(delay_ms);
digitalWrite(BLUE, HIGH);
delay(delay_ms);
digitalWrite(BLUE, LOW);
delay(delay_ms);
} else {
digitalWrite(RED, LOW);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, LOW);
}
}

View File

@ -0,0 +1,41 @@
/*
RGB Blink
Alternates R, G and B LED on for one second, then off for one second, repeatedly.
The frequency depends on the position of the potentiometer.
This example code is in the public domain.
modified 20 May 2016
by Shawn Nock
*/
#define RED 3
#define GREEN 4
#define BLUE 5
int delay_ms = 1000; // How long to keep LEDs on and off in milliseconds (sec/1000)
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
delay_ms = analogRead(A0);
digitalWrite(RED, HIGH); // turn the LED on (HIGH is the voltage level)
delay(delay_ms); // wait for a second
digitalWrite(RED, LOW); // turn the LED off by making the voltage LOW
delay(delay_ms); // wait for a second
digitalWrite(GREEN, HIGH);
delay(delay_ms);
digitalWrite(GREEN, LOW);
delay(delay_ms);
digitalWrite(BLUE, HIGH);
delay(delay_ms);
digitalWrite(BLUE, LOW);
delay(delay_ms);
}

@ -0,0 +1 @@
Subproject commit d064c7dd5b418e40a6e75cc1495cd00f2f320f27

View File

@ -0,0 +1 @@
For information on installing libraries, see: http://www.arduino.cc/en/Guide/Libraries