Recent Posts

Pages: [1] 2 3 ... 10
1
So, what do you think happens when the MySQL_Connection instance uses the espClient instance to talk to the database? What is the PubSubClient instance supposed to do with that information? And, what is the MySQL_Connection instance supposed to do with the PubSubClient communications?
My understanding is, that WiFiClient espClient; initiates the WiFi connection and then both the SQL-client as well as MQTT use the WiFi connection.
2
Project Guidance / Re: transmit audio and data wi...
Last post by ag0stin0 - Today at 08:35 am
You could try setting up a timer on an interrupt that reads A5 and reacts to it. 
Hello blh64
thank you for hint.
Can you explain more about it?
3
General Electronics / Re: How to modify the voltage ...
Last post by Wawa - Today at 08:35 am
Counting the cells (0.5volt each) might give you a better idea about MPP voltage.

You must use a diode to stop current flowing from the batteries back into the solar panel when it's dark.
That could be a schottky (with a ~0.4volt drop).

You can't use voltage regulation (load dump) on the battery side, but you can on the solar panel side.
That could be a "super zener", made with a zener diode and a TO-220 transistor.
Leo..
4
Programming Questions / Re: Merging examples question
Last post by Robin2 - Today at 08:33 am
When your program is too long just post the .ino file as an attachment.

I can't help with your NRFlite library but the examples in this Simple nRF24L01+ Tutorial do work. They use the TMRh20 RF24 library.

Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.

...R
5
Project Guidance / Code not working right
Last post by Luke21206 - Today at 08:32 am
 I am a newbie so sorry if this is easy or my thing is unnecessarily long. I have made a simple calculator but whenever I try to make it print the answer, it is all weird and messed up.
Code: [Select]
#include <LiquidCrystal.h>
#include <Keypad.h>
int opt1 = '+';
int opt2 = '+';
int find = 0;
int answer = 0;
int answerprint = 0;

char num[3];

int clear = 0;
int currentlength = 0;
int optlength = 0;
byte divide [8]={
  0b00100,
  0b00100,
  0b00000,
  0b11111,
  0b11111,
  0b00000,
  0b00100,
  0b00100,
};
const byte ROWS = 4;
const byte COLS = 4;

char Keys[ROWS][COLS] = {
  {'1', '2', '3', '+'},
  {'4', '5', '6', '-'},
  {'7', '8', '9', 'x'},
  {'*', '0', '=', 1}
};

