a lot of changes
This commit is contained in:
parent
fb8ff65aea
commit
7022455ed7
|
@ -11,6 +11,8 @@
|
||||||
//Components
|
//Components
|
||||||
LiquidCrystal_I2C lcd(0x27, 16, 2);
|
LiquidCrystal_I2C lcd(0x27, 16, 2);
|
||||||
RF24 radio(9,10); // CE, CSN
|
RF24 radio(9,10); // CE, CSN
|
||||||
|
const byte micPin = A0;
|
||||||
|
|
||||||
|
|
||||||
//Settings
|
//Settings
|
||||||
//byte unsigned address = 1;
|
//byte unsigned address = 1;
|
||||||
|
@ -27,24 +29,29 @@ byte value = 0;
|
||||||
bool isScreenChanged = true; // we must display first time
|
bool isScreenChanged = true; // we must display first time
|
||||||
|
|
||||||
//Switch screen button
|
//Switch screen button
|
||||||
const byte switchScreenButton = 2;
|
const byte switchScreenButton = A1;
|
||||||
byte switchScreenLast;
|
byte switchScreenLast;
|
||||||
|
|
||||||
//IncreaseButton
|
//IncreaseButton
|
||||||
const byte increaseButton = 3;
|
const byte increaseButton = A2;
|
||||||
byte increaseButtonLast;
|
byte increaseButtonLast;
|
||||||
|
|
||||||
//DecreaseButton
|
//DecreaseButton
|
||||||
const byte decreaseButton = 4;
|
const byte decreaseButton = A3;
|
||||||
byte decreaseButtonLast;
|
byte decreaseButtonLast;
|
||||||
|
|
||||||
void switchMode();
|
void switchMode();
|
||||||
void printOutput();
|
void printOutput();
|
||||||
void updatePassword();
|
void updatePassword();
|
||||||
|
|
||||||
|
//short micValue = 337;
|
||||||
|
//const short micBaseline = 337;// 3.3v / 2 = 1.56v, 1.56/5*1024 = 337.
|
||||||
|
|
||||||
|
short micValues[32];
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
pinMode(micPin, INPUT);
|
||||||
//Setting up buttons
|
//Setting up buttons
|
||||||
pinMode(switchScreenButton, INPUT_PULLUP);
|
pinMode(switchScreenButton, INPUT_PULLUP);
|
||||||
pinMode(increaseButton, INPUT_PULLUP);
|
pinMode(increaseButton, INPUT_PULLUP);
|
||||||
|
@ -65,17 +72,18 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// switchMode();
|
switchMode();
|
||||||
|
|
||||||
if (!mode) {// transmit
|
if (!mode) {// transmit
|
||||||
const char text[] = "Hello world!";
|
for (int i = 0; i < 32; i ++) {
|
||||||
if (radio.write(&text, sizeof(text))) Serial.println("данные успешно отправлены");
|
micValues[i] = analogRead(micPin) << 2;
|
||||||
else Serial.println("хуй там");
|
}
|
||||||
|
radio.write(micValues, 32);
|
||||||
} else { // receive
|
} else { // receive
|
||||||
if (radio.available()) {
|
if (radio.available()) {
|
||||||
char text[32] = "";
|
radio.read(micValues, 32);
|
||||||
radio.read(&text, sizeof(text));
|
for (int i = 0; i < 32; i++) {
|
||||||
Serial.println(text);
|
PORTD = micValues[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,15 +102,14 @@ void loop() {
|
||||||
switch (screen) {
|
switch (screen) {
|
||||||
case 0:
|
case 0:
|
||||||
mode = !mode;
|
mode = !mode;
|
||||||
Serial.println("xui");
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (decreaseValue == 0 && decreaseButtonLast == 1)
|
if (decreaseValue == 0 && decreaseButtonLast == 1)
|
||||||
// address = address > 0? address - 1 : 127;
|
// address = address > 0? address - 1 : 127;
|
||||||
Serial.println("");
|
1+1;
|
||||||
else
|
else
|
||||||
// address = address < 127? address + 1 : 0;
|
// address = address < 127? address + 1 : 0;
|
||||||
Serial.println("");
|
1+1;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (decreaseValue == 0 && decreaseButtonLast == 1){
|
if (decreaseValue == 0 && decreaseButtonLast == 1){
|
||||||
|
@ -122,10 +129,6 @@ void loop() {
|
||||||
decreaseButtonLast = decreaseValue;
|
decreaseButtonLast = decreaseValue;
|
||||||
if (isScreenChanged)
|
if (isScreenChanged)
|
||||||
printOutput();
|
printOutput();
|
||||||
// Serial.println(analogRead(A1));
|
|
||||||
analogWrite(6, value);
|
|
||||||
value +=5;
|
|
||||||
delay(50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void switchMode () {
|
void switchMode () {
|
||||||
|
@ -146,10 +149,10 @@ void printOutput () {
|
||||||
switch (screen) {
|
switch (screen) {
|
||||||
case 0:
|
case 0:
|
||||||
lcd.print("Mode: ");
|
lcd.print("Mode: ");
|
||||||
lcd.print(mode? "rec." : "tra.");
|
lcd.print(mode? "receive" : "transmit");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
lcd.print("Addr.: ");
|
lcd.print("Address: ");
|
||||||
// lcd.print(address);
|
// lcd.print(address);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -157,7 +160,7 @@ void printOutput () {
|
||||||
lcd.print(key);
|
lcd.print(key);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
lcd.print("Enc.: ");
|
lcd.print("Encryption: ");
|
||||||
lcd.print(encryption? "yes" : "no");
|
lcd.print(encryption? "yes" : "no");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue