Robię swoją wersje mechaniki i elementów do druku (pokazywałem na czacie, właśnie się drukują)
Ale nie o tym tu, zaglądnąłem w kod który autor projektu popełnił w arduino (pod linkiem powyżej jest też coś na kształt "schematu", wrzucam tu poniżej, jak go otwarłem to o zgrozo stwierdziłem, że wszystko w języku francuskim jest, a ja "nichtfersztejen" w tym języku. Więc google translator do roboty i tłumaczenie na anglijskij (ale tu tez z gramatyka u mnie różnie bywa nawet bardzo różnie).
Załączam już wersję "przetłumaczoną" uległy zmianie nazwy zmiennych, funkcji, komentarze i wszystko inne co było po francusku.
Prosiłbym jakiegoś wymiatacza arduinowego coby się przyglądnął programowi jako takiemu a i uwagi do angielskiego również mile widziane.
Co program robić ma:
1 a więc jest antena z ruchomą tubą na cewce, która ta tuba ma "skracać cewkę w zależności od pasma.
2. konstrukcja mechaniczna i silniczek mają wyręczyć ręczne przesuwanie tej tuby
3. sterowanie jest poprzez potencjometr i do tego jest pilot irda którym można zapisać jakieś trzy akceptowane ustawienia aby potem je po prostu tylko wybierać.
Program się kompiluje bez problemu (pod arduino uno) z właściwą biblioteką "liquidcrystal"
schemat:
program główny:
Kod: Zaznacz cały
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Program by F4CEL //
//Original sources of the program: https://www.thingiverse.com/thing:1756493 //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Description: A small code that allows to automate tuning of the MP-1 antenna //
// //
//Translation and change of French names of variables, functions etc.: Wojtek (SP9AWP) with the help of google translator ;-) // //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <Wire.h>
#include <LiquidCrystal_I2C.h> // https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads/NewLiquidCrystal_1.5.1.zip
#include <IRremote.h>
#include <EEPROM.h>
#include <Stepper.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); //I2C address for LCD
const char IR_RECV_PIN=2;
IRrecv myIRedReceiver(IR_RECV_PIN);
decode_results results;
const int yellowLED = 13; //yellow LED
const int redLED = 12; //red LED
const int greenLED = 8; //green LED
int steps = 48 * 64; //number of steps
Stepper myStepperMotor(steps, 9, 11, 10, 6);
long pinPot = A0; //the middle pin of the potentiometer
long pinPotValue; //value on the middle pin of the potentiometer
int x;
int m; //variable "m", used to create a delay
int eeWrite; //eeWrite - Variable to store in EEPROM
int eeRead; //eeRead - Variable to store data read from EEPROM
int eeWrite1;
int eeRead1;
int eeWrite2;
int eeRead2;
int eeWrite3;
int eeRead3;
byte newChar1[8] = { B00001, B00011, B00111, B01111, B11111, B00011, B00011, B00011 }; //arrows up (left side)
byte newChar2[8] = { B10000, B11000, B11100, B11110, B11111, B11000, B11000, B11000 }; //arrows up (right side)
byte newChar3[8] = { B00011, B00011, B00011, B11111, B01111, B00111, B00011, B00001 }; //arrows down (left side)
byte newChar4[8] = { B11000, B11000, B11000, B11111, B11110, B11100, B11000, B10000 }; //arrows down (right side)
void setup() {
Serial.begin(9600); //serial port monitor (for information or debug)
lcd.begin(16, 2); //LCD - 16 characters, 2 rows
lcd.backlight(); //turn on the backlight
lcd.createChar(1, newChar1);
lcd.createChar(2, newChar2);
lcd.createChar(3, newChar3);
lcd.createChar(4, newChar4);
EEPROM.get(0, eeRead);
EEPROM.get(30, eeRead1);
EEPROM.get(60, eeRead2);
EEPROM.get(90, eeRead3);
Serial.print("Position of the antenna:");
Serial.print(" ");
Serial.println(eeRead);
Serial.print("Memory 1:");
Serial.print(" ");
Serial.println(eeRead1);
Serial.print("Memory 2:");
Serial.print(" ");
Serial.println(eeRead2);
Serial.print("Memory 3:");
Serial.print(" ");
Serial.println(eeRead3);
myIRedReceiver.enableIRIn();
pinMode(redLED, OUTPUT);
pinMode(yellowLED, OUTPUT);
pinMode(greenLED, OUTPUT);
myStepperMotor.setSpeed(9);
m = 101;
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" *** MP1 *** ");
delay(2000);
lcd.clear();
}
void info_from_memory(){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Memory[1]: ");
lcd.setCursor(12,0);
lcd.print(eeRead1);
delay(1500);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Memory[2]: ");
lcd.setCursor(12,0);
lcd.print(eeRead2);
delay(1500);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Memory[3]: ");
lcd.setCursor(12,0);
lcd.print(eeRead3);
delay(1500);
lcd.clear();
}
void infrared_remote_control(){
m++; //Incrementation of variable "m", used to create a delay
if (m < 100){ //If "m" is less than 100 then the red led flashes quickly, no automatic recording for a few seconds.
lcd.setCursor(0,0);
lcd.print("Position: ");
lcd.setCursor(10,0);
lcd.print(eeWrite); //antenna position
lcd.setCursor(0,1);
lcd.print(" Waiting ..");
digitalWrite(redLED, HIGH);
delay(100);
digitalWrite(redLED, LOW);
delay(100);
lcd.setCursor(13,1);
lcd.print(" ");
}
if (m > 100){ //If "m" is greater than 100 then it automatically records the position and the red led flashes slowly
lcd.setCursor(2,1);
lcd.print(" :");
lcd.setCursor(12,1);
lcd.print(" ");
lcd.setCursor(12,1);
lcd.print(eeWrite);
lcd.setCursor(0,0);
lcd.print(" Position ");
digitalWrite(redLED, HIGH);
delay(500);
digitalWrite(redLED, LOW);
delay(500);
if (m == 101){ //If the value of the variable "m" equals 101 then it records in the EEPROM
EEPROM.put(0, eeWrite);
}
m = 102; //a value of 102 is assigned to "m" to avoid rewriting in the EEPROM loop (NOTE, the maximum number of entries in the eeprom is 100,000)
}
if (myIRedReceiver.decode(&results)){
Serial.println(results.value, HEX); //To display the value of the remote control (hexadecimal) on the serial monitor
if (results.value == 0xFFE01F){ // Key (-)
while ((results.value != 0xFF906F) && (eeWrite > 0)){ //The motor runs as long as the (EQ) key is not used and the eeWrite variable is not greater than 0
lcd.setCursor(12,0);
lcd.print(" ");
lcd_screen(3,4,0,0,1,0,2,1,2,0,"Origin : ","Position: ",eeRead,eeWrite);
myIRedReceiver.decode(&results);
myIRedReceiver.resume();
green_motor();
}
}
if (results.value == 0xFFA857){ //Key (+)
while ((results.value != 0xFF906F)&&(eeWrite < 3900)){ //The engine runs as long as the (EQ) key is not used and the variable "eeWrite" is less than 3900
lcd.setCursor(12,0);
lcd.print(" ");
lcd_screen(1,2,0,0,1,0,2,1,2,0,"Origin : ","Position: ",eeRead,eeWrite);
myIRedReceiver.decode(&results);
myIRedReceiver.resume();
yellow_motor();
}
}
if (results.value == 0xFFC23D){ //Key (CH+)
myIRedReceiver.resume();
info_from_memory();
Serial.println("You have 3 seconds to select one of the 3 memories on the remote control ");
digitalWrite(redLED, HIGH);
delay(3000);
if (myIRedReceiver.decode(&results)){
if (results.value == 0xFF30CF){ //If button 1: the motor rotates to the position (memory 1)
myIRedReceiver.resume();
Serial.println("OK for Memory 1 ");
EEPROM.get(30, eeRead1);
Serial.println(eeRead1);
digitalWrite(yellowLED, HIGH);
digitalWrite(greenLED, HIGH);
delay(500);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
while (eeRead1 > eeWrite){
lcd.setCursor(2,1);
lcd.print(" ");
lcd_screen(1,2,0,1,1,1,0,0,4,1,"Memory[1]: ","",eeRead1,eeWrite);
yellow_motor();
}
while (eeRead1 < eeWrite){
lcd.setCursor(2,1);
lcd.print(" ");
lcd_screen(3,4,0,1,1,1,0,0,4,1,"Memory[1]: ","",eeRead1,eeWrite);
green_motor();
}
EEPROM.put(0, eeWrite);
for (int e = 0 ; e < 10 ; e++){
digitalWrite(redLED, HIGH);
delay(100);
digitalWrite(redLED, LOW);
delay(100);
}
}
if (results.value == 0xFF18E7){ //If button 2: the motor rotates to the position (memory 2)
myIRedReceiver.resume();
Serial.println("OK for Memory 2 ");
EEPROM.get(60, eeRead2);
Serial.println(eeRead2);
digitalWrite(yellowLED, HIGH);
digitalWrite(greenLED, HIGH);
delay(500);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
while (eeRead2 > eeWrite){
lcd.setCursor(2,1);
lcd.print(" ");
lcd_screen(1,2,0,1,1,1,0,0,4,1,"Memory[2]: ","",eeRead2,eeWrite);
yellow_motor();
}
while (eeRead2 < eeWrite){
lcd.setCursor(2,1);
lcd.print(" ");
lcd_screen(3,4,0,1,1,1,0,0,4,1,"Memory[2]: ","",eeRead2,eeWrite);
green_motor();
}
EEPROM.put(0, eeWrite);
for (int e = 0 ; e < 10 ; e++){
digitalWrite(redLED, HIGH);
delay(100);
digitalWrite(redLED, LOW);
delay(100);
}
}
if (results.value == 0xFF7A85){ //If button 3: the motor rotates to the position (memory 3)
myIRedReceiver.resume();
Serial.println("OK for Memory 3 ");
EEPROM.get(90, eeRead3);
Serial.println(eeRead3);
digitalWrite(yellowLED, HIGH);
digitalWrite(greenLED, HIGH);
delay(500);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
while (eeRead3 > eeWrite){
lcd.setCursor(2,1);
lcd.print(" ");
lcd_screen(1,2,0,1,1,1,0,0,4,1,"Memory[3]: ","",eeRead3,eeWrite);
yellow_motor();
}
while (eeRead3 < eeWrite){
lcd.setCursor(2,1);
lcd.print(" ");
lcd_screen(3,4,0,1,1,1,0,0,4,1,"Memory[3]: ","",eeRead3,eeWrite);
green_motor();
}
EEPROM.put(0, eeWrite); //eeWrite - write to the EEprom + blinking of the red led
for (int e = 0 ; e < 10 ; e++){
digitalWrite(redLED, HIGH);
delay(100);
digitalWrite(redLED, LOW);
delay(100);
}
}
}
}
}
if (myIRedReceiver.decode(&results)){
if (results.value == 0xFFE21D){ //If key (CH +): Save position
Serial.println("Saving the value");
digitalWrite(redLED, HIGH);
EEPROM.put(0, eeWrite);
delay(5);
Serial.println("You have 3 seconds to select on the remote one of the 3 memories .. ");
myIRedReceiver.resume();
delay(3000); //a delay of 3 seconds to select one of the 3 memories
if (myIRedReceiver.decode(&results)){
if (results.value == 0xFF30CF){ //If key (1): Save in memory number 1
recording(30,eeWrite1,"Recording in memory number 1: OK ");
}
if (results.value == 0xFF18E7){ //If key (2): Save in memory number 2
recording(60,eeWrite2,"Recording in memory number 2: OK ");
}
if (results.value == 0xFF7A85){ //If key (3): Save in memory number 3
recording(90,eeWrite3,"Recording in memory number 3: OK ");
}
}
}
}
if (myIRedReceiver.decode(&results)){
if (results.value == 0xFFA25D){ //If key (CH-): A delay of 3 seconds to select the Zero key (to reset the counter)
myIRedReceiver.resume();
Serial.println("To set the counter to zero, you have 3 seconds to press the 0 key ");
digitalWrite(redLED, HIGH);
delay(3000);
if (myIRedReceiver.decode(&results)){
if (results.value == 0xFF6897){ //reseting counter and record in memory
x=0;
eeWrite = 0;
EEPROM.put(0, eeWrite);
digitalWrite(redLED, LOW);
lcd.clear();
Serial.println("Compteur remis a ZERO ");
lcd.setCursor(0,0);
lcd.print("Compteur remis");
lcd.setCursor(3,1);
lcd.print("a ZERO..");
digitalWrite(yellowLED, HIGH);
delay(3000);
lcd.clear();
myIRedReceiver.resume();
digitalWrite(yellowLED, LOW);
delay(1);
}
}
}
}
}
void recording(int Val_eeprom1,int Val_eeprom2,String text){ //Function for saving memories 1, 2 and 3
Val_eeprom2 = eeWrite;
EEPROM.put(Val_eeprom1, Val_eeprom2);
Serial.println(text);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Recording");
lcd.setCursor(7,1);
lcd.print("OK");
digitalWrite(yellowLED, HIGH);
digitalWrite(greenLED, HIGH);
delay(3000);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
lcd.clear();
}
void lcd_screen (int byte1,int byte2,int s1,int s2,int s3,int s4,int s5,int s6,int s7,int s8,String memory,String text,int eeRead,int eeWrite){ //Function for the display on the LCD screen
// lcd.clear();
lcd.setCursor(s1,s2);
lcd.write(byte(byte1));
lcd.setCursor(s3,s4);
lcd.write(byte(byte2));
lcd.setCursor(s5,s6);
lcd.print(memory);
lcd.print(eeRead);
lcd.setCursor(s7,s8);
lcd.print(text);
lcd.print(eeWrite);
}
void green_motor(){ //Function for motor movement (green led) via remote control
digitalWrite(greenLED, HIGH);
myStepperMotor.step(100);
digitalWrite(greenLED, LOW);
x--;
eeWrite = (x + eeRead);
pinPotValue = analogRead(pinPot);
Serial.println(x);
delay(1);
m = 0;
}
void yellow_motor(){ //Function for motor movement (yellowled) via remote control
digitalWrite(yellowLED, HIGH);
myStepperMotor.step(-100);
digitalWrite(yellowLED, LOW);
x++;
eeWrite = (x + eeRead);
pinPotValue = analogRead(pinPot);
Serial.println(x);
delay(1);
m = 0;
}
void loop(){ //LOOP
eeWrite = (x + eeRead);
pinPotValue = analogRead(pinPot);
Serial.println(x);
delay(1);
while ((pinPotValue < 100) && (eeWrite > 0)){ //The motor runs as long as the value of the potentiometer is less than 100 and the variable "eeWrite" greater than 0
lcd.setCursor(11,0);
lcd.print(" ");
lcd_screen(3,4,0,0,1,0,2,1,2,0,"Origin : ","Position: ",eeRead,eeWrite);
green_motor();
}
while ((pinPotValue > 400) && (eeWrite < 3900)){ //the motor runs as long as the value of the potentiometer is greater than 400 and the variable "eeWrite" is less than 3900
lcd.setCursor(11,0);
lcd.print(" ");
lcd_screen(1,2,0,0,1,0,2,1,2,0,"Origin : ","Position: ",eeRead,eeWrite);
yellow_motor();
}
if ((pinPotValue < 400) && (pinPotValue > 100)){ //If the value of the potentiometer is between 100 and 400 then the use of the remote control is possible
infrared_remote_control();
}
myIRedReceiver.resume();
}
i program do testowania (tak autor podał):
Kod: Zaznacz cały
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Program by F4CEL //
//Original sources of the program: https://www.thingiverse.com/thing:1756493 //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Description: A small code that allows to automate tuning of the MP-1 antenna //
// //
//Translation and change of French names of variables, functions etc.: Wojtek (SP9AWP) with the help of google translator ;-) // //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <IRremote.h>
#include <EEPROM.h>
#include <Stepper.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); //I2C address for LCD);
const char IR_RECV_PIN = 2;
IRrecv myIRedReceiver(IR_RECV_PIN);
decode_results results;
const int yellowLED = 13; //yellow LED
const int redLED = 12; //red LED
const int greenLED = 8; //green LED
int steps = 48 * 64; //number of steps
Stepper myStepperMotor(steps, 9, 11, 10, 6);
long pinPot = A0; //the middle pin of the potentiometer
long pinPotValue; //value on the middle pin of the potentiometer
int x;
int m; //variable "m", used to create a delay
int eeWrite; //eeWrite - Variable to store in EEPROM
int eeRead; //eeRead - Variable to store data read from EEPROM
int eeWrite1;
int eeRead1;
int eeWrite2;
int eeRead2;
int eeWrite3;
int eeRead3;
byte newChar1[8] = { B00001, B00011, B00111, B01111, B11111, B00011, B00011, B00011 }; //arrows
byte newChar2[8] = { B10000, B11000, B11100, B11110, B11111, B11000, B11000, B11000 }; //arrows
byte newChar3[8] = { B00011, B00011, B00011, B11111, B01111, B00111, B00011, B00001 }; //arrows
byte newChar4[8] = { B11000, B11000, B11000, B11111, B11110, B11100, B11000, B10000 }; //arrows
void setup() {
Serial.begin(9600); //serial port monitor (for information or debug)
lcd.begin(16,2); //LCD - 16 characters, 2 rows
lcd.createChar(1, newChar1);
lcd.createChar(2, newChar2);
lcd.createChar(3, newChar3);
lcd.createChar(4, newChar4);
lcd.backlight(); //turn on the backlight
EEPROM.get(0, eeRead);
EEPROM.get(30, eeRead1);
EEPROM.get(60, eeRead2);
EEPROM.get(90, eeRead3);
Serial.print("Position of the antenna:");
Serial.print(" ");
Serial.println(eeRead);
Serial.print("Memory 1:");
Serial.print(" ");
Serial.println(eeRead1);
Serial.print("Memory 2:");
Serial.print(" ");
Serial.println(eeRead2);
Serial.print("Memory 3:");
Serial.print(" ");
Serial.println(eeRead3);
myIRedReceiver.enableIRIn();
pinMode(redLED, OUTPUT);
pinMode(yellowLED, OUTPUT);
pinMode(greenLED, OUTPUT);
myStepperMotor.setSpeed(9);
m = 101;
lcd.setCursor(6,1);
lcd.print("MP-1");
delay(3000);
}
void green_motor() //Function for motor movement (green led) via remote control
{
digitalWrite(greenLED, HIGH);
myStepperMotor.step(-100);
digitalWrite(greenLED, LOW);
x--;
eeWrite = (x + eeRead);
pinPotValue = analogRead(pinPot);
Serial.println(x);
delay(1);
m = 0;
}
void yellow_motor() //Function for motor movement (yellowled) via remote control
{
digitalWrite(yellowLED, HIGH);
myStepperMotor.step(100);
digitalWrite(yellowLED, LOW);
x++;
eeWrite = (x + eeRead);
pinPotValue = analogRead(pinPot);
Serial.println(x);
delay(1);
m = 0;
}
void loop() //_______________________________________________________________________
{
eeWrite = (x + eeRead);
pinPotValue = analogRead(pinPot);
Serial.println(x);
delay(1);
while ((pinPotValue < 100) && (eeWrite > 0)) //The motor runs as long as the value of the potentiometer is less than 100 and the variable "eeWrite" greater than 0
{
lcd.backlight();
lcd.clear();
lcd.setCursor(2,1);
lcd.write(byte(3));
lcd.setCursor(3,1);
lcd.write(byte(4));
lcd.setCursor(4,0);
lcd.print(eeWrite);
lcd.setCursor(4,1);
lcd.print(eeRead);
digitalWrite(greenLED, HIGH);
myStepperMotor.step(-100);
digitalWrite(greenLED, LOW);
x--;
eeWrite = (x + eeRead);
pinPotValue = analogRead(pinPot);
Serial.println(x);
delay(1);
m = 0;
}
while (pinPotValue > 400) // && (eeWrite < 1000))
{
lcd.backlight();
lcd.clear();
lcd.setCursor(2,0);
lcd.write(byte(1));
lcd.setCursor(3,0);
lcd.write(byte(2));
lcd.setCursor(5,1);
lcd.print(eeWrite);
lcd.setCursor(5,0);
lcd.print(eeRead);
digitalWrite(yellowLED, HIGH);
myStepperMotor.step(100);
digitalWrite(yellowLED, LOW);
x++;
eeWrite = (x + eeRead);
pinPotValue = analogRead(pinPot);
Serial.println(x);
delay(1);
m = 0;
}
if ((pinPotValue < 400) && (pinPotValue > 100)) //If the value of the potentiometer is between 100 and 400 then the use of the remote control is possible
{
m++; //Incrementation of variable "m", used to create a delay
if (m < 100) //If "m" is less than 100 then the red led flashes quickly, no automatic recording for a few seconds.
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Ant: ");
lcd.print(eeWrite); //antenna position
lcd.setCursor(3,1);
lcd.print("Waiting ... ");
digitalWrite(redLED, HIGH);
delay(100);
digitalWrite(redLED, LOW);
delay(100);
}
if (m > 100) //If "m" is greater than 100 then it automatically records the position and the red led flashes slowly
{
lcd.clear();
lcd.setCursor(6,0);
lcd.print(eeWrite);
lcd.setCursor(3,1);
lcd.print("***MP-1***");
digitalWrite(redLED, HIGH);
delay(500);
digitalWrite(redLED, LOW);
delay(500);
if (m == 101) //If the value of the variable "m" equals 101 then it records in the EEPROM
{
EEPROM.put(0, eeWrite);
}
m = 102; //a value of 102 is assigned to "m" to avoid rewriting in the EEPROM loop (NOTE, the maximum number of entries in the eeprom is 100,000)
}
if (myIRedReceiver.decode(&results))
{
Serial.println(results.value, HEX); //To display the value of the remote control (hexadecimal) on the serial monitor
lcd.backlight();
if (results.value == 0xFFE01F) // Key (-)
{
while ((results.value != 0xFF906F) && (eeWrite > 0)) //The motor runs as long as the (EQ) key is not used and the eeWrite variable is not greater than 0
{
lcd.clear();
lcd.setCursor(2,1);
lcd.write(byte(3));
lcd.setCursor(3,1);
lcd.write(byte(4));
lcd.setCursor(4,0);
lcd.print(eeWrite);
lcd.setCursor(4,1);
lcd.print(eeRead);
myIRedReceiver.decode(&results);
myIRedReceiver.resume();
green_motor();
}
}
if (results.value == 0xFFA857) //Key (+)
{
while (results.value != 0xFF906F)
{
lcd.clear();
lcd.setCursor(2,0);
lcd.write(byte(1));
lcd.setCursor(3,0);
lcd.write(byte(2));
lcd.setCursor(5,1);
lcd.print(eeWrite);
lcd.setCursor(5,0);
lcd.print(eeRead);
myIRedReceiver.decode(&results);
myIRedReceiver.resume();
yellow_motor();
}
}
if (results.value == 0xFFC23D)//Key (CH+)
{
myIRedReceiver.resume();
Serial.println("You have 3 seconds to select one of the 3 memories on the remote control");
digitalWrite(redLED, HIGH);
delay(3000);
if (myIRedReceiver.decode(&results))
{
if (results.value == 0xFF30CF)
{
myIRedReceiver.resume();
Serial.println("OK for Memory 1 ");
EEPROM.get(30, eeRead1);
Serial.println(eeRead1);
digitalWrite(yellowLED, HIGH);
digitalWrite(greenLED, HIGH);
delay(500);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
while (eeRead1 > eeWrite)
{
lcd.clear();
lcd.setCursor(2,0);
lcd.write(byte(1));
lcd.setCursor(3,0);
lcd.write(byte(2));
lcd.setCursor(4,0);
lcd.print("M1:");
lcd.print(eeRead1);
lcd.setCursor(4,1);
lcd.print(eeWrite);
yellow_motor();
}
while (eeRead1 < eeWrite)
{
lcd.clear();
lcd.setCursor(2,1);
lcd.write(byte(3));
lcd.setCursor(3,1);
lcd.write(byte(4));
lcd.setCursor(4,0);
lcd.print("M1:");
lcd.print(eeRead1);
lcd.setCursor(4,1);
lcd.print(eeWrite);
green_motor();
}
EEPROM.put(0, eeWrite);
for (int e = 0 ; e < 10 ; e++)
{
digitalWrite(redLED, HIGH);
delay(100);
digitalWrite(redLED, LOW);
delay(100);
}
}
if (results.value == 0xFF18E7) //If button 2: the motor rotates to the position (memory 2)
{
myIRedReceiver.resume();
Serial.println("OK for Memory 2 ");
EEPROM.get(60, eeRead2);
Serial.println(eeRead2);
digitalWrite(yellowLED, HIGH);
digitalWrite(greenLED, HIGH);
delay(500);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
while (eeRead2 > eeWrite)
{
lcd.clear();
lcd.setCursor(2,0);
lcd.write(byte(1));
lcd.setCursor(3,0);
lcd.write(byte(2));
lcd.setCursor(4,0);
lcd.print("M2:");
lcd.print(eeRead2);
lcd.setCursor(4,1);
lcd.print(eeWrite);
yellow_motor();
}
while (eeRead2 < eeWrite)
{
lcd.clear();
lcd.setCursor(2,1);
lcd.write(byte(3));
lcd.setCursor(3,1);
lcd.write(byte(4));
lcd.setCursor(4,0);
lcd.print("M2:");
lcd.print(eeRead2);
lcd.setCursor(4,1);
lcd.print(eeWrite);
green_motor();
}
EEPROM.put(0, eeWrite);
for (int e = 0 ; e < 10 ; e++)
{
digitalWrite(redLED, HIGH);
delay(100);
digitalWrite(redLED, LOW);
delay(100);
}
}
if (results.value == 0xFF7A85) //If button 3: the motor rotates to the position (memory 3)
{
myIRedReceiver.resume();
Serial.println("OK for Memory 3 ");
EEPROM.get(90, eeRead3);
Serial.println(eeRead3);
digitalWrite(yellowLED, HIGH);
digitalWrite(greenLED, HIGH);
delay(500);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
while (eeRead3 > eeWrite)
{
lcd.clear();
lcd.setCursor(2,0);
lcd.write(byte(1));
lcd.setCursor(3,0);
lcd.write(byte(2));
lcd.setCursor(4,0);
lcd.print("M3:");
lcd.print(eeRead3);
lcd.setCursor(4,1);
lcd.print(eeWrite);
yellow_motor();
}
while (eeRead3 < eeWrite)
{
lcd.clear();
lcd.setCursor(2,1);
lcd.write(byte(3));
lcd.setCursor(3,1);
lcd.write(byte(4));
lcd.setCursor(4,0);
lcd.print("M3:");
lcd.print(eeRead3);
lcd.setCursor(4,1);
lcd.print(eeWrite);
green_motor();
}
EEPROM.put(0, eeWrite); //eeWrite - write to the EEprom + blinking of the red led
for (int e = 0 ; e < 10 ; e++)
{
digitalWrite(redLED, HIGH);
delay(100);
digitalWrite(redLED, LOW);
delay(100);
}
}
}
}
}
if (myIRedReceiver.decode(&results))
{
if (results.value == 0xFFE21D)//If key (CH +): Save position
{
Serial.println("Saving the value");
digitalWrite(redLED, HIGH);
EEPROM.put(0, eeWrite);
delay(5);
Serial.println("You have 3 seconds to select on the remote one of the 3 memories .. ");
myIRedReceiver.resume();
delay(3000); //a delay of 3 seconds to select one of the 3 memories
if (myIRedReceiver.decode(&results))
{
if (results.value == 0xFF30CF) //If key (1): Save in memory number 1
{
eeWrite1 = eeWrite;
EEPROM.put(30, eeWrite1);
Serial.println("Recording in memory number 1: OK ");
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Recording");
lcd.setCursor(7,1);
lcd.print("OK");
digitalWrite(yellowLED, HIGH);
digitalWrite(greenLED, HIGH);
delay(3000);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
}
if (results.value == 0xFF18E7) //If key (2): Save in memory number 2
{
eeWrite2 = eeWrite;
EEPROM.put(60, eeWrite2);
Serial.println("Recording in memory number 2: OK ");
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Recording");
lcd.setCursor(7,1);
lcd.print("OK");
digitalWrite(yellowLED, HIGH);
digitalWrite(greenLED, HIGH);
delay(3000);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
}
if (results.value == 0xFF7A85) //If key (3): Save in memory number 3
{
eeWrite3 = eeWrite;
EEPROM.put(90, eeWrite3);
Serial.println("Recording in memory number 3: OK ");
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Recording");
lcd.setCursor(7,1);
lcd.print("OK");
digitalWrite(yellowLED, HIGH);
digitalWrite(greenLED, HIGH);
delay(3000);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
}
}
}
}
if (myIRedReceiver.decode(&results))
{
if (results.value == 0xFFA25D) //If key (CH-): A delay of 3 seconds to select the Zero key (to reset the counter)
{
myIRedReceiver.resume();
Serial.println("To set the counter to zero, you have 3 seconds to press the 0 key ");
digitalWrite(redLED, HIGH);
delay(3000);
if (myIRedReceiver.decode(&results))
{
if (results.value == 0xFF6897) //reseting counter and record in memory
{
eeWrite = 0;
EEPROM.put(0, eeWrite);
digitalWrite(redLED, LOW);
Serial.println("Compteur remis a ZERO ");
lcd.setCursor(0,0);
lcd.print("Compteur remis");
lcd.setCursor(3,1);
lcd.print("a ZERO..");
digitalWrite(yellowLED, HIGH);
delay(3000);
myIRedReceiver.resume();
digitalWrite(yellowLED, LOW);
delay(1);
}
}
}
}
}
myIRedReceiver.resume();
}