olá sou novato no arduino e gostaria que voçês me podessem compilar este programa de modo que ele funcione.
FMKR28MHI3TXWXF.zip (671 Bytes)
olá sou novato no arduino e gostaria que voçês me podessem compilar este programa de modo que ele funcione.
FMKR28MHI3TXWXF.zip (671 Bytes)
Se e pequeno podes fazer copy/paste... se nao couber dentro dos 9000 caracteres de limite, se calhar e melhor dizeres exactamente o que pretendes.
Falta as definições das constantes referentes aos pinos:
const int buttonPin2 = 6;
const int buttonPin3 = 7;
const int buttonPin4 = 8;
const int led = 13;
O programa completo ficaria assim:
// this constant won't change:
const int buttonPin = 5; // the pin that the pushbutton is attached to
const int buttonPin2 = 6;
const int buttonPin3 = 7;
const int buttonPin4 = 8;
const int led = 13;
// Variables will change:
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button
void setup() {
// initialize the button pin as a input:
pinMode(buttonPin, INPUT);
// initialize serial communication:
Serial.begin(9600);
}
void loop() {
// read the pushbutton input pin:
buttonState = digitalRead(buttonPin);
// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
if (buttonState == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
Serial.println("Headlights");
delay (1000);
}
}
buttonState = digitalRead(buttonPin2);
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
Serial.println("Windshield Wipers");
delay (1000);
}
}
buttonState = digitalRead(buttonPin3);
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
Serial.println("Pit Speed Limiter");
delay (1000);
}
}
buttonState = digitalRead(buttonPin4);
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
Serial.println("Start Engine");
digitalWrite(led, HIGH);
//delay (10);
digitalWrite(led, LOW);
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;
}