PROBLEMA PARA ACTIVAR LAS SALIDAS DIGITALES

Hola, estoy intentando activar las salidas digitales desde el monitor serie de Arduino pero no tengo buenos resultados, quisiera saber si me pueden ayudar. estoy intentando con este codigo:

#include <Indio.h>
#include <Wire.h>

#include <UC1701.h>

static UC1701 lcd;
char dato;

void setup() {

  // put your setup code here, to run once:
  lcd.begin();


Serial.begin(9600); 

Indio.digitalMode(1,OUTPUT);
Indio.digitalMode(2,OUTPUT);


}

void loop() {
  // put your main code here, to run repeatedly:

 

if(Serial.available()>0)   // pregunta si existe un valor diferente de cero
{

 dato=Serial.read();  //lee el dato
 if(dato=='a')
 {
    lcd.clear();
    lcd.setCursor(1, 1);
  lcd.print("BOMBA ON");
  Indio.digitalWrite(1,HIGH);
 
 }
 
 if(dato=='b')
 {
lcd.clear();
  lcd.setCursor(1, 1);
  lcd.print("BOMBA OFF");
   Indio.digitalWrite(1,LOW);
 }

 if(dato=='c')
 {
lcd.clear();
  lcd.setCursor(1, 1);
  lcd.print("VALVULA ON");
   Indio.digitalWrite(2,HIGH);
 }

 if(dato=='d')
 {
lcd.clear();
  lcd.setCursor(1, 1);
  lcd.print("VALVULA OFF");
  Indio.digitalWrite(2,LOW);
 }

}
delay(10);
}

Alex Mallitasig
Alex Mallitasig
7
| 2 1 1
Asked on 12/2/16, 1:19 PM
0
vote
2510 Views

English? How can we help if we don't even understand the issue..

Albert Tobing
on 4/16/17, 11:43 AM

He is trying to switch digital outputs using commands from the serial monitor.

The software seems ok.

Probably the problem is in the serial monitor on the pc.

Please enable sending CR-LF at the bottom of the window and try again.

You can also echo your chars on serial monitor to find out what the software is actually doing.

Did you power up the unit from 24V first?

If you power it up from USB and then switch on 24V power, the unit will not initialize properly and outputs will not work.

 

El programa parece ok.

Probabilmente el problema esta en el serial monitor.

Por favor abilita CR-LF abaho la ventana y hace la prueba otra vez.

Puede asi regresar tu dato al serial monitor por ver lo que esta haciendo de verdad.

Utiliza Serial.print(dato) in diferentes lugares.

La alimentacion 24V debe ser aprendida antes del USB, si no la inicializacion del hardware no esta correcta y las salidas no van a funcionar!

Stefano Giuseppe Bonvini
Stefano Giuseppe Bonvini
107
| 4 1 3
Answered on 4/17/17, 11:10 AM
0
vote

Your answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

Ask a Question

Keep Informed

About This Forum

This community is for professionals and enthusiasts of our products and services.

Read Guidelines

Question tools

30 follower(s)

Stats

Asked: 12/2/16, 1:19 PM
Seen: 2510 times
Last updated: 4/17/17, 11:10 AM