# Ajuda com codigo basico

**URL:** <https://forum.fazedores.com/t/ajuda-com-codigo-basico/4372>\
**Category:** Arduino\
**Created:** [Maio 31, 2017, 1:54am UTC](https://forum.fazedores.com/t/ajuda-com-codigo-basico/4372 "2017-05-31T01:54:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cabana](https://avatars.discourse-cdn.com/v4/letter/c/cab0a1/32.png) [@cabana](https://forum.fazedores.com/u/cabana)\
**Post date:** [Maio 31, 2017, 1:54am UTC](https://forum.fazedores.com/t/ajuda-com-codigo-basico/4372/1 "2017-05-31T01:54:10Z")

</div>

BOA NOITE AMIGOS

GOSTARIA DE UMA AJUDA COM ESSE CÓDIGO ABAIXO PRECISO ACIONAR COM UM BOTÃO DUAS SOLENOIDES DE CADA VEZ POREM UMA DELAS DEVE SE REPETIR NO BOTÃO SEGUINTE OU SEJA UMA

BOTÃO 1 ACIONA RANGE E FWD1  
BOTAO 2 ACIONA RANGE2 E FWD1  
BOTAO 3 ACIONA RANGE2 E FWD2  
BOTAO 4 ACIONA RANGE1 E REV1  
BOTAO 5 ACIONA RANGE2 E REV1

E ESCREVE NO DISPLAY CADA AÇÃO

INICIEI O CODIGO ATE ACIONAR O BOTAO 1 OK QUANDO ACIONO O BOTAO2 JA DA ZEBRA O DISPLAY NAO ESCREVE

#include “LiquidCrystal.h”  
#include "Limits.h"  
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //essa é a pinagem LCD no UNO

const int buttonPin0 = 8; // the number of the pushbutton pin  
const int buttonPin1 = 10; // the number of the pushbutton pin

const int RANGE1 = 13; // the number of the LED pin  
const int RANGE2 = 6; // the number of the LED pin  
const int FDW1 = 7; // the number of the LED pin  
const int FDW2 = 9; // the number of the LED pin

// variables will change:  
int ZERO = 0; // variable for reading the pushbutton status  
int UM = 0; // variable for reading the pushbutton status

void setup() {

//Inicializando o LCD e informando o tamanho de 16 colunas e 2 linhas  
//que é o tamanho do LCD JHD 162A usado neste projeto.  
lcd.begin(16, 2);

lcd.clear(); //limpa o display do LCD.  
lcd.print(" TECH CABANA "); //imprime a string no display do LCD.  
lcd.setCursor(0,1);  
lcd.print(“TEST TRANSMISSAO”);  
delay(5000);  
lcd.clear(); //limpa o display do LCD.

// initialize the LED pin as an output:  
pinMode(RANGE1, OUTPUT);  
// initialize the LED pin as an output:  
pinMode(RANGE2, OUTPUT);  
// initialize the LED pin as an output:  
pinMode(FDW1, OUTPUT);  
// initialize the LED pin as an output:  
pinMode(FDW2, OUTPUT);  
// initialize the pushbutton pin as an input:  
pinMode(buttonPin0, INPUT);  
// initialize the pushbutton pin as an input:  
pinMode(buttonPin1, INPUT);  
}

void loop(){  
// read the state of the pushbutton value:  
ZERO = digitalRead(buttonPin0);  
UM = digitalRead(buttonPin1);

// check if the pushbutton is pressed.  
// if it is, the buttonState is HIGH:  
if (ZERO == HIGH) {  
// turn LED on:  
digitalWrite(RANGE1, HIGH);  
digitalWrite(FDW1, HIGH);  
lcd.setCursor(1,0);  
lcd.print(" HYSTER H155FT ");  
lcd.setCursor(0,1);  
lcd.print(“PRIMEIRA FRENTE”);  
}  
else {  
// turn LED off:  
digitalWrite(RANGE1, LOW);  
digitalWrite(FDW1, LOW);  
lcd.clear();  
}

}  
COMO FAÇO PARA ACIONAR O BOTAO 2 E ESCREVER SEGUNDA A FRENTE SE ME AJUDAREM A PARTIR DO TERCEIRO JA CONSIGO RESOLVER SOZINHO.

OBRIGADO

---

<div class="post-metadata">

**Author:** ![evandroluiz](https://avatars.discourse-cdn.com/v4/letter/e/c4cdca/32.png) [@evandroluiz](https://forum.fazedores.com/u/evandroluiz)\
**Post date:** [Junho 9, 2017, 10:41pm UTC](https://forum.fazedores.com/t/ajuda-com-codigo-basico/4372/2 "2017-06-09T22:41:39Z")

</div>

> [@cabana](#):
>
> if (ZERO == HIGH) {  
> …  
> else {  
> // turn LED off:  
> digitalWrite(RANGE1, LOW);  
> digitalWrite(FDW1, LOW);  
> **lcd.clear();**

Seu código diz que se o botão ZERO não estiver acionado é para limpar o display…
