Guest User

Untitled

a guest
Jul 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. const int RED = 9; //const = can't be changed, int = integer = whole numbers
  2. const int GREEN = 6; //Number equalls pin
  3. const int BLUE = 5;
  4.  
  5. int REDval; //Makes a variable for later
  6. int GREENval;
  7. int BLUEval;
  8.  
  9. int userInput[13]; //Raw input from serial buffer, 13 bytes
  10. int startbyte; //start byte, begin readin input
  11. int i;
  12.  
  13. long previousMillis = 0;
  14. long blinkinterval = 1000;
  15. long pulsinterval = 10;
  16.  
  17. void setup()
  18. {
  19. Serial.begin(9600); //initialize serial communication
  20. REDval = 255; //setting the start value of each variable
  21. GREENval = 255;
  22. BLUEval = 255;
  23. update();
  24. }
  25. void update()
  26. {
  27. analogWrite(RED, REDval); //analogWrite needs to conditions: first is pin
  28. analogWrite(GREEN, GREENval); //second is value
  29. analogWrite(BLUE, BLUEval); //the update function keeps track of the value
  30. }
  31.  
  32. void loop()
  33. {
  34. //wait for serial input (min 13 bytes in buffer)
  35. if (Serial.available() >12){
  36. //If it's really the "true character" ('f')
  37. if (Serial.read() != 'f') {
  38. Serial.print("Error in first");
  39. Serial.flush();
  40. return;
  41. }
  42.  
  43. if (Serial.read() != ' '){
  44. Serial.print("Error in second");
  45. Serial.flush();
  46. return;
  47. }
  48. Serial.print("Woohoo, made it past all the checks!!");
  49. Serial.flush();
  50. }
  51.  
  52. }
Add Comment
Please, Sign In to add comment