Advertisement
Guest User

Untitled

a guest
Feb 28th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. #include <LiquidCrystal_I2C.h>
  2. #include <Wire.h>
  3. int led3 =3 ; // luz de fundo lcd
  4. LiquidCrystal_I2C lcd(0x3F,2,1,0,4,5,6,7,3, POSITIVE); // lcd 16x2 i2c
  5.  
  6. unsigned long delay1 = 0;
  7. unsigned long delay2 = 0;
  8.  
  9.  
  10. int led12 = 12; // led 1
  11. int led13 = 13; // led 2
  12. int botao1 = 7; // BOTAO 1
  13. int botao2 = 6; // BOTAO 2
  14. int botao3 = 5; // BOTAO 3
  15. int estado1 = 0;
  16. int estado2 = 0;
  17. int estado3 = 0;
  18.  
  19.  
  20. void setup() {
  21. // put your setup code here, to run once:
  22.  
  23. pinMode(led12,OUTPUT);
  24. pinMode(led13,OUTPUT);
  25. pinMode(botao1,INPUT);
  26. pinMode(botao2,INPUT);
  27. pinMode(botao3,INPUT);
  28.  
  29. lcd.begin (16,2);
  30. lcd.clear();
  31. analogWrite(3,111);
  32.  
  33. }
  34.  
  35. void loop() {
  36. // put your main code here, to run repeatedly:
  37.  
  38. estado1 = digitalRead(botao1) ; // leitura do botao 1
  39. estado2 = digitalRead(botao2) ; // leitura do botao 2
  40. estado3 = digitalRead(botao3) ; // leitura do botao 3
  41.  
  42.  
  43. if(estado1 and estado2 == HIGH){
  44.  
  45. led1();} // chama função led1
  46.  
  47.  
  48.  
  49.  
  50. if(estado1 and estado3 == HIGH){
  51. led2();} // chama função led2
  52.  
  53. }
  54.  
  55.  
  56.  
  57. void led1(){ // função led1
  58.  
  59. if ((millis() - delay1) >=5000){ //função millis 1
  60. digitalWrite(led12,HIGH);
  61. lcd.print("led 1");}
  62. if ((millis() - delay1) <5000){
  63. digitalWrite(led12,LOW);}
  64. if ((millis() - delay1) >= 10000) {
  65. delay1 = millis();
  66. }
  67. lcd.clear(); // limpa lcd
  68.  
  69. }
  70.  
  71.  
  72. void led2(){ // função led2
  73.  
  74. if ((millis() - delay2) >=500){ //função millis 2
  75. digitalWrite(led13,HIGH);
  76. lcd.print("led 1");}
  77. if ((millis() - delay2) <500){
  78. digitalWrite(led13,LOW);}
  79. if ((millis() - delay2) >= 1000) {
  80. delay2 = millis();
  81. }
  82. lcd.clear(); // limpa lcd
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement