Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Teste leds + Teclado
- // Configurando os pinos:
- //LEDS
- const int leD6 = 8; // the number of the LED pin
- const int leD5 = 9; // the number of the LED pin
- const int leD4 = 10; // the number of the LED pin
- const int leD3 = 11; // the number of the LED pin
- const int leD2 = 12; // the number of the LED pin
- const int leD1 = 13;
- //Botoes
- const int K4 = A0; // the number of the pushbutton pin
- const int K3 = A1; // the number of the pushbutton pin
- const int K2 = A2; // the number of the pushbutton pin
- const int K1 = A3; // the number of the pushbutton pin
- //Energia Botoes
- const int tecl = A4; // the number of the pushbutton pin
- // variables will change:
- int ledstate = LOW; // variable for reading the pushbutton status
- unsigned long previousMillis = 0;
- void setup() {
- pinMode(leD1, OUTPUT);
- pinMode(leD2, OUTPUT);
- pinMode(leD3, OUTPUT);
- pinMode(leD4, OUTPUT);
- pinMode(leD5, OUTPUT);
- pinMode(leD6, OUTPUT);
- pinMode(K1, INPUT);
- digitalWrite(K1, HIGH);
- pinMode(K2, INPUT);
- digitalWrite(K2, HIGH);
- pinMode(K3, INPUT);
- digitalWrite(K3, HIGH);
- pinMode(K4, INPUT);
- digitalWrite(K4, HIGH);
- pinMode(tecl, OUTPUT);
- digitalWrite(tecl, LOW);
- }
- void loop() {
- if (digitalRead(K1) == LOW) {
- digitalWrite(leD1, HIGH);
- }
- else {
- // turn LED off:
- digitalWrite(leD1, LOW);
- }
- if (digitalRead(K2) == LOW) {
- digitalWrite(leD2, HIGH);
- }
- else {
- // turn LED off:
- digitalWrite(leD2, LOW);
- }
- if (digitalRead(K3) == LOW) {
- digitalWrite(leD3, HIGH);
- }
- else {
- // turn LED off:
- digitalWrite(leD3, LOW);
- }
- if (digitalRead(K4) == LOW) {
- digitalWrite(leD4, HIGH);
- }
- else {
- // turn LED off:
- digitalWrite(leD4, LOW);
- }
- unsigned long currentMillis = millis();
- if(currentMillis - previousMillis >= 500) {
- previousMillis = currentMillis;
- if (ledstate == LOW)
- ledstate = HIGH;
- else
- ledstate = LOW;
- digitalWrite(leD5, ledstate);
- digitalWrite(leD6, !ledstate);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement