char incomingByte = 0; // for incoming serial data #define PIN 7; // Analog output pin that the diffuser is attached to void setup() { Serial.begin(9600); // opens serial port, sets data rate to 9600 bps pinMode(7,OUTPUT); //#define PIN 7; // Analog output pin that the diffuser is attached to } void loop() { // send data only when you receive data: if (Serial.available() >= 0) { // read the incoming byte: incomingByte = Serial.read(); if (incomingByte == '1'){ digitalWrite(7,HIGH); } else if (incomingByte == '0'){ digitalWrite(7,LOW); } } }