sábado, 19 de setembro de 2015
quinta-feira, 13 de agosto de 2015
Protótipo Arduino e display LCD para o Mostrador digital câmbio 4L60E
Protótipo Arduino e display LCD para o Mostrador digital câmbio 4L60E. Um novo protótipo para o Mostrador digital. Feito com o arduino.
As chaves representam as solenóides A e B.
O potenciometro é para o ajuste de contraste do LCD.
Segue o programa.
#include <LiquidCrystal.h> //Inclui a biblioteca do LCD
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //Configura os pinos do Arduino para se comunicar com o LCD
int sola = 8; // Associando o nome sola ao pino 8 que corresponde solenóide A
int solb = 9; // Associando o nome solb ao pino 9 que corresponde solenóide B
void setup()
{
pinMode(sola, INPUT); // Inicializando o pino como INPUT
pinMode(solb, INPUT); // Inicializando o pino como INPUT
lcd.begin(16, 2); //Inicia o LCD com dimensões 16x2(Colunas x Linhas)
lcd.setCursor(0, 0); //Posiciona o cursor na primeira coluna(0) e na primeira linha(0) do LCD
lcd.print("Marcador digital"); //Escreve no LCD "Marcador digital”
lcd.setCursor(0, 1); //Posiciona o cursor na primeira coluna(0) e na segunda linha(1) do LCD
lcd.print("Câmbio 4L60E"); //Escreve no LCD “Câmbio 4L60E”
}
void loop()
{
int vala = digitalRead(sola); // le o valor na entrada sola
int valb = digitalRead(solb); // le o valor na entrada solb
if (vala == LOW and valb == LOW) // se sola = zero e solb = zero (solenoide A e B ligadas)
// marcha 1
{
lcd.setCursor(14, 1); //Posiciona o cursor na decima quarta coluna(14) e na segunda linha(1) do LCD
lcd.print("1"); //Escreve no LCD “1”
}
else
{
lcd.setCursor(14, 1); //Posiciona o cursor na decima quarta coluna(14) e na segunda linha(1) do LCD
lcd.print(" "); //Escreve no LCD “ ”
}
if (vala == HIGH and valb == LOW) // se sola = 1 e solb = zero (solenoide A desligada e B ligada)
// marcha 2
{
lcd.setCursor(14, 1); //Posiciona o cursor na decima quarta coluna(14) e na segunda linha(1) do LCD
lcd.print("2"); //Escreve no LCD “2”
}
else
{
lcd.setCursor(14, 1); //Posiciona o cursor na decima quarta coluna(14)) e na segunda linha(1) do LCD
lcd.print(" "); //Escreve no LCD “ ”
}
if (vala == HIGH and valb == HIGH) // se sola = 1 e solb = 1 (solenoide A e B desligadas)
// marcha 3
{
lcd.setCursor(14, 1); //Posiciona o cursor na decima quarta coluna(14) e na segunda linha(1) do LCD
lcd.print("3"); //Escreve no LCD “3”
}
else
{
lcd.setCursor(14, 1); //Posiciona o cursor na decima quarta coluna(14) e na segunda linha(1) do LCD
lcd.print(" "); //Escreve no LCD “ ”
}
if (vala == LOW and valb == HIGH) // se sola = 1 e solb = 1 (solenoide A ligada e B desligada)
// escreve 4 no display
{
lcd.setCursor(14, 1); //Posiciona o cursor na decima quarta coluna(14) e na segunda linha(1) do LCD
lcd.print("4"); //Escreve no LCD “4”
}
else
{
lcd.setCursor(14, 1); //Posiciona o cursor na decima quarta coluna(14) e na segunda linha(1) do LCD
lcd.print(" "); //Escreve no LCD “ ”
}
}
quarta-feira, 12 de agosto de 2015
Montagem protótipo para acionamento do display
https://123d.circuits.io/circuits/942594-the-unnamed-circuit/edit#breadboard
Programa do Arduino para o Indicador Digital do câmbio 4L60E
// Associando os segmentos do display aos pinos de saída na placa do Arduino.
// Cada segmento é um LED:
int leda = 1;
int ledb = 2;
int ledc = 3;
int ledd = 4;
int lede = 5;
int ledf = 6;
int ledg = 7;
int sola = 8; // Associando o nome sola ao pino 8 que corresponde solenóide A
int solb = 9; // Associando o nome solb ao pino 9 que corresponde solenóide B
// A rotina roda até ser pressionado resset:
void setup() {
// Inicializando os pinos digitais como OUTPUT.
pinMode(leda, OUTPUT);
pinMode(ledb, OUTPUT);
pinMode(ledc, OUTPUT);
pinMode(ledd, OUTPUT);
pinMode(lede, OUTPUT);
pinMode(ledf, OUTPUT);
pinMode(ledg, OUTPUT);
pinMode(sola, INPUT); // Inicializando o pino como INPUT
pinMode(solb, INPUT); // Inicializando o pino como INPUT
}
// A rotina em loop roda indefinidamente para sempre:
void loop() {
int vala = digitalRead(sola); // le o valor na entrada sola
int valb = digitalRead(solb); // le o valor na entrada solb
if (vala == LOW and valb == LOW) // se sola = zero e solb = zero (solenoide A e B ligadas)
{
// escreve 1 no display
digitalWrite(ledb, HIGH); // Liga o segmento b LED do display (HIGH é o nível de voltagem)
digitalWrite(ledc, HIGH); // Liga o segmento c LED do display (HIGH é o nível de voltagem)
}
else
// desliga todos os segmentos
{
digitalWrite(leda, LOW); // turn the LED off by making the voltage LOW
digitalWrite(ledb, LOW); // turn the LED off by making the voltage LOW
digitalWrite(ledc, LOW); // turn the LED off by making the voltage LOW
digitalWrite(ledd, LOW); // turn the LED off by making the voltage LOW
digitalWrite(lede, LOW); // turn the LED off by making the voltage LOW
digitalWrite(ledf, LOW); // turn the LED off by making the voltage LOW
digitalWrite(ledg, LOW); // turn the LED off by making the voltage LOW
}
if (vala == HIGH and valb == LOW) // se sola = 1 e solb = zero (solenoide A desligada e B ligada)
// escreve 2 no display
{
digitalWrite(leda, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(ledb, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(ledg, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(lede, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(ledd, HIGH); // turn the LED on (HIGH is the voltage level)
}
else
{
digitalWrite(leda, LOW); // turn the LED off by making the voltage LOW
digitalWrite(ledb, LOW); // turn the LED off by making the voltage LOW
digitalWrite(ledc, LOW); // turn the LED off by making the voltage LOW
digitalWrite(ledd, LOW); // turn the LED off by making the voltage LOW
digitalWrite(lede, LOW); // turn the LED off by making the voltage LOW
digitalWrite(ledf, LOW); // turn the LED off by making the voltage LOW
digitalWrite(ledg, LOW); // turn the LED off by making the voltage LOW
}
if (vala == HIGH and valb == HIGH) // se sola = 1 e solb = 1 (solenoide A e B desligadas)
// escreve 3 no display
{
digitalWrite(leda, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(ledb, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(ledg, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(ledc, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(ledd, HIGH); // turn the LED on (HIGH is the voltage level)
}
else
{
digitalWrite(leda, LOW); // turn the LED off by making the voltage LOW
digitalWrite(ledb, LOW); // turn the LED off by making the voltage LOW
digitalWrite(ledc, LOW); // turn the LED off by making the voltage LOW
digitalWrite(ledd, LOW); // turn the LED off by making the voltage LOW
digitalWrite(lede, LOW); // turn the LED off by making the voltage LOW
digitalWrite(ledf, LOW); // turn the LED off by making the voltage LOW
digitalWrite(ledg, LOW); // turn the LED off by making the voltage LOW
}
if (vala == LOW and valb == HIGH) // se sola = 1 e solb = 1 (solenoide A ligada e B desligada)
// escreve 4 no display
{
digitalWrite(ledf, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(ledb, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(ledg, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(ledc, HIGH); // turn the LED on (HIGH is the voltage level)
}
else
{
digitalWrite(leda, LOW); // turn the LED off by making the voltage LOW
digitalWrite(ledb, LOW); // turn the LED off by making the voltage LOW
digitalWrite(ledc, LOW); // turn the LED off by making the voltage LOW
digitalWrite(ledd, LOW); // turn the LED off by making the voltage LOW
digitalWrite(lede, LOW); // turn the LED off by making the voltage LOW
digitalWrite(ledf, LOW); // turn the LED off by making the voltage LOW
digitalWrite(ledg, LOW); // turn the LED off by making the voltage LOW
}
}
- via 123d.circuits.io