int ledPin = A3; // specify the pin for the LED light
bool led = 0;
int incomingByte;
void setup() {
incomingByte = 0;
Serial.begin(9600); // open serial communication at 9600 baud
pinMode(ledPin, OUTPUT); // set the pin mode to output
Serial.println();
}
void loop() {
if (Serial.available() > 0) { // check if there is data available
incomingByte = Serial.read();
analogWrite(ledPin, incomingByte);
Serial.println(incomingByte);
/*String incoming = Serial.readString(); // read the data as a string
if (incoming == "255") { // if the received data is "toggle"
led = 1;
}
if (incoming == "0") { // if the received data is "toggle"
led = 0;
}
digitalWrite(ledPin, led); // toggle the LED light*/
}
}