Day 11 Oct 3
For todays lab I had to write code where a user would input an angle and a servo would turn to angle, if the angle was invalid a red LED would turn on. However I could not get the red light to turn off after I entered an invalid angle. Here's the code //Sending Multiple Variables at Once //Define LED pins #include <Servo.h> const int SERVO=9; //Servo on Pin 9 Servo myServo; const int RED =12; const int GREEN =11; const int BLUE =10; //int data; char data; //Variables for RGB levels int rval = 0; int gval = 0; int bval = 0; int val = 0; void setup() { Serial.begin(9600); //Serial Port at 9600 baud //Set pins as outputs pinMode(RED, OUTPUT); pinMode(GREEN, OUTPUT); pinMode(BLUE, OUTPUT); myServo.attach(SERVO); } void loop() { //Keep working as long as data is in the buffer while (Serial.available() > 0) { data=Serial.read(); //if(data<0 && data> 180) if(data=='0') { digitalW...