implemenetd first TODO
This commit is contained in:
parent
0001755388
commit
6be93695ce
102
code/code.ino
102
code/code.ino
|
@ -1,4 +1,3 @@
|
|||
//TODO: Divide interface with screens, each screen is a settings for each feature (address, mode, password, encryption on/off)
|
||||
//TODO: Learn how to use radio module, transmit data with it
|
||||
//TODO: Learn how to use mic. in arduino, transmit plain sound among two arduinos and play it
|
||||
//TODO: Implement encryption and decryption using AES128, test it with text, then use to encrypt sound
|
||||
|
@ -8,17 +7,32 @@
|
|||
#include <nRF24L01.h>
|
||||
#include <RF24.h>
|
||||
#include <AESLib.h>
|
||||
#include <EEPROM.h>
|
||||
|
||||
//Components
|
||||
LiquidCrystal_I2C lcd(0x27, 16, 2);
|
||||
RF24 radio(7,8);
|
||||
|
||||
//Settings
|
||||
byte unsigned address = -1;
|
||||
byte unsigned address = 1;
|
||||
unsigned short key = 0;
|
||||
String seed = "1305b5cfa1a59e9789de"; // "random" seed ;)
|
||||
byte unsigned screen = 0;
|
||||
const String seed = "1305b5cfa1a59e9789de"; // "random" seed ;)
|
||||
String password;
|
||||
bool mode = 0; // 0 = transmit, 1 = recieve, bool is 2 bytes less than byte :)
|
||||
bool encryption = 1; // will the trafic be encrypted?
|
||||
|
||||
//Switch screen button
|
||||
const byte switchScreenButton = 2;
|
||||
byte switchScreenLast;
|
||||
|
||||
//IncreaseButton
|
||||
const byte increaseButton = 3;
|
||||
byte increaseButtonLast;
|
||||
|
||||
//DecreaseButton
|
||||
const byte decreaseButton = 4;
|
||||
byte decreaseButtonLast;
|
||||
|
||||
void switchMode();
|
||||
void printOutput();
|
||||
|
@ -26,6 +40,11 @@ void updatePassword();
|
|||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
//Setting up buttons
|
||||
pinMode(switchScreenButton, INPUT_PULLUP);
|
||||
pinMode(increaseButton, INPUT_PULLUP);
|
||||
pinMode(decreaseButton, INPUT_PULLUP);
|
||||
|
||||
//Setting up a radio module
|
||||
radio.begin();
|
||||
|
@ -40,9 +59,56 @@ void setup() {
|
|||
}
|
||||
|
||||
void loop() {
|
||||
switchMode();
|
||||
// switchMode();
|
||||
byte switchButtonValue = digitalRead(switchScreenButton);
|
||||
byte increaseValue = digitalRead(increaseButton);
|
||||
byte decreaseValue = digitalRead(decreaseButton);
|
||||
|
||||
|
||||
if (switchButtonValue == 0 && switchScreenLast == 1) {
|
||||
screen = screen < 3? screen + 1 : 0;
|
||||
}
|
||||
|
||||
if (increaseValue == 0 && increaseButtonLast == 1) {
|
||||
switch (screen) {
|
||||
case 0:
|
||||
mode = 1;
|
||||
break;
|
||||
case 1:
|
||||
address = address < 127? address + 1 : 0;
|
||||
break;
|
||||
case 2:
|
||||
key ++;
|
||||
break;
|
||||
case 3:
|
||||
encryption = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (decreaseValue == 0 && decreaseButtonLast == 1) {
|
||||
switch (screen) {
|
||||
case 0:
|
||||
mode = 0;
|
||||
break;
|
||||
case 1:
|
||||
address = address > 0? address - 1 : 127;
|
||||
break;
|
||||
case 2:
|
||||
key --;
|
||||
break;
|
||||
case 3:
|
||||
encryption = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switchScreenLast = switchButtonValue;
|
||||
increaseButtonLast = increaseValue;
|
||||
decreaseButtonLast = decreaseValue;
|
||||
|
||||
printOutput();
|
||||
delay(500);
|
||||
delay(100);
|
||||
}
|
||||
|
||||
void switchMode () {
|
||||
|
@ -58,12 +124,26 @@ void switchMode () {
|
|||
}
|
||||
|
||||
void printOutput () {
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.print("Mode: ");
|
||||
lcd.print(mode? "rec." : "tra.");
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print("Addr.: ");
|
||||
lcd.print(address);
|
||||
lcd.clear();
|
||||
switch (screen) {
|
||||
case 0:
|
||||
lcd.print("Mode: ");
|
||||
lcd.print(mode? "rec." : "tra.");
|
||||
break;
|
||||
case 1:
|
||||
lcd.print("Addr.: ");
|
||||
lcd.print(address);
|
||||
break;
|
||||
case 2:
|
||||
lcd.print("Password: ");
|
||||
lcd.print(key);
|
||||
break;
|
||||
case 3:
|
||||
lcd.print("Enc. :");
|
||||
lcd.print(encryption? "yes" : "no");
|
||||
}
|
||||
|
||||
|
||||
// for (int i = 0; i < 5; i ++) lcd.print(address[i] - '0');
|
||||
//lcd.print(mode);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue