Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int RED = 9; //const = can't be changed, int = integer = whole numbers
- const int GREEN = 6; //Number equalls pin
- const int BLUE = 5;
- int REDval; //Makes a variable for later
- int GREENval;
- int BLUEval;
- int userInput[13]; //Raw input from serial buffer, 13 bytes
- int startbyte; //start byte, begin readin input
- int i;
- long previousMillis = 0;
- long blinkinterval = 1000;
- long pulsinterval = 10;
- void setup()
- {
- Serial.begin(9600); //initialize serial communication
- REDval = 255; //setting the start value of each variable
- GREENval = 255;
- BLUEval = 255;
- update();
- }
- void update()
- {
- analogWrite(RED, REDval); //analogWrite needs to conditions: first is pin
- analogWrite(GREEN, GREENval); //second is value
- analogWrite(BLUE, BLUEval); //the update function keeps track of the value
- }
- void loop()
- {
- //wait for serial input (min 13 bytes in buffer)
- if (Serial.available() >12){
- //If it's really the "true character" ('f')
- if (Serial.read() != 'f') {
- Serial.print("Error in first");
- Serial.flush();
- return;
- }
- if (Serial.read() != ' '){
- Serial.print("Error in second");
- Serial.flush();
- return;
- }
- Serial.print("Woohoo, made it past all the checks!!");
- Serial.flush();
- }
- }
Add Comment
Please, Sign In to add comment