![]() |
Añadir leyenda |
PROGRAMACIÓN EN PYTHON
import serial
import time
puerto=serial.Serial("COM1",9600,timeout=1)
time.sleep(0.5);
while(1):
pin=raw_input("ingrese pin: ")
puerto.write(pin)
time.sleep(1)
nivel=raw_input("ingrese nivel: ")
puerto.write(nivel)
time.sleep(1)
a=raw_input("deseas continuar: ")
if a=='n':
exit()
if a=='s':
print " "
else:
exit()
PROGRAMACIÓN EN ARDUINO
int nivel;
char c;
byte pin;
int pines;
void setup()
{
Serial.begin(9600);
for(pin=2; pin<6; pin++){
pinMode(pin, OUTPUT);
digitalWrite(pin, LOW);
}
}
void loop()
{
x1:
if(Serial.available()==0)
goto x1;
c= Serial.read();
pines=c;pines=pines-0x30;
x2:
if(Serial.available()==0)
goto x2;
c= Serial.read();
nivel=c;nivel=nivel-0x30;
//if(nivel==0)
digitalWrite(pines, nivel);
//else digitalWrite(pines, nivel);
}
CONECCIONES
No hay comentarios.:
Publicar un comentario