demo buzzer, i2c screen
parent
fa45559221
commit
a311fdf0e7
|
@ -12,3 +12,8 @@
|
|||
platform = atmelavr
|
||||
board = uno
|
||||
framework = arduino
|
||||
|
||||
lib_deps =
|
||||
Wire
|
||||
blackhack/LCD_I2C@^2.3.0
|
||||
luisllamasbinaburo/I2CScanner@^1.0.1
|
||||
|
|
|
@ -1,18 +1,62 @@
|
|||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <LCD_I2C.h>
|
||||
// #include <I2C_Scanner.h>
|
||||
#include <I2CScanner.h>
|
||||
|
||||
// put function declarations here:
|
||||
int myFunction(int, int);
|
||||
#define BUZZER_PIN 11
|
||||
|
||||
I2CScanner scanner;
|
||||
|
||||
LCD_I2C lcd(0x27, 16, 2);
|
||||
|
||||
void helloBuzz();
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
int result = myFunction(2, 3);
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
|
||||
scanner.Init();
|
||||
|
||||
lcd.begin();
|
||||
lcd.backlight();
|
||||
|
||||
Serial.begin(9600);
|
||||
Serial.println("Hello World!");
|
||||
helloBuzz();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void buzzOff()
|
||||
{
|
||||
noTone(BUZZER_PIN);
|
||||
pinMode(BUZZER_PIN, INPUT);
|
||||
}
|
||||
|
||||
void helloBuzz() {
|
||||
tone(BUZZER_PIN, 500, 100);
|
||||
delay(100);
|
||||
tone(BUZZER_PIN, 1000, 100);
|
||||
delay(100);
|
||||
tone(BUZZER_PIN, 4000, 100);
|
||||
delay(100);
|
||||
buzzOff();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
}
|
||||
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
|
||||
delay(1000); // wait for a second
|
||||
|
||||
// put function definitions here:
|
||||
int myFunction(int x, int y) {
|
||||
return x + y;
|
||||
}
|
||||
lcd.clear();
|
||||
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
|
||||
delay(1000); // wait for a second
|
||||
|
||||
tone(BUZZER_PIN, 200, 20);
|
||||
|
||||
scanner.Scan();
|
||||
|
||||
lcd.print(" Hello"); // You can make spaces using well... spaces
|
||||
lcd.setCursor(5, 1); // Or setting the cursor in the desired position.
|
||||
lcd.print("World!");
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue