/* Laser Control Board Controls a laser line diode by switching the power on and off (using a relay in my case) When it recieves an 'G' (for go on) via serial, it turns the laser on. When it gets an 'F' (for off), it turns it off. Oh, and the bord acknolages the change in status with 'K'. If somehow communication fails, print 'N'. */ int relayPin = 13; // LED connected to digital pin 13 char command; int success=0; void setup() { pinMode(relayPin, OUTPUT); // sets the digital pin as output beginSerial(9600); } void loop() { if(serialAvailable()) { command = serialRead(); if (command=='G') { digitalWrite(relayPin,HIGH); success=1; } else if (command=='F') { digitalWrite(relayPin,LOW); success=1; } else { success=0; } delay(20); //Delays 2/10ths of a second to make sure the laser has come on if (success==1) { serialWrite('K'); } else { serialWrite('N'); } success=0; } }