byte rowPins[ROWS] = {5, A5, A4, A2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {A1, A0, A3, A6};

Keypad keypad = Keypad(makeKeymap(Keys), rowPins, colPins, ROWS, COLS);


LiquidCrystal lcd(7,9,10,11,12,13); // the pins we use on the LCD
int P = 8;


void setup() {
digitalWrite(6, HIGH);
  pinMode(6, OUTPUT);
lcd.createChar(1, divide);
lcd.begin(16, 2);
lcd.print("Type an equation");
lcd.setCursor(0,1);
lcd.cursor();
  while(find==0){
 
  while((optlength == 0)&&(currentlength == 0)&&(find == 0)){
  char key = keypad.getKey();
 
    key == NO_KEY;
   
    if (key != NO_KEY){
      if ((key != '+')&&(key != '-')&&(key != 'x')&&(key != 1)&&(key != '=')){
     
      if(key == '*'){
        digitalWrite(6, LOW);
       
      }
       
      if (key != '*'){
      lcd.print(key);
      num[0] = key;
      currentlength++;   
      }

  }
    }
    }
  while((currentlength == 1)&&(optlength == 0)&&(find == 0)){
  char optkey = keypad.getKey();
  optkey == NO_KEY;
   if ((optkey != NO_KEY)&&(optlength == 0)&&(currentlength == 1)){
     if ((optkey == '+')||(optkey == '-')||(optkey == 'x')||
     (optkey == 1)||(optkey == '=')||(optkey == '*')){
       
       if(optkey == '*'){
       digitalWrite(6, LOW);
       }
       if(optkey == '='){
        lcd.print(optkey);
       
        find++;
       }
       
       if((optkey != '=')&&(optkey != '*')){
       lcd.print(optkey);
       opt1 = optkey;
       optlength++;
       }
     }
     }
  }
 
while((currentlength==1)&&(optlength==1)&&(find == 0)){
  char key2 = keypad.getKey();
 
    key2 == NO_KEY;
   
    if ((key2 != NO_KEY)&&(currentlength == 1)){
      if ((key2 != '+')&&(key2 != '-')&&(key2 != 'x')&&(key2 != 1)&&(key2 != '='))
      {
        if (key2 == '*'){
          digitalWrite(6, LOW);
        }
      if (key2 != '*'){
      lcd.print(key2);
      num[1] = key2;
      currentlength++;   
      }

  }
    }
    }
while((currentlength == 2)&&(optlength == 1)&&(find == 0)){
  char optkey2 = keypad.getKey();
  optkey2 == NO_KEY;
   if ((optkey2 != NO_KEY)&&(optlength == 1)&&(currentlength == 2)){
     if ((optkey2 == '+')||(optkey2 == '-')||(optkey2 == 'x')||(optkey2 == 1)||
     (optkey2 == '*')||(optkey2 == '=')){
    if(optkey2 == '*'){
       digitalWrite(6, LOW);
       }
       if(optkey2 == '='){
        lcd.print(optkey2);
        find++;
       }
       
       if((optkey2 != '=')&&(optkey2 != '*')){
       lcd.print(optkey2);
       opt2 = optkey2;
       optlength++;
       }
     }
     }
  }
    while((currentlength==2)&&(optlength==2)&&(find == 0)){
  char key3 = keypad.getKey();
 
    key3 == NO_KEY;
   
    if ((key3 != NO_KEY)&&(currentlength == 2)){
      if ((key3 != '+')&&(key3 != '-')&&(key3 != 'x')&&(key3 != 1)&&(key3 != '=')){
      if (key3 == '*'){
      digitalWrite(6, LOW);
      }
      if (key3 != '*'){
      lcd.print(key3);
      num[2] = key3;
      currentlength++;   
      }

  }
    }
    }
   
    while((currentlength==3)&&(optlength==2)&&(find == 0)){
      char findkey = keypad.getKey();
 
    findkey == NO_KEY;
   
    if(findkey != NO_KEY){
      if((findkey == '=')||(findkey == '*')){
        if (findkey == '*'){
          digitalWrite(6, LOW);
        }
        if(findkey == '='){
          lcd.print("=");
          find++;
        }
      }
    }
    }
     
    }
}


void loop(){
 if(answerprint == 0){
   
   if(opt1 == '+'){
     answer = num[0] + num[1];
   }
      if(opt1 == '-'){
     answer = num[0] - num[1];
   }
      if(opt1 == 'x'){
     answer = num[0] * num[1];
   }
      if(opt1 == 1){
     answer = num[0] / num[1];
   }
   
   if (opt2 == '+'){
     answer = answer + num[2];
     lcd.print(answer);
     answerprint++;
   }
   if (opt2 == '-'){
     answer = answer - num[2];
     lcd.print(answer);
     answerprint++;
   }
   if (opt2 == 'x'){
     answer = answer * num[2];
     lcd.print(answer);
     answerprint++;
   }
   if (opt2 == 1){
     answer = answer / num[2];
     lcd.print(answer);
     answerprint++;
   }
 }


while(answerprint == 1){
  char endkey = keypad.getKey();
 
    endkey == NO_KEY;
   
    if(endkey != NO_KEY){
      if (endkey == '*'){
        digitalWrite(6, LOW);
      }
     
}
}
}

If anyone has any idea as to why this occurs, help is very much appreciated!
6
if  the  Waveshare GSM/GPRS/GPS Shield is transmitting at 115200baud a receiver at 4800 will probably not display anything (you may get garbage displayed)
I suggest using a Mega with hardware ports at 115200baud
7
Programming Questions / Re: Sending volts
Last post by Robin2 - Today at 08:30 am
@smalloytn, please don't post double-spaced text. It is much harder to read. Just use extra space between paragraphs.

...R
8
Project Guidance / NEED HALP! COUNTDOWN TIMER
Last post by Afandizzat - Today at 08:29 am
Greetings,

I'm a beginner in arduino, I got this coding off the internet on how to  make a countdowntimer ;

Components used:
16x2 LCD
4x4keypad
potentiometer
push button
2 220ohm resistor
1 10kohm resistor
1 LED
1 Buzzer


it says theres an error on
void setFeedingTime() in r=key-48;
I tried erasing that line and i++; j++;

then I tried running the code, the display is as I wanted but when i input the value on LCD it doesnt count down but it says "Countdown begins" and redisplay "HH:MM:SS"



I will really appreciate any sort of explanation and help

All credits to the original coder: https://circuitdigest.com/microcontroller-projects/arduino-countdown-timer.

#include <LiquidCrystal.h>
#include <Keypad.h>

const byte ROWS = 4; // Four rows
const byte COLS = 4; // Three columns

long int set1;
long int set2;
long int set3;
long int set4;
long int j;

String hours;
String minutes;
String seconds;
// Define the Keymap

char keys[ROWS][COLS] = {

  {'1','2','3','A'},

  {'4','5','6','B'},

  {'7','8','9','C'},

  {'*','0','#','D'}

};

byte rowPins[ROWS] = { 6, 7, 8, 9 };// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins
byte colPins[COLS] = { 10, 11, 12, 13 };// Connect keypad COL0, COL1 and COL2 to t

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

LiquidCrystal lcd(A0, A1, 5, 4, 3, 2); // Creates an LC object. Parameters: (rs, enable, d4, d5, d6, d7)

 int t1, t2, t3, t4, t5, t6;
 int r1, r2, r3;
 
boolean feed = true; // condition for alarm

 char key;
 String r[8];

 void setFeedingTime()
{
  feed = true;
   int i=0;

  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Set feeding Time");
  lcd.clear();
  lcd.print("HH:MM:SS");
  lcd.setCursor(0,1);

 
  while(1){
    key = kpd.getKey();

    char j;
   
  if(key!=NO_KEY){
   
    lcd.setCursor(j,1);
   
    lcd.print(key);
   
    r = key-48;
    i++;
    j++;

    if (j==2 || j == 5)
    {
      lcd.print(":"); j++;
    }
    delay(500);
  }

  if (key == 'D')
  {key=0; break; }
  }
 lcd.clear();
}
 
 void setup()
 {
  lcd.begin(16,2);
  Serial.begin(9600);
  pinMode(A0, OUTPUT);
  pinMode(A1, OUTPUT);
  pinMode(A3, INPUT);
  pinMode(A4, OUTPUT);
 }
 
 void loop()
 {
      lcd.setCursor(0,0);
      lcd.print("Arduino Timer");
      //Serial.println(A3);

      if (digitalRead(A3)==1) //
      {
      lcd.clear();
      setFeedingTime();
      for(int i = 0; i < 6; i++)  // this for loop is used to get the value of the feeding time and print it serially
      {
       Serial.print(r);
       Serial.println();
      }
     
   hours = String (r[0]) + String (r[1]) ; //combining two separate int values of r[0] and r[1] into one string and save it to "hours"
   minutes = String (r[2]) + String (r[3]) ;  //combining two separate int values of r[2] and r[3] into one string and save it to "minutes"
   seconds = String (r[4]) + String (r[5]) ;  //combining two separate int values of r[4] and r[5] into one string and save it to "seconds"

 
  set1 = (hours.toInt()*3600); //converting hours into seconds
  set2 = (minutes.toInt() * 60);  //converting minutes into seconds
  set3 = seconds.toInt();
  set4 = (hours.toInt() * 3600)+ (minutes.toInt() * 60) + seconds.toInt(); //adding set1, set2 and set3 together in set4
  Serial.print("set4");
  Serial.print(set4);
  Serial.println();

  lcd.setCursor(0,0);
  lcd.print("Countdown begins");
  delay(1000);
  lcd.clear();
 
  for(long int j = set4; j >= 0; j--) // this for loopis used to decrease the total time in seconds
  {
  Serial.println(j);
 
  lcd.setCursor(0,0);
  lcd.print("HH:MM:SS");
 
  long int HH = j / 3600; // converting the remaining time into remaining hours
  lcd.setCursor(0,1);
  Serial.println(HH);
  if (HH < 10) { lcd.print('0');  }
  lcd.print(HH);
  lcd.print(":");
 
  long int MM = (j - (HH*3600))/60 ; //converting the remaining time into remaining minutes
  lcd.setCursor(3,1);
  Serial.println(MM);
  if (MM < 10) { lcd.print('0');  }
  lcd.print(MM);
  lcd.print(":");
 
  long int SS = j - ((HH*3600)+(MM*60)); //converting the remaining time into remaining seconds
  lcd.setCursor(6,1);
  Serial.println(SS);
  if (SS < 10) { lcd.print('0');  }
  lcd.print(SS);
  delay(1000);

  if (digitalRead(A3)==1){break;}

   if (j == 0)
   
    {
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Timer Stop");
      lcd.setCursor(2,1);
      lcd.print("-Ring-Ring-");
     
    for(int k =0; k<= 100; k++) //this for loop is used for the buzzer to beep 100 time as the timer reaches zero
      {
        digitalWrite(A4,HIGH);
        delay(300);
        digitalWrite(A4,LOW); 
        delay(300);
        if (digitalRead(A3)==1){break;} 
      }
    }
   }
  }
}       


On another post someone told me to avoid using strings, is there any other way around it?
9
Programming Questions / Re: Need Help on Programming
Last post by Robin2 - Today at 08:28 am
To make it easy for people to help you please modify your post and use the code button </>
Code: [Select]
so your code looks like this and is easy to copy to a text editor. See How to use the Forum

Your code is too long for me to study quickly without copying to a text editor.

Also use the AutoFormat tool to indent your code for easier reading.

...R
10
Español / Re: delay 7 dias es posible?
Last post by RIG - Today at 08:27 am
Hola Bienvenido
En cuanto a tu pregunta si se puede agregar un delay de 7 dias, la respuesta es claro que se puede, incluso muchos mas
Quote
¿habrá algún inconveniente con eso?
Que bueno que hiciste esta pregunta porque tienes un gran problema si usas un delay tan grande, esto es que durante 7 días tu arduino no hará nada de nada, solo esperar a que transcurra ese tiempo, dicho en otras palabras: estará bloqueado durante 7 días

Quote
en el caso que se pierda la electricidad en el sexto
       día, ¿en vez de reiniciarse es posible que continué del día que se perdió la electricidad?
De la forma que lo planteas, con el uso de delay no es posible.


En tu caso creo que lo mas recomendable sera que uses un RTC, mira estos videos:

Como se usa un RTC

Como automatizar

Tambien te recomiendo que le heches un ojo a la funcion millis() Aqui puedes descargar un pdf que explica muy bien esta funcion   para que aprendas a evitar en lo posible el uso del delay
Pages: [1] 2 3 ... 10