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