Created
March 20, 2019 05:32
-
-
Save bboyho/d40795033952a0a04e368280ce8c19a8 to your computer and use it in GitHub Desktop.
color mixing tests with two 180Ohm and one 100Ohm resistor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SoftwareSerial.h> | |
SoftwareSerial xbee(2, 3); //Rx = 2, Tx = 3 | |
//Declare variables and pin definitions | |
//SEND Button | |
const int button1Pin = 4; //push button | |
const int ledPin1 = 13; //LED on the push button | |
boolean prev_button1State = false; | |
boolean current_button1State = false; | |
char send_CHAR = 'A'; //default send character | |
//LED Status Indicator | |
int ledR = 5;//hardware PWM | |
int ledG = 6;//hardware PWM | |
int ledB = 9; //hardware PWM | |
int redIntensity = 255; | |
int pattern = 0; //pattern | |
//UP Button | |
const int button2Pin = 11; //push button | |
boolean prev_button2State = false; | |
boolean current_button2State = false; | |
//DOWN Button | |
const int button3Pin = 12; | |
boolean prev_button3State = false; | |
boolean current_button3State = false; | |
/*******************Setup Loop***************************/ | |
void setup() { | |
// initialize the digital pins as an output for LEDs | |
pinMode(ledR, OUTPUT); | |
pinMode(ledG, OUTPUT); | |
pinMode(ledB, OUTPUT); | |
while (true) { | |
sequenceTest();//visually initialization | |
} | |
//Declare buttons | |
pinMode(button1Pin, INPUT_PULLUP); //use internal pullup resistor | |
pinMode (ledPin1, OUTPUT); | |
pinMode(button2Pin, INPUT_PULLUP); //use internal pullup resistor | |
pinMode(button3Pin, INPUT_PULLUP); //use internal pullup resistor | |
//Declare serial connections for debugging | |
Serial.begin(9600); | |
Serial.println("Arduino started sending bytes via XBee"); | |
xbee.begin(9600); | |
Serial.println("Glove Controller's XBee Ready to Communicate"); | |
} | |
/*******************Main Loop***************************/ | |
void loop() { | |
int button1State; | |
int button2State; | |
int button3State; | |
button1State = digitalRead(button1Pin); | |
button2State = digitalRead(button2Pin); | |
button3State = digitalRead(button3Pin); | |
}//end loop | |
void allOFF() { | |
analogWrite(ledR, 0); | |
analogWrite(ledG, 0); | |
analogWrite(ledB, 0); | |
} | |
void allON() { | |
analogWrite(ledR, redIntensity); | |
analogWrite(ledG, 255); | |
analogWrite(ledB, 255); | |
} | |
void redON() { | |
analogWrite(ledR, redIntensity); | |
analogWrite(ledG, 0); | |
analogWrite(ledB, 0); | |
} | |
void roseON() { | |
analogWrite(ledR, redIntensity); | |
analogWrite(ledG, 0); | |
analogWrite(ledB, 128); | |
} | |
void magentaON() { | |
analogWrite(ledR, redIntensity); | |
analogWrite(ledG, 0); | |
analogWrite(ledB, 255); | |
} | |
void violetON() { | |
analogWrite(ledR, 128); | |
analogWrite(ledG, 0); | |
analogWrite(ledB, 255); | |
} | |
void blueON() { | |
analogWrite(ledR, 0); | |
analogWrite(ledG, 0); | |
analogWrite(ledB, 255); | |
} | |
void azureON() { | |
analogWrite(ledR, 0); | |
analogWrite(ledG, 128); | |
analogWrite(ledB, 255); | |
} | |
void cyanON() { | |
analogWrite(ledR, 0); | |
analogWrite(ledG, 255); | |
analogWrite(ledB, 255); | |
} | |
void springgreenON() { | |
analogWrite(ledR, 0); | |
analogWrite(ledG, 255); | |
analogWrite(ledB, 128); | |
} | |
void greenON() { | |
analogWrite(ledR, 0); | |
analogWrite(ledG, 255); | |
analogWrite(ledB, 0); | |
} | |
void chartreuseON() { | |
analogWrite(ledR, 128); | |
analogWrite(ledG, 255); | |
analogWrite(ledB, 0); | |
} | |
void yellowON() { | |
analogWrite(ledR, redIntensity); | |
analogWrite(ledG, 255); | |
analogWrite(ledB, 0); | |
} | |
void orangeON() { | |
analogWrite(ledR, redIntensity); | |
analogWrite(ledG, 51); | |
analogWrite(ledB, 0); | |
} | |
void sequenceTest() { | |
roseON(); | |
delay(3000); | |
magentaON();//good | |
delay(3000); | |
violetON(); | |
delay(3000); | |
blueON();//good | |
delay(3000); | |
azureON(); | |
delay(3000); | |
cyanON(); | |
delay(3000); | |
springgreenON(); | |
delay(3000); | |
greenON();//good | |
delay(3000); | |
chartreuseON(); | |
delay(3000); | |
yellowON();//good | |
delay(3000); | |
orangeON();//good | |
delay(3000); | |
redON();//good | |
delay(3000); | |
allON(); | |
delay(3000); | |
allOFF(); | |
delay(3000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment