Compare commits
3 Commits
fa45559221
...
1da249ad69
Author | SHA1 | Date |
---|---|---|
radex | 1da249ad69 | |
radex | 792cac609d | |
radex | a311fdf0e7 |
|
@ -12,3 +12,9 @@
|
|||
platform = atmelavr
|
||||
board = uno
|
||||
framework = arduino
|
||||
|
||||
lib_deps =
|
||||
Wire
|
||||
blackhack/LCD_I2C@^2.3.0
|
||||
luisllamasbinaburo/I2CScanner@^1.0.1
|
||||
robtillaart/PCF8574@^0.4.1
|
||||
|
|
|
@ -1,18 +1,92 @@
|
|||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <LCD_I2C.h>
|
||||
// #include <I2C_Scanner.h>
|
||||
#include <I2CScanner.h>
|
||||
#include <PCF8574.h>
|
||||
|
||||
// put function declarations here:
|
||||
int myFunction(int, int);
|
||||
#define BUZZER_PIN 11
|
||||
|
||||
// when rotated clockwise, CLK changes before DT
|
||||
#define CLK_PIN 7
|
||||
#define DT_PIN 6
|
||||
#define SW_PIN 5 // switch, goes low when pressed
|
||||
|
||||
I2CScanner scanner;
|
||||
|
||||
LCD_I2C lcd(0x27, 16, 2);
|
||||
PCF8574 PCF(0x21, &Wire);
|
||||
|
||||
void helloBuzz();
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
int result = myFunction(2, 3);
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
pinMode(CLK_PIN, INPUT);
|
||||
pinMode(DT_PIN, INPUT);
|
||||
pinMode(SW_PIN, INPUT_PULLUP);
|
||||
|
||||
Wire.begin();
|
||||
scanner.Init();
|
||||
|
||||
lcd.begin();
|
||||
lcd.backlight();
|
||||
|
||||
Serial.begin(9600);
|
||||
Serial.println("Hello World!");
|
||||
helloBuzz();
|
||||
|
||||
if (!PCF.begin())
|
||||
{
|
||||
Serial.println("could not initialize...");
|
||||
}
|
||||
if (!PCF.isConnected())
|
||||
{
|
||||
Serial.println("=> not connected");
|
||||
while(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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:
|
||||
}
|
||||
tone(BUZZER_PIN, 100, 5);
|
||||
|
||||
// put function definitions here:
|
||||
int myFunction(int x, int y) {
|
||||
return x + y;
|
||||
}
|
||||
// scanner.Scan();
|
||||
|
||||
lcd.print(" cewk-o-mator ");
|
||||
lcd.print(" HSWAW 2024 ");
|
||||
|
||||
PCF.write8(0b11110000); // first 4 bits are columns, low when pressed
|
||||
// PCF.write8(0b00001111); // last 4 bits are rows, low when pressed
|
||||
int x = PCF.read8();
|
||||
// Serial.print("Keyboard: ");
|
||||
// Serial.println(x, BIN);
|
||||
|
||||
bool clk = digitalRead(CLK_PIN);
|
||||
bool dt = digitalRead(DT_PIN);
|
||||
bool sw = digitalRead(SW_PIN);
|
||||
|
||||
Serial.print("CLK: ");
|
||||
Serial.print(clk);
|
||||
Serial.print(" DT: ");
|
||||
Serial.print(dt);
|
||||
Serial.print(" SW: ");
|
||||
Serial.println(sw);
|
||||
|
||||
delay(200);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue