#include // *** // *** Define the RX and TX pins. Choose any two // *** pins that are unused. Try to avoid D0 (pin 5) // *** and D2 (pin 7) if you plan to use I2C. // *** #define RX 2 // *** D3, Pin 2 #define TX 1 // *** D4, Pin 3 // *** // *** Define the software based serial port. Using the // *** name Serial so that code can be used on other // *** platforms that support hardware based serial. On // *** chips that support the hardware serial, just // *** comment this line. // *** SoftwareSerial Serial(RX, TX); const int analogPin = 3; // pin that the sensor is attached to //const int laser = 4; // pin that the LED is attached to const int threshold = 1000; // an arbitrary threshold level that's in the range of the analog input void setup() { // initialize the LED pin as an output: pinMode(0, OUTPUT); // initialize serial communications: Serial.begin(9600); } void loop() { // read the value of the potentiometer: int analogValue = analogRead(analogPin); // digitalWrite(laser, HIGH); // if the analog value is high enough, turn on the LED: if (analogValue > threshold) { // Serial.println("off"); //} digitalWrite(0, HIGH); Serial.println("off"); } else { digitalWrite(0, LOW); Serial.println("on"); } // print the analog value: //Serial.println(analogValue); //delay(1); // delay in between reads for stability }