hi
I am looking to wiring for reference, and I'd like to ask about some language comparisons. As I am new to this as we all are, please understand.
Here is what I've altered in the serial:light serial example.
// light serial
int ledpin=13;
int val=0;
int analPin = 0;
void setup() {
beginSerial(19200);
pinMode(ledpin, OUTPUT);
}
void loop() {
val = analogRead(analPin);
printInteger(val);
printByte(1);
digitalWrite(ledpin, HIGH);
printByte(0);
delay(100);
digitalWrite(ledpin, HIGH);
}
//original code from wiring
// light serial
// by BARRAGAN http://people.interaction-ivrea.it/h.barragan
char val; // variable to receive data from the serial port
int ledpin = 48; // LED connected to pin 48 (on-board LED)
void setup()
{
pinMode(ledpin, OUTPUT); // pin 48 (on-board LED) as OUTPUT
Serial.begin(9600); // start serial communication at 9600bps
}
void loop() {
if( Serial.available() ) // if data is available to read
{
val = Serial.read(); // read it and store it in 'val'
}
if( val == 'H' ) // if 'H' was received
{
digitalWrite(ledpin, HIGH); // turn ON the LED
} else {
digitalWrite(ledpin, LOW); // otherwise turn it OFF
}
delay(100); // wait 100ms for next reading
}
Is this correct? I haven't got any result from the led light...
Please let me know what I should change.
thanks