/*
codigo del arduino utilizado ene l ejemplo, si lo cargan en cualquier ARDUINO UNO veran que funciona perfectamente
*/
// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
int incomingByte = 0; // for incoming serial data
void setup() {pinMode(12, OUTPUT);pinMode(11, OUTPUT);pinMode(13, OUTPUT);
// initialize serial communications at 9600 bps:
Serial.begin(9600,SERIAL_7N1);//Serial.begin(speed, config) config: sets data, parity, and stop bits. Valid values are :
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
//outputValue = map(sensorValue, 0, 1023, 0, 255);
// change the analog out value:
//analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:
//Serial.print("sensor = " );
Serial.println(sensorValue);
//Serial.print("\t output = ");
//Serial.println(outputValue);
// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
switch(incomingByte)
{
case 105: digitalWrite(13, HIGH); break;//i
case 106: digitalWrite(12, HIGH); break;//j
case 107: digitalWrite(11, HIGH); break;//k
case 108: digitalWrite(13, LOW); break;//l
case 109: digitalWrite(12, LOW); break;//m
case 110: digitalWrite(11, LOW); break;//n
case 111: digitalWrite(11, LOW);digitalWrite(12, LOW);digitalWrite(13, LOW); break;//todas apagadas "o"
case 112: digitalWrite(13, HIGH);digitalWrite(12, HIGH);digitalWrite(11, HIGH); break;//todas prendidas "p"
}
// say what you got:
// Serial.print("I received: ");
// Serial.print(incomingByte, DEC);
}
delay(100);
}