Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h>
- #include <TimerOne.h>
- #define botao_incremento A0
- #define botao_decremento A1
- #define botao_frequencia_incremento A2
- #define botao_frequencia_decremento A3
- unsigned long freq;
- unsigned int dspduty;
- unsigned int duty;
- LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
- // ------------------------------------ setup -------------------------------
- void setup()
- {
- Serial.begin(9600);
- lcd.begin(16,2);
- lcd.print("BEM VINDOS");
- pinMode(A0, INPUT);
- pinMode(A1, INPUT);
- pinMode(A2, INPUT);
- pinMode(A3, INPUT);
- pinMode(9, OUTPUT);
- }
- // ------------------------------------ loop -------------------------------
- void loop()
- {
- lcd.print (" ");
- lcd.setCursor(0,1);
- Timer1.initialize(freq);
- Timer1.pwm(9, duty);
- delay(100);
- if(digitalRead(botao_frequencia_incremento) == HIGH)
- {
- freq = freq +1000;
- // Serial.println(freq);
- delay(500);
- }
- if(digitalRead(botao_frequencia_decremento)== HIGH)
- {
- freq = freq -1000;
- // Serial.println(freq);
- delay(500);
- }
- lcd.print (" ");
- lcd.setCursor(0,1);
- if(digitalRead(botao_incremento) == HIGH)
- {
- duty = duty +500;
- delay(500);
- }
- if(digitalRead(botao_decremento) == HIGH)
- {
- duty = duty -500;
- delay(500);
- }
- // Serial.println(duty);
- dspduty = map(duty,0 ,65535,0, 100);
- Serial.println(dspduty);
- lcd.print(dspduty);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement