texts:
I'm getting this error while compiling the code for my mp3 shield.

    C:\Users\Kami\Documents\Arduino\libraries\MP3Shield_Library_Demo\SFEMP3Shield.cpp:9:9: error: 'prog_uint16_t' does not name a type

 PROGMEM prog_uint16_t bitrate_table[14][6] = { {0,0,0,0,0,0},

         ^

C:\Users\Kami\Documents\Arduino\libraries\MP3Shield_Library_Demo\SFEMP3Shield.cpp: In member function 'uint8_t SFEMP3Shield::begin()':

C:\Users\Kami\Documents\Arduino\libraries\MP3Shield_Library_Demo\SFEMP3Shield.cpp:43:8: error: 'volume' was not declared in this scope

   if (!volume.init(&card)) return 2; //Serial.println("Error: Volume ini");

        ^

C:\Users\Kami\Documents\Arduino\libraries\MP3Shield_Library_Demo\SFEMP3Shield.cpp:45:23: error: 'volume' was not declared in this scope

   if (!root.openRoot(&volume)) return 3; //Serial.println("Error: Opening root"); //Open the root directory in the volume.

                       ^

exit status 1
Error compiling for board Arduino/Genuino Uno.


texts:
I have a sketch that uses two timers using millis() from a library I created to keep time. The timers seem to be working correctly, but when I print the start time of each timer, it is clearly wrong.

E.g. the timer is set to run for 3 seconds. When I start the timer the first time, it reads that it started at 0. The next time I start the timer, right after it has finished running once, it reads that it started at 2 seconds. This should not be possible.

I have even tried timing it on my phone, and have seen the timerStart value read 5 seconds, when the sketch has been running for 10.

Does anyone have any idea what could be going wrong? Code below.

Here is the library's .h file:

#ifndef Timer_h
#define Timer_h

#include <Arduino.h>

class Timer {
  public:
    Timer(unsigned long timerLength);
    unsigned long timerStart;
    unsigned long timeElapsed;
    boolean isFinished = true;
    boolean timerStarted = false;
    void startTimer();
    void checkTimer();
  private:
    unsigned long _timerLength;
};

#endif

Here is the library's .cpp file:

#include <Arduino.h>
#include <Timer.h>

Timer::Timer(unsigned long timerLength) {
  _timerLength = timerLength;
}

void Timer::startTimer() {
  if (!timerStarted) {
    timerStart = millis();
    timerStarted = true;
  }
}

void Timer::checkTimer() {
  timeElapsed = millis() - timerStart;
  if (timeElapsed >= _timerLength) {
    isFinished = true;
    timerStarted = false;
  } else {
    isFinished = false;
  }
}

And here is part of my sketch code, where the timerStart value is wrong:

#include <Timer.h>

Timer breathTimer(3000);
Timer betweenTimer(1000);

// this part determines if a turbine is spinning or not
SIGNAL(TIMER0_COMPA_vect) {
  uint8_t x = digitalRead(FLOWSENSORPIN);

  //if the turbine is spinning
  if (x == HIGH) {

    //start the breath timer
    if (betweenTimer.isFinished) {
      if (breathTimer.isFinished) {
        Serial.print("Breath Timer Started @ ");
        Serial.println(breathTimer.timerStart);
      }
      breathTimer.startTimer();
    }
  }
}

void setup() {
   Serial.begin(9600);
   pinMode(FLOWSENSORPIN, INPUT);
   digitalWrite(FLOWSENSORPIN, HIGH);
   betweenTimer.isFinished = true;
}

void loop() {

  // check the breath timer
  if (breathTimer.timerStarted) {
    breathTimer.checkTimer();
    if (breathTimer.isFinished) {
      Serial.println("Breath Timer is Finished");
      betweenTimer.startTimer();
      Serial.println("Between Timer Started");
    }
  }

  if (betweenTimer.timerStarted) {
    betweenTimer.checkTimer();
    if (betweenTimer.isFinished) {
      Serial.println("Between Timer is Finished");
    }
  }
}


texts:
Using STM32Duino on Nucleo F429ZI:

#include <LwIP.h>
#include <STM32Ethernet.h>
#define UDP_TX_PACKET_MAX_SIZE 512
#include <EthernetUdp.h>

IPAddress remoteIP;
unsigned int remotePort;

EthernetUDP Udp;
uint8_t packetBuffer[UDP_TX_PACKET_MAX_SIZE];

void setup()
{
  Serial.begin(115200);
  IPAddress localIP = /***/;
  IPAddress netmask = /***/;
  IPAddress dns = /***/;
  IPAddress gateway = /***/;

  Ethernet.begin(localIP, netmask, dns, gateway);
  uint8_t *mac = Ethernet.macAddress();

  int port = 8888;
  Udp.begin(port);
}

void loop()
{
  processUDPMessage();
}

void processUDPMessage(void)
{
  while (int size = Udp.parsePacket())
  {
    if (size > 0) parsePacket(size);
  }
}

void parsePacket(int size)
{
  remoteIP = Udp.remoteIP();
  remotePort = Udp.remotePort();

  Udp.read(packetBuffer, size);
  Serial.println((char *) packetBuffer);
}

If I received at least 4 packets at the same time, one of them is not received. Each packet is less than 50 byte long.

Is there anything I could do to improve the reliability of my code?


texts:
I am looking for ideas on how to connect 12 sensors to an Arduino wirelessly.  The sensors will be about 10ft from the Arduino.  They need to send one byte of data every 100ms-250ms to the Arduino in an organized manner.

I have investigated MQTT and pubsubclient, but have not found a way to make an Arduino a Broker, and have been told it is very inefficient for my application.
I have looked at NRF24L01, but it appears to be limited to just 6 pipes to receive data in an organized fashion.
I researched Xbee, but have been told that it cannot keep up with the data rate.

Other suggestions are appreciated...  Thank you.


texts: Underwater positioning system (swimming pool)

texts:
I'm making a few experiments with a quite simple rover car I made using Arduino UNO and a few spare parts. Just for the heck of it I made it waterproof and now I want to toss it in my pool to make some underwater exploration. Maybe I'll fit some scrubers under it to make it easer to clean the floor.

My problem is: my rover navigates on its own, avoiding walls and objects using an ultrasonic sensor. But underwater the speed of sound goes up, and different qualities of water make it even harder for this system to work. Sometimes the pool is full of particles, and the scruber will probably worse the water quality around the robot.

My question is: what kind of system is better to navigate underwater, simply avoiding walls? The current behavor (on dry ground) is to turn to the right and go on when it finds a wall, I would like to keep this behavior, but underwater. As it's a simple toy, I'm hardly willing to spend a hundred bucks on a fancy laser proximity sensor, neither I need to map the entire pool with a single pulse, it should be a simple wall avoiding system.

Thank you!


texts: Problem with interpretting and using the IMU data

texts:
I am using MPU6050 IMU for getting accelerometer and gyro data. I could read the data using the code from the I2Cdev library here, but the problem I have is that I can't use this data in a meaningful manner. As an example I want to define the motion of an object in x,y,z axis using accelerometer data. Although I get a set of values, I can't understand how to use it.

If I could convert these values to ms-2 units, I hope I would be able to achieve this

Could you provide me some advice, code or reference to work on this?

I also tried the code here to get the raw values.


texts: How to fade in and fade out led strip connected to arduino based on continous analog input from capacitative sensor?

texts:
So I've been trying to get a capacitive sensor made from aluminum foil to work. And I have had success the kind of proximity and readings I need to light up a single LED and produce basic tone. Using this very basic code :

{
  Serial.println(value1);//value that i get from analog sensor
  //this is just to get the values in order for the led and sound
  if (value1<=8) value1=-100;
  analogWrite(ledPin,value1+100);//these weird calculations seem to work for me
  tone(tonepin,value1+100,100);
  delay(10);

All this works perfectly for me, the delay isn't perceivable, the response is for all practical purposes simultaneous to input. Except it's not beautiful, because the LED keeps flickering when values reduce or increase because the jumps are sudden I suppose.

SO I thought I'll try to fade in and fade out to different values from present values.  Used the fading examples. Here:

Serial.println(value1);
  if (value1<=8) value1=-100;

  if (value1+100<=value2+100) {
    for(int fadeValue = value2+100 ; fadeValue <= value1+100; fadeValue +=5) {

    analogWrite(ledPin, fadeValue);

    delay(10);
    }
  }

  else
  {

    for(int fadeValue = value2+100 ; fadeValue >= value1+100; fadeValue -=5)
    {
        analogWrite(ledPin, fadeValue);

    delay(10);
    }
  }
  //analogWrite(ledPin,value1+100);
  tone(tonepin,value1+100,100);
  delay(10);
  value2=value1;

But this takes away the responsiveness, the whole thing is so slow to react, the sound and the light are obviously not in sync as I read my code. But also the light is not really fading, still blinking, but there seems to be some effect but I am not sure.

Any help with what I could do and what I am doing wrong would be nice.


texts: VirtualWire `vw_get_message`: docs and examples on the PJRC site

texts:
I'm looking at he following page, that describes functions from VirtualWire library and provides some examples.

https://www.pjrc.com/teensy/td_libs_VirtualWire.html

Some basic questions I have after reading it:

The description of vw_get_message function states.

  Read the last received message. This should be called only when a message is known to be received with any of the 3 functions above.

"3 functions above" refers to vw_have_message, vw_wait_rx and vw_wait_rx_max functions.

However, in the example on that very same page vw_get_message function is called from receiver's loop() without making any attempts to call any of those 3 functions first.

Why? Is it legal to use vw_get_message by itself? And how does it work in this case, i.e. what is the semantics of the return value?

The function is explicitly described as non-blocking, apparently implying that if this usage is legal, there's no way to tell "corrupted message" situation from "no message" situation.
Does the library preserve the granularity/separation of messages? I.e if the TX side sends 1-byte messages, does it guarantee that each call to vw_get_message on RX side will return 1-byte messages? It seems to be implied by the description of the protocol, but I'd like to ask just in case.
If the answer to the second question is "yes", then does this API preserve zero-length messages? Or are they discarded immediately?


texts:
To the best of my understanding, when I declare

String s = "This is a string.";

what happens is that space is allocated on the stack for a pointer which points to some String object which internally contains a char array. My confusion stems from the fact that this pointer seems(I could be wrong) to behave differently than any other type of pointer. For example, if I write

int a = 1;
int* x = &a;
int* y = x;

what happens is that the pointer saved in y now points to the same location in memory as the pointer saved at x. So if I write

String s1 = "This is a string.";
String s2 = "Hello World!";
s1 = s2;

does the pointer saved at s1 now point to the same memory location as s2? Or does s1 copy the char array from s2 into its own separate memory? Further, If I write

String s1 = "This is a string.";
s1 = "Hello World!";

does s1 now point to whatever arbitrary memory location was created for the string literal "Hello World!"? Will this memory location be freed later, or is some sort of smart garbage collector in place which knows that I am using that memory in the heap? Finally, should I never assign a string declared on the stack to a global variable, as this will be referencing a memory location which will be freed soon?

Thank you in advance for your help!


texts: Serial plotter looks different and doesnt print graph

texts:
When I open my serial plotter to get the graph for my HC-SR04 sensor it doesn't show anything. My plotter looks different too. I have attached images below as well.

Only those numbers on the top-most move with time.(100,200,300)
Here's my code:
int trigPin = 12;
int echoPin = 11;

int pingTravelTime;
float pingTravelDistance;
float distToTarget;

int baudRate = 9600;

int dT = 10;
int dT2 = 500 ;

String msg1 = "The distance is equal to ";
String msg2 = "cm";

void setup() {
  // put your setup code here, to run once:
  Serial.begin(baudRate);

  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(trigPin, LOW);
  delayMicroseconds(dT);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(dT);
  digitalWrite(trigPin, LOW);

  pingTravelTime = pulseIn(echoPin, HIGH);

  pingTravelDistance = pingTravelTime * ((765. * 5280. * 12.) / (3600. * 1000000));
  pingTravelDistance = 2.54 * pingTravelDistance;
  distToTarget = (pingTravelDistance / 2);

  Serial.println(msg1 + distToTarget + msg2);

  delay(dT2);
}

What do I do??


texts:
I have a very simple ISR:

const uint32_t PATTERN_A = 0xFF00FF00;
const uint32_t PATTERN_B = 0x00FF00FF;
volatile uint32_t count = 0;
volatile uint32_t toggle = PATTERN_A;

// My ISR
void callback()
{
    count++;
    toggle = (count % 2) ? PATTERN_A : PATTERN_B;
}

The idea is that the toggle variable takes values 0xFF00FF00 or 0xFF00FF00 depending on the evenness of the count variable. This is the only place where toggle is changed, but it's used (read-only) in the sketch.

I don't know why, but toggle gets all sort of random values during execution.

What is happening here?


texts:
I only uploaded the library to check whether it has installed correctly. It's installed and i am having this error. Using library DHT-sensor-library-master at version 1.4.1 in folder: C:\Users\Mcniven\Documents\Arduino\libraries\DHT-sensor-library-master\DHT_U.h:36:29: fatal error: Adafruit_Sensor.h: No such file or directory
#include <Adafruit_Sensor.h>
exit status 1
Error compiling for board Arduino/Genuino Uno.


texts:
I'm trying to use Node MCU and NTP time turning on a relay 2 times a day and for only 10 minutes like at 6am 10 minutes and at 6pm 10 minutes.
The problem is my electricity is unreliable and node MCU might turn off during these times and when it turns on again after that specified time it won't turn on and not fulfill my requirement.
And there is another case where the node mcu turns of after completing the task and turns on again only to perform the task again which I don't want.
I want a solution where my node MCU will only perform the task ones in one given period regardless of how many times it is restarted and also count the time it turns on the relay so that if electricity is down and when it turns on again and does 10-minutes it performed the task and turns on the relay only the required amount.
I know it's a bit complex that's why I want someone to help me in this regard. I thought of making use of an SQL server but I don't exactly know how to go about to satisfy my requirements.


texts:
My teacher gave us a performance output about doing a dancing christmas lights in tinkercad. But I don't know what to do about the codes. He left  an instruction to us about what to do. I follow it but the tinkercad keep telling that...
Sorry, it seems like your code has some errors.
Close
 In function 'void setup()':
13:5: error: a function-definition is not allowed here before '{' token
21:7: error: a function-definition is not allowed here before '{' token
41:61: error: expected '}' at end of input
41:61: error: expected '}' at end of input
41:61: error: expected '}' at end of input
 exit status 1

And here's the code that I've entered...
int ledPins[]={3,4,5,6,7,8,9,10,11,12};
void setup()
{
  for(int i =0; i <11; i++)
  {
    pinMode(ledPins[i],OUTPUT);
}
  {
  void setup()
    {
     for (int i=0; i <11; i++)
     {
       pinMode(ledPins[i],OUTPUT);
     }
  }
    {
      void loop()
      {
        int i = 0;
        while (i<10)

        {
          {
            digitalWrite(ledPins{i],HIGH);
            delay(100);
            digitalWrite(ledPins[i],LOW);
            i++;
                                }
                         }
                         i = 10;
                         while (i >0
                                {
                                  digitalWrite(ledPins[i],HIGH;
                                               delay(100);
                                               digitalWrite(ledPins[i],LOW;
                                                            i--;
                                                            }
                                                            }

And here's the instruction of my teaher for the codes...
6. Initialize variables
Use array to initialize variables.
Set ledPin as the name of the variable and initialize the Arduino pins that you’re going to use.
Never forget to end each statement with semicolon
7. Set all pin to output
Use function void setup ()
Create a for () loop for array manipulation.
Initialize the for loop with i=0; since we will start the dancing lights with all LEDs turned off.
Initialize the condition i<11; since we need to turn on the 10 LEDs.
Set the increment to i++ because we need to iterate until it reaches the last LED.
Configure pin using pinMode().
Place a curly bracket before and after the for loop and pinMode().
8. Create a loop
Use function void loop().
Create a variable, i = 0.
Use while() for continuous looping
First while() is used to run your light from right to left.
Second while() is used to run your light from left to right.
Place a curly bracket before and after your statement block
Never forget to end each statement with semicolon


texts: Converting from Float to Int yielding weird results. What am I doing wrong?

texts: So I am trying to take GPS data with a Neo 6M gpsmodule (that is what is covered up by the square for privacy sake) and process it by adding/multiplying to get large integers representing the GPS data. This is using Arduino nano. When I try and convert the float numbers to integers, it gives me totally different numbers. 1242895 turns into -2289, and 611194 turns into 21370. I have tried so many things, but am stumped as to what is going on. Is it related to pointing? It's been awhile since I learned about pointers in my C++ class. X and Y are initialized as int global variables.


texts:
I'm trying to measure the temperature using a DS18B20 sensor. I'm using the DallasTemperature and OneWire Libraries. The sensor is connect in Pin 10 with a 4k7 resistor between VDD and DQ (actually I'm using 4x 1k and 2x 330 ohms) as so:

Here's the code I'm using:

#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 10

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

float celsius;

void setup(void) {
  Serial.begin(9600);

  sensors.setResolution(12);

  sensors.begin();
}

void loop(void) {
  sensors.requestTemperatures();
  celsius = sensors.getTempCByIndex(0);

  Serial.println(celsius);
}

The sensor is outputing values close to the actual temperature (measure with a mercury thermometer), but a bit off.

Example:

Sensor Temperaute: 34.44°C
Thermometer Temperature: ~32°C

Why is that? And how can I fix it?


texts: Arduino digital input fluctuates with neighbouring pins

texts:
I am using digital pins (2,3,4,5) to play midi notes on and off with 3pdt switches with pull down 10k resistor between input pin and ground.

However when I press button 2 randomly at different time interval it sometimes shows pin 3 high in the monitor. (after reading forums here I have realised that it might be due to big switches that I am using where the physical contact plates might be reason for this). I have even changed wires and isolated them from each other to rule out the noise from the wires.
I have checked all the connections and soldered the Arduino board pins with best possible skills that I have and tracks are all clear.

Same case occurs between other buttons as but its not always.
However after reading about Debounce I have made changes to the code as following, now I got the error only once after that I havent seen it. Can someone have look at the code and advice me if I have assigned Debounce function to multiple switches correctly and if not, what should it be as I am new with coding
Since I am using 3pdt switch I have added switch mode..

#include <MIDI.h>

int buttonPin[] = {2, 3, 4, 5};
byte mode[] = {0, 0 , 0 ,0};
boolean currentState = LOW;
boolean lastState = LOW;
int buttonPinM[] = {6, 7, 8, 9};
byte mode1[] = {0, 0, 0, 0};

boolean currentState1 = LOW;
boolean lastState1 = LOW;

long lastDebounceTime = 0;
long debounceDelay = 50;

void setup (){
    MIDI.begin(MIDI_CHANNEL_OMNI);

    int i;
    for (i = 0; i < 4; i++) {
        pinMode(buttonPin[i], INPUT);
    }
    int j;
    for (j = 0; j < 4; j++) {
        pinMode(buttonPinM[j], INPUT);
    }

    {
        int i;
        for (i = 0; i < 4; i++);
    }
    {
        int j;
        for (j = 0; j < 4; j++);
    }
}

// This will track which pin/mode we're using

int j = 0;
int i = 0;

void loop () {
    {
        currentState = digitalRead(buttonPin[i]);

        if ( (millis() - lastDebounceTime) > debounceDelay) {
            switch (mode[i]) {
                case 0:
                    if (currentState == HIGH) {
                        MIDI.sendNoteOff (i+55, 0, 1);
                        mode[i] = 1;
                        lastDebounceTime = millis();
                    }
                    break;
                case 1:
                    if (currentState == HIGH)
                        mode[i] = 2;
                    break;
                case 2:
                    if (currentState == LOW) {
                        MIDI.sendNoteOn (i+55, 127, 1);
                        mode[i] = 3;
                        lastDebounceTime = millis();
                    }
                    break;
                case 3:
                    if (currentState == LOW)
                        mode[i] = 0;
                    break;
            }
        }
        lastState = currentState;
        if (++i > 3)
            i = 0;
    }
    {
        currentState1 = digitalRead(buttonPinM[j]);
        if ( (millis() - lastDebounceTime) > debounceDelay) {
            switch (mode1[j]) {
                case 0:
                    if (currentState1 == HIGH ) {
                        MIDI.sendNoteOn (j+61, 127, 1);
                        mode1[j] = 1;
                        lastDebounceTime = millis();
                    }
                    break;
                case 1:
                    if (currentState1 == HIGH)
                        mode1[j] = 2;
                    break;
                case 2:
                    if (currentState1 == LOW) {
                        MIDI.sendNoteOff (j+61, 0, 1);
                        mode1[j] = 3;
                        lastDebounceTime = millis();
                    }
                    break;
                case 3:
                    if (currentState1 == LOW)
                        mode1[j] = 0;
                break;
            }
        }
        lastState1 = currentState1;
        if (++j > 3)
            j = 0;
    }
}


texts: Can I use 5V 1A Adapter to power Arduino UNO?

texts:
I have two Adapters, one is rated as Output 12V 500mA (used to power an old modem) and another one is rated as 5V 1A (old mobile phone charger).

My question is can use any of these to power my Arduino UNO with a barrel connector?

What does it mean when any adapter is rated as Output DC 5V 1A, Does it mean maximum we can draw 1A of current through it? What will happen if I draw more current than that.


texts: Enter a three digits number using push button connected to Arduino

texts:
I have the code given by my tutor and I need to change the code to be able enter a three digits number with the push button of switch module.
Here is the code which can only enter one individual number.
#include "RL_Switch.h" // include Switch library
Switch pushSwitch;      // create a Switch object called ‘pushSwitch’

int key = 0, inputflag = 0;

void setup() {
  pushSwitch.begin(); //initialise Switch module
  Serial.begin(57600); //initialise Serial Monitor
}

void loop() {

  /*assign to variable ‘pushKey’ the pressed button number, otherwise pushKey will be assigned -1
  /* (Please refer to Switch module material).*/
  key = pushSwitch.getPushKey();
  //Serial.print("K = ");
  //Serial.println(key);

  if(key <= -1) inputflag = 0;
  else {
    if(inputflag == 0) {
      inputflag = 1;
    }
    else {
      key = -1;
    }
  }

  //Serial.print("K = ");
  //Serial.println(key);

  if(key >= 0) {
    // if pushKey is higher than -1 then a button is pressed
    Serial.print("Pushed : "); // print out “Pushed : “
    Serial.println(key); // print out the pressed button number
    delay(500);
  }

   delay(100);

}


texts: Serial.print / sprintf causes program crash

texts:
The following code

  int i;
  char msg[16]; // Serial data.

  Serial.println();
  Serial.println("===============");

  sprintf(msg, "Sequence:  %4d", runNum);
  Serial.println(msg);

  Serial.print("LED colour: ");
  Serial.println(colours[colour]);

  Serial.print("Max mA:      ");
  Serial.println(mAmax);

  Serial.println("  mA    mV");
  for (i = 1; i <= mAmax; i++) {
    sprintf(msg, "%4d", i);          // <--- Line 1.
    Serial.print(msg);               // <--- Line 2.
    sprintf(msg, "%6d", i * 3);
    Serial.println(msg);
    delay(50);
  }

crashes after the first pass as shown below:

===============
Sequence:     1
LED colour: red
Max mA:      30
  mA    mV
   1     3

If I comment out "Line 1" and "Line 2" the loop runs correctly.

I suspect that something odd happens with either the two sprintf calls or the Serial.print / Serial.println calls in quick succession.

Can anyone spot an error or know of an issue that I've missed?

Development environment: create.arduino.cc


texts:
I want to control my bar fridge with temp sensor and relay,
This is my first project with code, i copied this:
https://robojax.com/learn/arduino/?vid=robojax-DHT22_11_TM1637_relay
But
I want some extra code that will prevent the fridge (ie relay) from going on too often.
For my purposes I want the relay to close if the temp is above 4c, but only if the relay has been off for say 20min or more.  FYI this is because my power source does not like to start the compressor when it is hot, so i don't want it cycling if it was just on.


texts: Trying to track down macro or #define values, possibly in arduino preprocessor

texts:
In reading various code I stumble across symbols that seem to be the result
of #define or other macro like symbols that I cannot find just by tracking
through the code ( including its chain, if any, of includes ).

Can someone offer some reasonably simple, but complete, guidance on how the
arduino ide works with especially emphasis on automatically included files
( and their location ) and any other automagically appearing stuff.


texts: Input 4-digit number using 4*4 keypad and show in serial monitor

texts:
#include <Keypad.h>

int myNum[4];

const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad 8,7,6,5
byte colPins[COLS] = {9, 8, 7, 6}; //connect to the column pinouts of the keypad 4,3,2,1
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println("Enter four-digit num -");  // request for input
  for (int i = 0; i < 4;){
    if(keypad.getKey()!= NO_KEY) {
      myNum[i] = keypad.getKey();
      i = i+1;
    }
  }
  Serial.print("Entered number is = ");
  Serial.print(myNum[0]);
  Serial.print(myNum[1]);
  Serial.print(myNum[2]);
  Serial.println(myNum[3]);
  delay(500);
}

I want that when I press a 4-digit number on the keypad it should be shown in the serial monitor. This code gives 0000 when I press any key on keypad.


texts:
I am using an Arduino M0 Pro and have a device connected via Pin 0 and 1 of it. So I am using the predefined Serial5 interface to receive data from it. I have the following code snippet/method that tries to read an answer from Serial5 if it is available. Otherwise it returns an empty string.

String read_answer() {
  String str = "";
  // Check if bytes are available
  if (Serial5.available()) {
    char c;
    // Read an character unless the read() method returns -1
    // The -1 is identical to 255
    while ((c = Serial5.read()) != 255) {
      // Append the read character to the string array
      str.concat(c);
    }

    // Output the string on the serial debug interface
    Serial.print("Read: \"");
    Serial.print(str);
    Serial.print("\"\n");
  }
  // Return the read string
  return str;
}

If I send an the following string "ABCDEF HIJKL MNOPQR" via an FTDI towards it the first times it correctly printed :

Read: "ABCDEF HIJKL MNOPQR"

But suddenly it just stops reading the complete string. The output is something like that:

Read: "ABCDEF HIJKL MN

It is just cut off and everything stops working, over and over again. It might be a very stupid mistake but I don't know where to check next. If I missed something to explain or more context is needed pls tell me.


texts:
I want to measure current using the MAX471 sensor that outputs voltage proportional to the current (1V/A according to the datasheet). To test the module, I connected a 330 ohm resistor to the sensor and powered it from 3.3V arduino. Using ohms law, I was expecting an output voltage of around 10 mV (for ~ 10 mA) in my circuit. However, I am getting an output of around 2.17 volts which seems wrong.
Does anyone see any mistake in my circuit or how I am trying to measure the current?
Here is my circuit:

My Code:
#include <Arduino.h>

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  int adc_val = analogRead(A5);
  float vol = 3.2 / 4095 * adc_val; // using a 12 bit adc

  Serial.println(vol);
  delay(3000);
}


texts: How high of a baud rate can I go (without errors)?

texts:
The standard is 9600 baud. That's just the standard. Using a Arduino Uno SMD R2, what is the highest practical baud rate I can achieve?

Bonus points for the audacious: How would you go about creating an error checking mechanism and then increasing the baud rate ridiculous high to get high transfer rates?


texts: On the Arduino website it states that the analog pins read voltages from 0 to 5 volts (default) and return a value from 0 to 1023. One can also set the range with analogReference(). However, this is probably assuming the Arduino is running at 5 volts. If one powers the board with, say 4 volts, will the analog reference still be 5 volts default, or changed to the input voltage of 4 volts?


texts: Code hangs with SPI, and OLED labraries (Possible conflict between Adafruit SSD1306 and hardware SPI libraries)

texts:
I have an issue with using two libraries together, namely SPI.h that is installed together with an Arduino and Adafruit_SSD1306.h. My code was getting stuck so I stripped it down to the bare minimum to find where the problem occurs. Here's the stripped down code:
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h>

//Screen Resoluttion
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_Res A3
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_Res);

#define _ssPin  7

void setup()   {
  pinMode(OLED_Res, OUTPUT);
  pinMode(_ssPin, OUTPUT);
  Serial.begin(19200);
  Serial.println("Serial set up");
  SPI.begin();
  Serial.println("SPI set up");
  Wire.begin();
  Serial.println("I2C set up");
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  Serial.println("Screen set up");
}

void loop()
{
  Serial.println("Loop entered");
}

I am debugging the code using serial monitor. The code as it stands right now hangs after I2C initialization. If I uncomment either SPI.begin() or display.begin(...) it jumps into the loop. Which leads me to think there might be a conflict between the two libraries. Which is weird considering I haven't found a similar issue on the internet and I doubt these two libraries are rarely used.


texts: How to measure resistance of TFT Touchscreen

texts:
I'm using a TFT Touchscreen shield with my Arduino UNO, and I'm running "tftpaint" example by Adafruit.

I've noticed that when initializing the Touchscreen object, a resistance value must be provided. Library default is 300, but a comment in the code says:

// For better pressure precision, we need to know the resistance
// between X+ and X- Use any multimeter to read it

How should I perform such measurement? Where do I put the probes of my multimeter? FYI, my shield is this one:


texts:
I want to connect an RFID reader to an Arduino board. The RFID reader has several wires attached, and the manual mentions them as follows:

Red: VCC +12V
Black: GND
Green: D 0/RX/4R+
White: D 1/TX/4R−
Blue: LED/CS
Yellow: Beep

There is also another black wire attached, but the manual does not mention it.
This is an image of it:

I have the red wire connected to the 5V pin and the black wire to the GND pin on Arduino board. Then I have the white wire connected to the RX pin on the Arduino board.

I'm trying to Serial-read the RX port using this code:

void setup() {
    Serial.begin(9600);
}

void loop() {
    if (Serial.available() > 0) {
        int b = Serial.read();
        Serial.print(b);
        Serial.print(" ");
    }
}

When I try to read a keyfob, only this is printed – nineteen times 248:

248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248

To me it looks like there's something wrong with the connection somewhere.

How can I properly read this RFID reader? If above assumption is not correct, is there something I should know?


texts: How to program micro chips directly with USB

texts:
Is it possible to program chips like the Arduino uno's Atmega328P directly with USB serial from your computer?
Where can i find information on the protocols/standards to do such a thing?

More specifically, I want to be able to make a custom pcb for my Attiny85 chips with a usb connector. I would prefer not to use the arduino IDE.
Is it possible to program this chip like so?


texts: Which type of sensor should i use to get RPM of an engine?

texts:
Using Arduino (i got leonardo and uno),
I'm looking for a way to get the RPM of my car's engine.
I know this can be done using an OBD2 connection however i'm looking for a different way.
Sensing?
I need a reference for a sensor / a creative way to get this data.
Having said that, these approaches came up:

guessing the RPM by reading the amps in the car's 12V connection
recording the sound of the engine using a microphone and setting thresholds for certain RPM values


texts: Powering Arduino Pro Mini + Driving LED Strip

texts:
Just looking for a second opinion on my circuit below. Wired up everything works great, but last night as i was unplugging the FTDI programmer something seemed to have happend, and the mini was bricked.

I'm not sure if it has to do with my wiring below, or if it was me unplugging the cable in a haphazard manner.

What I'm attempting to do is run my arduino from 12v wall supply, but also drive an LED strip with it. I'm just unsure if this is the best way to go about it, any advice is welcome.

Thanks
Justin


texts:
The Arduino starter kit came with a DC motor. I want to have it rotate at a slow speed so it can be on a reel and automatically dispense and wind wire, however, I don't know how I can slow it down.

Giving it an analog value of 1 is still way too fast.

Is there any way to control or reduce the speed. Like a 360 degree turn in a second rather than milliseconds?

Thanks


texts: Is there an advantage to set pinmodes via bitmask and register?

texts:
I'm working with the capacitive sensor library currently and the author does not use digitalWrite(), but instead sets the output of a pin via functions changing the bitmasks of certain registers:

https://github.com/PaulStoffregen/CapacitiveSensor/blob/master/CapacitiveSensor.h#L39

I looked into the OneWire library description those functions come from, but I still can't see any advantage over simply using the standard way Arduino proposes.


texts:
I am trying to read messages sent from my mobile to a GSM SIM900A module on my Arduino Serial monitor. Neither does the AT+CMGR command nor does the AT+CMGL command display SMS content. I also tried increasing the receiver buffer size in the SoftwareSerial Library but to no avail. I am simply trying to read 'check123'. I want to further store the SMS received as a string for further processing. But I am stuck with no display of SMS content on the serial monitor.

My code is:

#include <SoftwareSerial.h>
SoftwareSerial mySerial(9, 10);
String content = "";
char character;
int i;

void setup() {
  mySerial.begin(9600);
  Serial.begin(9600);
  delay(100);
}

void loop() {
  ReceiveSMS();
  delay(2000);
}

void ReceiveSMS() {
  mySerial.println("AT+CMGF=1");
  delay(2000);
  toSerial();
  mySerial.println("AT+CPMS=\"SM\",\"SM\",\"SM\"");
  delay(2000);
  toSerial();
  mySerial.println("AT+CMGL=\"ALL\"\r");
  delay(5000);
  toSerial();
  mySerial.println("AT+CMGD=1,4");
  delay(2000);
  toSerial();
}

void toSerial() {
  while (mySerial.available() != 0) {
    Serial.write(mySerial.read());
  }
}

Output is:

Edit:

SoftwareSerial.cpp file. I have marked the area where I have changed the value from 64 to 256 according to some previous help post.


texts: client.connect() failing unless I ping my ESP

texts:
[EDIT] it seems like this has to do with my laptop's firewall settings rather than anything wrong with the ESP8266 [/EDIT]

I have a webserver on my laptop. When I do this on my ESP8266 (after the wifi has been connected)

while(!client.connect(laptop,port)) {
   Serial.println("Connecting...");
   delay(1000);
}

It loops forever. However, if I manually ping my ESP from my laptop, I initially get this

Pinging 192.168.1.7 with 32 bytes of data:
Request timed out.
Reply from 192.168.1.7: bytes=32 time=4ms TTL=255

And as soon as this happens, the ESP gets connected to the laptop, and all works fine.

So it seems to me like the client.connect is preventing the ESP from even registering to the network, and the pinging is somehow waking it up.


texts: Is there any circuit with opamp where can be (by arduino) set constant output amplitude which doesn't depend on input signals amplitude?


texts:
Has anyone experience configuring the Atmega328P to work with an 8Mhz external clock?

I want to reduce the power consumption of the device. If I just connect an 8MHz external quartz oscillator then simple programs like LED blink still work (With the time delays doubled), but if I try to use communication like UART, then I am unable to. So no programming new sketches.


texts:
i use the "client.availbale" to check incoming data on the (mkr1010) client coming from (mkr1010) server but it always contains "0". Serial printing (monitor) it on server works. It looks as if the data never arrives? Thanks for helping out !

client code :

if (client.connect(ServerIP, 23)) {
client.print("741G");
byte i = 0;
Serial.println(client.available());

    while (client.available() > 0 && i < bufferSize) {

      incomingMessage[i] = client.read();
      Serial.println(incomingMessage[i]);
      Serial.println(i);
      // check if end of incoming message
      if (incomingMessage[i] == '\r') {
        // replace carriage return with null terminator
        incomingMessage[i] = '\0';
        // set array index counter to end
        i = bufferSize;
        // flush out any remaining control characters which would
        // stay in client buffer until next loop
        client.flush();
      }
      // increase array index counter
      i++;

my server code :

// when the client sends the first byte, say hello:
  if (client) {
    if (!alreadyConnected) {
      // clead out the input buffer:
      client.flush();
      Serial.println("We have a new client");
      client.println("Hello, client!");
      alreadyConnected = true;
    }

    if (client.available() > 0) {
      // read the bytes incoming from the client:
      char request = client.read();
      Serial.print(request);

      for (i = 0; i < 4; i = i + 1) {
      Serial.print(myseq[i]);
      server.write(myseq[i]);

      }


texts: How do I use an AtTiny85 (or other AtTiny) with Arduino?

texts:
Please mind that this is an "example" question.

How to make a "tiny arduino"?

I've ordered a bunch of ATtiny85's off E-bay, they're like tiny Arduino's.

I've set up the latest Arduino IDE and would like to run the blink example.

My process so far:

Wiring

Code

(The blink example)

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}


texts:
I have an mpx12DP pressure sensor that I want to use to measure the depth of water in a 1m tall water tank.

But it only measures up to 55mV of voltage change, which the arduino can't really detect changes in. (The sensor measures 0 to 1.45psi- 1m of water should give me 1.4psi, so I should be able to get really good accuracy).

Is this as good sensor to use for this purpose? How do I amplify the signal from the sensor? I have tried an LM324 op-amp, but couldn't get it to work (this may be entirely the wrong thing to use! And I was utterly unsure of the kind of circuit to use it in). Any advice on parts.. schematics.. a suitable already-amplified sensor that reads only up to 1.45psi?

Thank you,

Pressure sensor datasheet: http://www.digikey.co.uk/product-detail/en/MPX12DP/MPX12DP-ND/684659
Op amp datasheet: http://www.ti.com/lit/ds/symlink/lm124-n.pdf


texts: Do arduino librarys require the arduino to be connected to a computer?

texts: The title pretty much explains my question. If I'm using a library for example one for an accelerometer does the arduino need to be connected to my computer because it's using a library? Or is the library uploaded to the arduino and there for can run with out a computer connected?


texts: How to store u-blox coordinates (lat, lng) values in doubles? [TinyGps++]

texts:
I use a u-blox gps with my arduino. I can successfully write out the value of a coordinate (lat, lng) like this: Serial.println (gps.location.lat(), 8); but when I try to store the value with all the decimals it returns 8.00 instead of the correct coordinate + all of the 8 decimals.

This is my code:

#include "TinyGPS++.h"
#include <SoftwareSerial.h>
SoftwareSerial gpsconnection (4,3);
TinyGPSPlus gps;

void setup()
{
 Serial.begin(9600);
 gpsconnection.begin (9600);
}

void loop()
{
 while (gpsconnection.available())
 {
   gps.encode(gpsconnection.read());
 }

 //this works and returns 8 decimals
 Serial.println (gps.location.lat(), 8);
 Serial.println (gps.location.lng(), 8);

 //but if i try to store it like this:
 double latcord = (gps.location.lat(), 8);
 double lngcord = (gps.location.lng(), 8);

 //it returns 8.00 on both the "latcord" and "lngcord" which is the wrong coordinate and also it doesnt return 8 decimals
 Serial.println (latcord);
 Serial.println (lngcord);

 //if i try to convert the value to a string and then back to a double like this:
 double lat = gps.location.lat();
 String msgLat =  String(lat, 8);

 double thelat = atof(msgLat.c_str());

 //with this i get the correct first two numbers out but only 2 decimals after, not 8 decimals as it should be.
 Serial.println (thelat);

}


texts: IR Receiver interrupt and arduino sleep mode

texts:
I need to put my arduino into the sleep mode in order to consume less power. My arduino receives IR data and do some work with it, but I need to make it sleep until there is no data. If the data has appeared it should wake up and do something with data and go back to sleep mode.
Is there any way to do this.
I would be grateful for any help.


texts: What is wrong with my code? RGB potentiometer

texts:
Arduino programming has been a huge learning curve for me and I am trying to create a project with an rgb that's color is determined by a potentiometer. To where the further I turn it, the further across the rainbow spectrum it goes. I can't figure out how to do all values in between because I am not educated enough but I came up with this basic code...

int redpin = 6;
int greenpin = 3;
int bluepin = 5;
int potPin = 0;

void setup() {
  // put your setup code here, to run once:
  pinMode(redpin, OUTPUT);
  pinMode(bluepin, OUTPUT);
  pinMode(greenpin, OUTPUT);
  pinMode(potPin, INPUT);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  int wavecolor = analogRead(potPin);
  Serial.print(wavecolor);
  {
    if (wavecolor = 0) {
      setColor(255, 0, 0);  // red
    }
    if (wavecolor > 0 or wavecolor < 333) {
      setColor(0, 255, 0);  // green
    }
    if (wavecolor > 333 or wavecolor < 667) {
      setColor(0, 0, 255);  // blue
    }
    if (wavecolor > 667 or wavecolor < 1022) {
      setColor(255, 255, 0);  // yellow
    }
    if (wavecolor = 1023) {
      setColor(80, 0, 80);  // purple
    }
  }
}

void setColor(int red, int green, int blue)
{
#ifdef COMMON_ANODE
  red = 255 - red;
  green = 255 - green;
  blue = 255 - blue;
#endif
  analogWrite(redpin, red);
  analogWrite(greenpin, green);
  analogWrite(bluepin, blue);
}

And for some reason, where the light should change colors once the potentiometer goes past a certain number, the light just flickers and only changes colors to white when it is all the way up or down. Also, it has a weird flickery yellow color.
Since I am new to this, can one of you better educated people be willing to assist me?


texts: AT commands not working on arduino uno with A7 gsm gprs module

texts:
After all connections have been made, I tried to verify my sketch to the arduino

#include <SoftwareSerial.h>

// RX, TX
SoftwareSerial mySerial(2, 3);

void setup()
{
  Serial.begin(9600);
  mySerial.begin(9600);

  while (mySerial.available())
  {
    mySerial.read();
  }
}

void loop()
{
  if (Serial.available())
  {
    mySerial.write(Serial.read());
  }

  if (mySerial.available())
  {
    Serial.write(mySerial.read());
  }
}

After uploading this code to arduino, I tried to confirm.

But it was constantly displaying
¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿
If I set the baud to 9600

But if I set it to 115200, I will not get anything
..
Please help me.

I will be defending my project tomorrow and I am stock here...


texts: ADC noise when sharing ground from external supplies

texts:
i have resistor based sensor, when i test it using arduino connect to PC using serial monitor  without sharing ground to other circuit it has a nice value between 300-650 in adc range and the error/ accuracy reading just have about 5 value (ex: 607-612) if there is no condition change in the sensor.

But the problem comes when i sharing the ground to the other circuit. The accuracy is messed up bigger than 60 adc value (570-660) with the same condition without sharing ground.

My circuit is powered by PSU 24V and 24V driver to produce input signal for electric pressure regulator. The arduino ground is sharing because to control the input of the 24V driver. Here my circuit in the attachment.

So there is two ground from PC (i need it to use serial monitor) and the PSU 24V

How to eliminate the noise? Is there any way to control the 24v driver and read the sensor at the same time without sharing ground? Maybe using two controller with master/slave? Or there is any advice?


texts: Understanding the pin diagram for MPU6050 IMU

texts:
I was reading this tutorial about the MPU6050 IMU and I was unable to understand why the pin configurations vary so much when compared to this schematic for EasyEDA.
The tutorial has this pin configuration :

Whereas the EasyEDA schematic looks like this :

I am not sure how to reconcile the two. Why does the schematic have 24 pins while the first diagram has only 8? Also I don't know what all the 24 pins are for.


texts: Digital Pin won't ground when set to LOW

texts: My friend and I are repurposing an old rc car for a project. When we connect the dc motors to 5V and ground, the motors spin. However, when we power the motors from 5v and ground it in the digital output pin set to LOW, nothing happens. The identical circuit works in tinkercad. We are using a nano, but have tried an uno and mega as well.


texts: How to send HTTP request to specific port using Ciao?

texts:
I currently have a working REST client on my arduino, but the requests always go to port 80, how do I make it send the request to a specific port?

This is my current code:
/*
File: RestClient.ino
This example makes an HTTP request after 10 seconds and shows the result both in
serial monitor and in the wifi console of the Arduino Uno WiFi.

Note: works only with Arduino Uno WiFi Developer Edition.

http://www.arduino.org/learning/tutorials/boards-tutorials/restserver-and-restclient

#include <Wire.h>
#include <UnoWiFiDevEd.h>

void setup() {

    const char* connector = "rest";
    const char* server = "download.arduino.org";
    const char* method = "GET";
    const char* resource = "/latest.txt";

    Serial.begin(9600);
    Ciao.begin();

    pinMode(2, INPUT);

    delay(10000);
    doRequest(connector, server, resource, method);
}

void loop() {

}

void doRequest(const char* conn, const char* server, const char* command, const char* method){
    CiaoData data = Ciao.write(conn, server, command, method);
    if (!data.isEmpty()){
        Ciao.println( "State: " + String (data.get(1)) );
        Ciao.println( "Response: " + String (data.get(2)) );
        Serial.println( "State: " + String (data.get(1)) );
        Serial.println( "Response: " + String (data.get(2)) );
    }
    else{
        Ciao.println ("Write Error");
        Serial.println ("Write Error");
    }
}

If I add for example :8080 to the end of the server variable, it does not work.

So how do I make that request go to a specific port?


texts: Use only one pin as serial output/input with arduino

texts:
I'm looking for a way to use Arduino UNO's as serial outputs or input "individually", I don want to have an RX pin for each TX pin. I know the library SoftwareSerial, but I'm not sure if it is posible to achieve my objective with it.

I have also read that in this library "If using multiple software serial ports, only one can receive data at a time". Is there any library or method I can use to achieve both of my objectives, using pins "individually" and receiving data from more than a pin at a time?

Thank you for your time.


texts:
I built a sample of my project on a breadboard using little 700mh leds and other components that easily ran off my computers usb. Now I’m building my project to full size.  This includes 12 7w leds, soundboard and amps. It’s still going to be controlled by a arduino mega, obviously, the power consumption is substantially higher than the usb or even the arduino can provide. I’m using a high amp power supply that can drive everything including the arduino.

The question is... how will I be able to alter my sketch later???  Is it feasible to use a panel mount usb cord modified to only allow tx and rx, (cut the red and black)?  Or will I have to isolate the mega each time I need to send a change to it?


texts:
I am using Adafruit motor shield, I am running multiple DC motors for different amounts of time, but to start at the same time - I have researched that to do this I have to monitor the elapsed time of each motor in the loop instead of using the delay to avoid blocking if I want them to run at the same time.

Eventually, There will be around 10 DC motors running off this, however it seems very sloppy to me to have 10 repeat entries of very similar code.

Is there a way to create a class or something for the following code so I am not repeating it all as although it works it seems like the way I am currently doing it is bad practice(?) and could be done more eloquently! Forgive me if this is a strange question as I am new to arduino.

In this example there are only 2 motors, however when it gets to around 10, there will be a lot of code just for this bit!

Any suggestions are welcome.

Thanks in advance.

Example code:

#include <Wire.h>
#include <Adafruit_MotorShield.h>

boolean runMotor1 = false;
boolean Motor1Running = false;
unsigned long Motor1StartMillis;
unsigned long Motor1RunTime = 5000;

boolean runMotor2 = false;
boolean Motor2Running = false;
unsigned long Motor2StartMillis;
unsigned long Motor2RunTime = 10000;

//etc etc etc up to 10 Motors

Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_DCMotor *MotorMotor1 = AFMS.getMotor(1);
Adafruit_DCMotor *MotorMotor2 = AFMS.getMotor(2);

void setup()
{
  Serial.begin(9600);
  AFMS.begin();
  runMotor1 = true;  // set condition to true for testing
  runMotor2 = true;
}
void loop()
{
/// Motor1 START
  if (runMotor1 == true) {
     Serial.println("Run Motor 1!");
     runMotor1 = false;
    MotorMotor1->setSpeed(255);
    MotorMotor1->run(FORWARD);
    Motor1StartMillis = millis();
    Motor1Running = true;
  }

  if( Motor1Running && (millis()-Motor1StartMillis > Motor1RunTime) )
  {
    Serial.println("Motor1 Time Elapsed!");
    MotorMotor1->setSpeed(0);
    MotorMotor1->run(RELEASE);
    runMotor1 = false;
    Motor1Running = false;
  }

  /// Motor 2
    if (runMotor2 == true) {
     Serial.println("Run Motor 2!");
     runMotor2 = false;
    MotorMotor2->setSpeed(255);
    MotorMotor2->run(FORWARD);
    Motor2StartMillis = millis();
    Motor2Running = true;
  }

  if( Motor2Running && (millis()-Motor2StartMillis > Motor2RunTime) )
  {
    Serial.println("Motor2 Time Elapsed!");
    MotorMotor2->setSpeed(0);
    MotorMotor2->run(RELEASE);
    runMotor2 = false;
    Motor2Running = false;
  }

}

Thanks for reading, and thank you for any input you may have.
Steve


texts:
I want to connect my adafruit motor shield v2.3 to a touch board from bare conductive so that the motor turns when one of the electrodes is touched.

I've tested the touch part and that isn't a problem so i tested the motor shield on my arduino uno. I am using the DCMotorTest example and when uploading it doesn't give any errors. The shield is getting powered, but the motor isn't turning.

The motor does turn when connected to a 9v battery.
The motor doesn't turn when connected to motor shield without external power and VIN jumper connected.enter image description here
The motor doesn't turn when connected to motor shield with external power with and without VIN jumper connected.

/*
This is a test sketch for the Adafruit assembled Motor Shield for Arduino v2
It won't work with v1.x motor shields! Only for the v2's with built in PWM
control

For use with the Adafruit Motor Shield v2
---->   http://www.adafruit.com/products/1438
*/

#include <Wire.h>
#include <Adafruit_MotorShield.h>

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);

// Select which 'port' M1, M2, M3 or M4. In this case, M1
Adafruit_DCMotor *myMotor = AFMS.getMotor(1);
// You can also make another motor on port M2
//Adafruit_DCMotor *myOtherMotor = AFMS.getMotor(2);

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Adafruit Motorshield v2 - DC Motor test!");

  AFMS.begin();  // create with the default frequency 1.6KHz
  //AFMS.begin(1000);  // OR with a different frequency, say 1KHz

  // Set the speed to start, from 0 (off) to 255 (max speed)
  myMotor->setSpeed(150);
  myMotor->run(FORWARD);
  // turn on motor
  myMotor->run(RELEASE);
}

void loop() {
  uint8_t i;

  Serial.print("tick");

  myMotor->run(FORWARD);
  for (i=0; i<255; i++) {
    myMotor->setSpeed(i);
    delay(10);
  }
  for (i=255; i!=0; i--) {
    myMotor->setSpeed(i);
    delay(10);
  }

  Serial.print("tock");

  myMotor->run(BACKWARD);
  for (i=0; i<255; i++) {
    myMotor->setSpeed(i);
    delay(10);
  }
  for (i=255; i!=0; i--) {
    myMotor->setSpeed(i);
    delay(10);
  }

  Serial.print("tech");
  myMotor->run(RELEASE);
  delay(1000);
}

https://imgur.com/a/tEGndDQ


texts: 7 -pin OLED not working with SSD1306.h, GFX.h, U8glib.h using in SPI

texts:
I have tried running the example code provided to get the OLED to work but to no avail.
I have two OLED displays with me.
They are not connected serially.
I am using SPI interface.
These are the reference codes I used to get the OLED to work.
Link-1
Link-2
The wiring is given in the header for Link-2 and in the on-site wiring diagram for Link-1.
I was briefly able to get the OLED working using Link-2 and to test reliability I unhooked the device from the breadboard and as soon as I reloaded the code onto the Arduino. It stopped working. After running 50 consecutive Restart->Re-flash->Check Output cycles the OLED is still unresponsive.


texts: WS2812B NeoPixels no longer working after cutting the strip and adding an extension

texts:
I am trying to use WS2812B LEDs with an Arduino.
I have 24 LEDs connected to pin 6.
When I first received the strip I connected it to 12V and data.
Using the cyclone example in the FastLED library worked.
But then I cut them and added extension wires.
I have 3 LEDs on single strip; so it is 8 strips of 3 LEDs.
The extension is about 30cm long.
Now when I power them, they just glow bright white.
So, I thought the extension wire was the problem.
I removed extension and connected them as they came.
But still, they are turning on bright white.
I connected the Arduino out to DIN.


texts:
I need to write a library for a display I created with eight segments. So, I decided to try to use SevSeg (https://github.com/DeanIsMe/SevSeg) as a starting off point. It can't be that different, right?

Well, I think I have hit a roadblock that indicates I must basically do everything from scratch. Here is how the information on what segments correspond to letters are stored in SevSeg:

 // The codes below indicate which segments must be
//illuminated to display each number.

static const byte digitCodeMap[] = {
  //     GFEDCBA  Segments      7-segment map:
  B00111111, // 0   "0"          AAA
  B00000110, // 1   "1"         F   B
  B01011011, // 2   "2"         F   B
  B01001111, // 3   "3"          GGG
  B01100110, // 4   "4"         E   C
  B01101101, // 5   "5"         E   C
  B01111101, // 6   "6"          DDD
  B00000111, // 7   "7"
  B01111111, // 8   "8"
  B01101111, // 9   "9"
  B01110111, // 65  'A'
  B01111100, // 66  'b'
  B00111001, // 67  'C'
  B01011110, // 68  'd'
  B01111001, // 69  'E'
  B01110001, // 70  'F'
  B00111101, // 71  'G'
  B01110110, // 72  'H'
  B00000110, // 73  'I'
  B00001110, // 74  'J'
  B01110110, // 75  'K'  Same as 'H'
  B00111000, // 76  'L'
  B00000000, // 77  'M'  NO DISPLAY
  B01010100, // 78  'n'
  B00111111, // 79  'O'
  B01110011, // 80  'P'
  B01100111, // 81  'q'
  B01010000, // 82  'r'
  B01101101, // 83  'S'
  B01111000, // 84  't'
  B00111110, // 85  'U'
  B00111110, // 86  'V'  Same as 'U'
  B00000000, // 87  'W'  NO DISPLAY
  B01110110, // 88  'X'  Same as 'H'
  B01101110, // 89  'y'
  B01011011, // 90  'Z'  Same as '2'
  B00000000, // 32  ' '  BLANK
  B01000000, // 45  '-'  DASH
};

As you can see this is a one dimensional array of 8-byte binaries that encode the segment. I don't understand the purpose of the B0 at the beginning of each byte. Could I use the 0 column to encode my eighth segment?

Am I right to assume this will change everything about the code and maybe I should start from scratch with a 2-D array?

This is roughly what I want:

//  ABCDEFGH  Segments      8-segment map:
  11000011, // 0   "0"       A BBBBB H
  10000000, // 1   "1"       A C   D H
  01011010, // 2   "2"       A C   D H
  11101010, // 3   "3"       A  C D  H
  00110101, // 4   "4"       A  E F  H
  01011010, // 5   "5"       A E   F H
  11101110, // 6   "6"       A E   F H
  01011000, // 7   "7"       A GGGGG H
  01111110, // 8   "8"
  01100101, // 9   "9"
  11111101, // 10  "A"
  10001110, // 11  "b"
  11000010, // 12  "C"
  00001111, // 13  "d"

What data type should I use for the array? Would byte work since I'm not using the B0?

Thanks.


texts:
I have a scd30 sensor wired to an Arduino Uno. The scd30 works on the I2C protocol. I am able to read data live on the serial monitor on the Arduino IDE. I have an ethernet shield on my Arduino. I would like the Arduino to communicate with a field agent which will upload the data to the internet.

I have tried numerous modbus TCP libraries and dont seem to be getting anywhere. I can connect my arduino to the field agent but whenever it sends data I get a 0x02 exception code - Illegal data address. This is the library I'm using https://github.com/andresarmento/modbus-arduino/tree/master/libraries/ModbusIP/examples

I believe the right way to go about it is through holding registers but im not sure how to do this when using I2C. The connection is fine, the problem is the format. Any help is appreciated thanks.

/*
  Reading CO2, humidity and temperature from the SCD30
  This example prints the current CO2 level, relative humidity, and temperature in C.
*/
#include <SPI.h>
#include <Ethernet.h>
#include <Modbus.h>
#include <ModbusIP.h>
#include <Wire.h>
#include <Streaming.h>
#include "SparkFun_SCD30_Arduino_Library.h"

SCD30 airSensor;
//Modbus Registers Offsets (0-9999)
const int SENSOR_ISTS = 100;
//ModbusIP object
ModbusIP mb;
long ts;

void setup()
{
  Wire.begin();
  Serial.begin(9600);
  Serial.println("SCD30 Example");

 // The media access control (ethernet hardware) address for the shield
    byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
    // The IP address for the shield
    byte ip[] = { 000 , 00,0, 00  };
    byte gateway[] = { 0, 0, 0, 0 };
    byte subnet[] = { 255, 255, 255, 0 };
    //Config Modbus IP
    mb.config(mac, ip,gateway,subnet);
    // Add SWITCH_ISTS register - Use addIsts() for digital inputs
    mb.addHreg(SENSOR_ISTS);
  airSensor.begin(); //This will cause readings to occur every two seconds

}

void loop()
{

mb.task();
   mb.Hreg(SENSOR_ISTS, digitalRead(airSensor.getTemperature()));

}


texts: GSM module connected with arduino uno giving garbage values in response

texts:
I connected a GSM module with the Arduino UNO. The connections are as follows:

  Gnd of gsm -----> Gnd of arduino

  TX of gsm  -----> pin 9 of arduino

  Rx of gsm  -----> pin 10 of arduino

GSM is powered from a 9V-1Amp wall adapter.

The GSM is performing according to all the AT commands (like making a voice call, hanging a call, answering a call) which are given, but it is displaying garbage values on serial monitor in response.

Here is the code:

#include <SoftwareSerial.h>
SoftwareSerial myserial(9, 10);

void setup() {
    Serial.begin(115200);
    myserial.begin(9600);
    myserial.println("ATDXXXXXXXXXX;");
    delay(30000);
    myserial.println("ATH");
}

void loop() {
    if (myserial.available()>0){
        Serial.println(myserial.read());
    }
}

What could be reasons for the GSM to output garbage values and how can I resolve it?


texts: How to transmit data from a sensor using SIM800L?

texts:
I am using soil sensor with Arduino UNO. I wish to transmit data coming from sensor to a server using sim800l.
I am unable to find any help on this. please guide me.


texts: Cannot receive data from GPS SD Shield V2-B

texts:
I am attempting to receive GPS data from a GPS SD Shield V2-B purchased from maplin. I have attempted the very simple sketch they provide on their website linksprite.com.
I have also tried following a tutorial found here: http://tronixstuff.com/2014/01/15/tutorial-arduino-mediatek-3329-gps/.
This is the code i am using:

    // Example 19.1

    #include <SoftwareSerial.h>
    SoftwareSerial GPS(2,3); // configure software serial port -

    void setup()
    {
      GPS.begin(9600);
      Serial.begin(9600);
      pinMode(13,OUTPUT);
    }
    void loop()
    {
      byte a;
        if (GPS.available() > 0 )
      {
        a = GPS.read(); // get the byte of data from the GPS
        Serial.write(a);
        digitalWrite(13,HIGH);
        delay(1000);
        digitalWrite(13,LOW);
        delay(1000);
      }
    }

I am using an Arduino 101. The jumpers on the GPS shield are set up as follows:

I have attempted using both power simply from my Mac and an external 9V battery connected to the Arduino.
The 'blink' has been added the sketch to test whether data was being received but there was a problem with the serial monitor. This is not the case because the blink did not occur. It however did occur when moved outside of the if statement as you would expect.
Any help or suggestions would be much appreciated.


texts:
I am working on an Arduino Mega 2560 and BL-TB6560-V2.0 driver for running a stepper motor. Initially I was able to run the stepper in both direction with code given and a schematic as per this image.

.

int dirpin = 7;
int dirH = 12;
int steppin = 9;

void setup() {
  pinMode(dirpin, OUTPUT);
  pinMode(steppin, OUTPUT);
  pinMode(dirH, OUTPUT);
}

void loop() {
  digitalWrite(dirpin, LOW); // Set the direction.
  digitalWrite(dirH, LOW);
  delay(1000);
  for (int i = 0; i<32767; i++) {
    // Iterate for 4000 microsteps.(32767)
    digitalWrite(steppin, LOW); // This LOW to HIGH change is what creates the
    digitalWrite(steppin, HIGH); // "Rising Edge" so the easydriver knows to when to step.
    delayMicroseconds(50);
  }
  delay(1000);
  digitalWrite(dirpin, LOW); // Set the direction.
  digitalWrite(dirH, HIGH);
  for (int j = 0; j<32767; j++) {
    // Iterate for 4000 microsteps.
    digitalWrite(steppin, LOW); // This LOW to HIGH change is what creates the
    digitalWrite(steppin, HIGH); // "Rising Edge" so the easydriver knows to when to step.
    delayMicroseconds(50);
  }
}

But now when I am trying it, the same stepper is not rotating. What could be the reason? I have checked the driver voltage, it's ok, and the code and schematic is the same.


texts:
I am building a simple security system with my Arduino Uno. I have an alarm() function:

void alarm() {
  tone(8, 3300, 200);
  delay(200);
  tone(8, 3000, 200);
  delay(200);
}

When I call it in the loop() function like so:

void loop() {
  alarm();
}

the alarm sounds fine. I just want to be able to stop it. What I mean is, I want it to start the alarm (if it is off) when I call the alarm() function, then stop it when I call the alarm() function again. How can I do this?
P.S. Can someone with over 150 reputation please make the tone tag? I can't believe it's not here!

Edit: I tried the following code, but the alarm just kept going:

bool alarmOn;
void setup() {
  pinMode(8, OUTPUT);
  alarm(true);
  delay(5000);
  alarm(false);
}

void loop() {
}

void alarm(boolean call) {
  if (call) {
    alarmOn = true;
  } else {
    alarmOn = false;
  }
  while (alarmOn) {
    tone(8, 3300, 200);
    delay(200);
    tone(8, 3000, 200);
    delay(200);
  }
}


texts: Whats the best way to keep an Arduino in a waterproof junction box and prevent overheating?

texts: I am trying to make an automatic garden gate unlock that runs on a timer. I plan on running an arduino uno 24/7 with a software timer that activates a motor to release a bolt lock. I am going to fit all the electronics and extension cord into a waterproof junction box. Will this cause over heating? Is there a need for some kind of waterproof cooling system? Has anyone ever built outdoor electronics and ran into this problem?


texts:
I'm researching options for a project in which I need to send/receive SMS messages to/from multiple users of different service providers.
Hoping to reduce costs, I'm thinking of forwarding the messages to a different SIM card, depending of the user's service provider (since all of them have plans with free SMS for numbers of the same provider).
Arduino GSM Shield seemed like a good option, except the shield has only one SIM card slot.
I wonder: would it be possible to stack 3 shields (there are 3 mayor service providers in my country) on the same Arduino Board and use some reasonably straightforward programming to handle the task?
Thanks in advance.


texts: I am interfacing Amonia Sensor RS485 output with Arduino Mega . not getting any response

texts:
I am interfacing Amonia Sensor RS485 output  with Arduino Mega but not getting any response. i need to transmit  {0x06, 0x03, 0x00, 0x00, 0x00, 0x04, 0x45, 0xBE};
frame to sensor then senor will send response frame. i am using Max485 converter which has DE RE pins .could you guide ME to write proer code. please help me i am in trouble

#include <SoftwareSerial.h>

#define SSerialRX        0
#define SSerialTX        1

#define modbusModuleDE   8
#define modbusModuleRE   9

SoftwareSerial RS485Serial(SSerialRX, SSerialTX);
byte byteSend;

//ModbusMaster node;

void setup()
{

 Serial.begin(9600);

 pinMode(modbusModuleRE , OUTPUT);
 pinMode(modbusModuleDE , OUTPUT);

  Serial.println("..... ");

  delay(10);

}

byte buf[8];
void loop()
{

     Serial.print("NH: ");
digitalWrite(modbusModuleDE, 1);
 digitalWrite(modbusModuleRE, 1);
 delay(10);
     byte request[] = {0x06, 0x03, 0x00, 0x00, 0x00, 0x04, 0x45, 0xBE};
     RS485Serial.write(request, sizeof(request));
     RS485Serial.flush();
  digitalWrite(modbusModuleDE, 0);
 digitalWrite(modbusModuleRE, 0);
 delay(10);
     RS485Serial.readBytes(buf, 8);

     Serial.print("DATA:");
    Serial.println(buf[3], HEX);Serial.println(buf[4], HEX);

    delay(1000);

}


texts:
I would like to purchase this dual H-bridge module. I plan on connecting it to an Arduino Uno. In the products datasheet the specified power supply (Vd) is 6.5-12V, and the voltage for the motor control pins is 2.3V HIGH and -0.3V LOW.

My question is whether this product is compatible with the standard 5V of Arduino Uno for both the power supply and logic; i.e. can I connect the Vd to the 5V terminal of the Arduino and the control pins to the digital terminals?

If not, what modifications do I need in order to use this H-bridge with an Arduino?

Note: Originally I bought this cheap module and connected the motor control pins to the Arduino, but each output returned a different output voltage!


texts:
Its important to mention that I'm noob.
I bought 500mw 405nm TTL module laser(5-12 volt) driver circuit. When I supplied laser with 12 volt, it turns on with max power. but when i connects laser TTL module to arduino (pin 11) in order to control turning on & off of laser through GRBL(CNC machine language) command with full power, the output of laser reduces.

"M05 S0" turns off the laser while
"M03 S255" should turns on the laser with full power as it is turning on with direct 12 volt supply, but its not happening.

so how can I make laser turn on with full power with arduino control?

Laser I,m using
https://www.amazon.in/gp/product/B071J2W7V8/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1

Laser driver circuit


texts: Seeking help - Using CJMCU 8*8 LED matrix with arduino

texts:
The CJMCU 8*8 LED board is a grid of 64 W2812 (addressable) LEDs. The board is configured as if it was one long LED strand (just a single  DIN, 5v and GND). For some flipping hair pulling reason, my code works fine on 2812 LED strands, but I get nothing on the board. Just random flickering when I jostle the 5V wire. Any ideas? Am I completely missing something here? Pretty sure the board is fine, just can't seem to take any input...

(Here's a link to the board: http://www.aliexpress.com/store/product/CJMCU-64Bit-WS2812-5050-RGB-LED-Development-Board-Built-in-RGB-Driver-White-SKU-11481/933826_32249197598.html)


texts: Converting each digit in an integer to its respective ASCII characters

texts:
For example what would be the process of converting the integer 1023 into ascii characters of

0x31 (1)
0x30 (0)
0x32 (2)
0x33 (3)

Not looking for any library functions (I know of Serial.print() and what not). I am trying to serially communicate an integer to the serial monitor, and I'd like to know what the process would be for an algorithm to take an integer and make each digit its corresponding ascii character


texts: RC servo misbehave using arduino and MPU6050

texts:
I am a beginner.. I am trying to control RC servo using Arduino based of data from MPU6050.
I am using library I2Cdev to communicate with gyro and to get yaw, pitch and roll. I am using example script which I have modified to control servo based on received data.

mpu.dmpGetQuaternion(&q, fifoBuffer);
mpu.dmpGetGravity(&gravity, &q);
mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);

Serial.print("ypr\t");
Serial.print(ypr[0] * 180 / M_PI);
Serial.print("\t");
Serial.print(ypr[1] * 180 / M_PI);
Serial.print("\t");
Serial.println(ypr[2] * 180 / M_PI);

pitch_angle = (ypr[1] * 180 / M_PI) + 90;
roll_angle = (ypr[2] * 180 / M_PI) + 90;

Serial.print(pitch_angle);
Serial.print("\t");
Serial.println(roll_angle);

pitchServo.write((int)(pitch_angle));
rollServo.write((int)(roll_angle));

Without servo being connected everything works well.
But after I plug in servo after few second being still (it seems to even follow movement of gyro) it starts to shake and then probably whole Arduino stops working (serial transmission of data stops) and Arduino has to be restarted.

100 95
ypr 12.21   10.51   5.49
100 95
ypr 12.23   10.31   5.48
100 95
ypr 12.25   10.15   5.45
100 95
ypr 12.27   10.02   5.45
100 95
ypr -13.31  30.81   55.76
120 145
ypr 20.53   -21.36  -52.59
68  37
ypr 64.96   35.38   10.25
125 100

I tried to plug two 100 nF capacitors across power and ground of the servo and I tried to connect servo in to different power source than Arduino.

EDIT:
Servo is not fixed with MPU6050 so there shouldn't be any resonance at least on the mechanical base.
Wiring is very simple:

Any idea? Thanks


texts: How to read the raw data from GY-85 module?

texts:
This module has 3 sensors. Gyroscope, Accelerometer and Magnetometer.

I think I'm reading the raw data in the wrong way.

For example, for the magnetometer HMC5883L, I'm using this code which I copied from a library and it gives the correct values, but when I use the same code for reading the raw data from the accelerometer ADXL345 then it's not what it should be according to different sources I've read.

The magnetometer HMC5883L:

void HMC5883L_print_Serial(void)
{
  int16_t x,z,y;
  uint8_t data[6];
  float heading,heading_in_degrees,declination_angle_YANBU;

  data_read(data);

  // This one doesn't
  x = data[1] << 8 | data[0];
  z = data[3] << 8 | data[2];
  y = data[5] << 8 | data[4];

  // This one works OK
  /*x = data[0] << 8 | data[1];
  z = data[2] << 8 | data[3];
  y = data[4] << 8 | data[5];*/

  heading = atan2(y,x);
  declination_angle_YANBU = ((3.0 + (52.0 / 60.0)) / (180 / M_PI));  // in yanbu city it's
  heading += declination_angle_YANBU;

  // Correct for heading < 0deg and heading > 360deg
  if (heading < 0){
    heading += 2 * PI;
  }

  if (heading > 2 * PI){
    heading -= 2 * PI;
  }

  heading_in_degrees = heading * 180 / M_PI;
  Serial.println(heading_in_degrees);
  _delay_ms(20);

}

The accelerometer ADXL345

void ADXL345_print_Serial(void){
  int16_t x,z,y;
  uint8_t data[6];

  ADXL345_read_raw(data);

  // This one gives values from -255 to +255
  x = data[1] << 8 | data[0];
  z = data[3] << 8 | data[2];
  y = data[5] << 8 | data[4];

  // This one give values from -32768 to +32768
  /*x = data[0] << 8 | data[1];
  z = data[2] << 8 | data[3];
  y = data[4] << 8 | data[5];*/
    Serial.print(x);Serial.print("\t");
    Serial.print(y);Serial.print("\t");
    Serial.println(z);
    _delay_ms(100);
}

So basically I want to learn how to work with these sensors and also I want to know the principles about each one, because I'm confused between then I feel they are the same and each one provides similar functions; like, tilt sensing.


texts: Using CLion as Arduino IDE — Cannot find Libraries

texts:
I'm having a problem using CLion as Arduino IDE when integrating 3rd-party libraries:

Here is the CMakeList.txt

cmake_minimum_required(VERSION 2.8.4)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/ArduinoToolchain.cmake)
set(PROJECT_NAME ArduinoIceCream)
project(${PROJECT_NAME})

set(${CMAKE_PROJECT_NAME}_BOARD mega)
set(${CMAKE_PROJECT_NAME}_PORT COM4)
set(mega.build.mcu atmega2560)
LINK_DIRECTORIES(C:\\Users\\Xybrek\\Documents\\Arduino\\libraries)

set(${CMAKE_PROJECT_NAME}_SKETCH ArduinoIceCream.ino)
generate_arduino_firmware(${CMAKE_PROJECT_NAME})

Here is the log:

"C:\Program Files (x86)\JetBrains\CLion 2016.3\bin\cmake\bin\cmake.exe" --build C:\Users\Xybrek\ClionProjects\ArduinoIceCream\cmake-build-debug --target upload -- -j 4
-- Generating ArduinoIceCream
-- Using C:/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-objcopy.exe for converting firmware image to hex
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Xybrek/ClionProjects/ArduinoIceCream/cmake-build-debug
[ 89%] Built target mega_CORE
Scanning dependencies of target ArduinoIceCream
[ 92%] Building CXX object CMakeFiles/ArduinoIceCream.dir/ArduinoIceCream_ArduinoIceCream.ino.cpp.obj
C:/Users/Xybrek/ClionProjects/ArduinoIceCream/ArduinoIceCream.ino:22:32: fatal error: BasicStepperDriver.h: No such file or directory
 #include "BasicStepperDriver.h"
                                ^
compilation terminated.
CMakeFiles\ArduinoIceCream.dir\build.make:65: recipe for target 'CMakeFiles/ArduinoIceCream.dir/ArduinoIceCream_ArduinoIceCream.ino.cpp.obj' failed
mingw32-make.exe[3]: *** [CMakeFiles/ArduinoIceCream.dir/ArduinoIceCream_ArduinoIceCream.ino.cpp.obj] Error 1
mingw32-make.exe[2]: *** [CMakeFiles/ArduinoIceCream.dir/all] Error 2
CMakeFiles\Makefile2:103: recipe for target 'CMakeFiles/ArduinoIceCream.dir/all' failed
mingw32-make.exe[1]: *** [CMakeFiles/upload.dir/rule] Error 2
CMakeFiles\Makefile2:211: recipe for target 'CMakeFiles/upload.dir/rule' failed
mingw32-make.exe: *** [upload] Error 2
Makefile:169: recipe for target 'upload' failed


texts: Barebones 328p, 2xAA vs 3xAA, which will last longer?

texts:
So im just running a 328p at 8mhz with the internal oscillator. Datasheet says 1.8 to 5.5v is voltage range.

Will 3xAA in series (~4.5v) last longer than 2xAA in series (~3v), assuming all batteries have the same capacity, theoretically each option should have the same mAh but does the difference in voltage affect things ?


texts: Which relay module to buy and what is the difference between 1 channel and 2 channel relay boards

texts:
I wanted to d a simple circuit using Arduino to control the lights in my house. But i do not know which relay module to use my house runs on standard 220v ac.
Can anyone tell me weather this relay board will be enough
https://www.roboelements.com/wp-content/uploads/2018/10/1-Channel-5V-Relay-Module-for-Arduino-with-Optocoupler.jpg
Or should I buy a 2 channel one?
And another thing what is the difference between 1 channel and 2 channel relay board.
I'm a complete beginner, so please help me out.


texts:
I need the Arduino to read about 100 analog inputs. Is this even doable? If not what is the maximum analog inputs I can read into the Arduino (The maximum non trivially would be to use the analog pins that the board already provides).

But can I expand those out? Thanks!!


texts:
Is possible to see what kind of baud rate a customer software is using?
I have been trying so many in my Serial.begin(), from 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600 to 115200 and I can't match the one that they are using.  Unfortunately they don't know ether.
So, I wonder if there is any way to tell the Serial.begin() to match the baud rate from the software. Any idea?
Thanks,
Sammy


texts: How to connect the 3.3v pin of arduino mega to multiple sensors

texts: I am connecting 3 accelerometers to an arduino mega. I have everything except how to connect them to the 3.3v pin. I know that I can just connect the 3 of them to the same ground pin but I have been told I can't do the same with 3.3v pin. Can anyone tell me what is the best way to power them from the arduino mega?


texts:
I wired my switch just like in the default button program. I know it works because it works fine on other pins, just not pin 18 or 19. What am I doing wrong?

const int buttonPin = 18;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
  }
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}


texts: controll intigers from webserver on nodeMCU esp8266

texts:
I would like to controll neopixel leds from over wifi with my nodeMCU but i dont know how to controll values over wifi, through a web interface would be perferable over url, but that also works.
usinf arduinoIDE for all code.


texts: How can I use Wemos D1's TX pin as OneWire?

texts:
I'm building a thermostat control with a Wemos D1 Mini. The ILI9341 display uses almost all the pins, and all I have left are the RX, TX, A0 and D0 pins. However I can't get any valid readings from these pins. According to the various wemos pinouts, I should be able to use RX/TX as onewire pins. As soon as I set the pin to a different one, and replace the wire there, I have correct readings. What am I missing with using these pins?

I'm connecting the display as stated in this arcticle: link

I also found this site which shows that I should be able to set these two pins as IO pins.

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#ifndef STASSID
#define STASSID "wifiname"
#define STAPSK  "password"
#endif

const char* ssid = STASSID;
const char* password = STAPSK;

ESP8266WebServer server(80);

OneWire oneWire(1);
DallasTemperature sensors(&oneWire);

void handleRoot() {
  sensors.requestTemperatures();
  server.send(200, "text/plain", String(sensors.getTempCByIndex(0)));
}

void setup() {
  pinMode(1, FUNCTION_3);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }

  server.on("/", handleRoot);
  server.begin();
  sensors.begin();
}

void loop() {
  server.handleClient();
}


texts: POWER_MODE_IDLE wake on any input change?

texts:
I want to be able to put an Arduino to "sleep" but I want it to immediately resume if any panel tactile buttons are pressed.

The purpose is to try to minimize any digital noise in an nearby high gain analog circuit.

My guess at this point is that I want to put the Arduino into POWER_MODE_IDLE but it is less clear to me the best way to wake up.

How can I instantly wake up from POWER_MODE_ILDE if any input changes? I don't want to have to hold down a button or even use a specific input. Is there a "catch-all" interrupt that will react immedately to a change on any or on a large set of inputs?


texts: How to extract code on one DT-06 board to another board?

texts:
I have two DT-06 boards DT06 datasheet.

The board stock firmware provides Web UI for wifi/network/serial setup. I've replaced the firmware on one board with other sketch; but now I want to revert it to the stock firmware. I cannot find the stock firmware source code anywhere. The DT-06 manufacturer also won't give it out.
Is it possible to extract the stock firmware from another DT-06 board and put it back into the other DT-06 board?
Thank you.


texts: Digital pins are no longer outputting enough to click a relay

texts:
I've been working on a project for awhile now, and I ran into a problem a week ago I couldn't solve. I'm using an Arduino uno R3.
My project involves the use of 4 relays triggered by the digital pins. Write a HIGH value, relay clicks. Write a LOW value, relay unclicks. Rather simple.
One day, I come back to it to discover it can no longer click the relays. No changes were made to my code that worked previously. The relay light came on, but no click. Could it be that I sent HIGH to 4 at the same time? My theory is that I could've drawn too much power at the same time, weakening it in a way that causes it to not output as much as it did previously.
I tested a relay on a different board and it works perfectly fine.


texts:
Is there any way to make sounds using an Arduino without using the tone function?
It must be possible via this new method to control frequency of sound.


texts:
I'm trying to get a HC-05 connected as master to a Bluetooth ELM327 OBD scanner.

The HC-05 is accepting AT commands, no problem. This is the sequence I use:

AT+RMAAD    (Clear any paired devices)
AT+ORGL     (Set factory defaults)
AT+ROLE=1   (Set role to master)
AT+RESET    (reset needed after role change)

AT+CMODE=0  (allows connection to any device)
AT+INQM=0,5,9   (set inquiry to search for up to 5 devices for 9 seconds)
AT+INIT     (Inits BT)
AT+INQ      (searches for BT devices)

AT+PAIR=1D,A5,68988A,9  (Pairs to the address of the ELM327, timeout in 9 secs)
AT+BIND=1D,A5,68988A    (Binds the address)
AT+CMODE=1      (HC-05 will now only connect with the paired device)
AT+LINK=1D,A5,68988A    (Connect to device)

Everything is fine, until the last step: AT+LINK.
What happens is:

>at+link=1D,A5,68988A
FAIL
+INQ:1D:A5:68988A,1F00,7FFF
OK

So it fails the AT+LINK, then for some reason, it starts inquiry mode.
I saw a guide which had CMODE=1/0 swapped. I have tried both, anyway, doesn't make any difference to the result. I should be in full AT command mode, I connected 3.3v to pin 34. The password for the ELM327 is 1234, and the default password for the HC-05 is 1234.

If I skip the link stage, then re-power the HC-05 in comms mode, then the ELM327 flashes its green LED which means its transmitting. The HC-05 flashes rapidly, then slowly, then rapidly, then slowly, and so on. But I get nothing in the serial monitor, not even garbled text.

This is the OBD reader I have

This is the HC-05 I have

So I don't know what the problem is, I have connected the HC-05 to my phone as a slave, and can send messages to and from it though the serial monitor. So its working. And the ELM327 is working fine when connected to my phone. So both are working fine.

So my guess is, either I'm missing something, like, maybe the outgoing password/pin is set with a different AT Command other than AT+PSWD? Or, maybe this particular HC-05 for some reason isn't capable of master mode? Or maybe the ELM327 I have for some reason will never accept a connection from something other than an android phone?

I just wondered if anyone has some experience with this, and can advise, before I go off and buy another HC-05 and another ELM327. Thanks in advance for any help.

Just for more information, I'm using an ESP32, which I know has bluetooth and I wanted to use it, but I couldn't find how to enter it's AT Commands (at least, not easily), it was just easier to buy a HC-05. So since the ESP32 has 3.3v outputs I don't use a voltage divider. I use the 5V out for the VCC on the HC-05, and I use the 3.3v out to go directly to pin 34. Here's the sketch I use to enter AT Commands:

#include "HardwareSerial.h"
#define RXD2 16                //Arduino pin connected to Tx of HC-05
#define TXD2 17                //Arduino pin connected to Rx of HC-05

HardwareSerial BTSerial(2);

char c=' ';
boolean NL = true;

void setup()
{
  // initialize the 2 serial ports:
  Serial.begin(38400);  //For the arduino to communicate with the PC
  Serial.print("Sketch:   ");   Serial.println(__FILE__);
  Serial.print("Uploaded: ");   Serial.println(__DATE__);
  Serial.println(" ");

  BTSerial.begin(38400, SERIAL_8N1, RXD2, TXD2); //-> HC-05 AT mode baud rate is 38400
  Serial.println("BTserial started at 38400");
  Serial.println(" ");
}

void loop() {

  // Read from the Bluetooth module and send to the Arduino Serial Monitor
  if (BTSerial.available()) {
    c = BTSerial.read();
    Serial.write(c);
   }

  // Read from the Serial Monitor and send to the Bluetooth module
  if (Serial.available()) {
    c = Serial.read();
    BTSerial.write(c);

    // Echo the user input to the main window. The ">" character indicates the user entered text.
    if (NL) { Serial.print(">");  NL = false; }
    Serial.write(c);
    if (c==10) { NL = true; }
  }
}


texts: How to avoid two arduino components using the same digital PIN

texts:
I'm trying to build an Arduino project where it involves a TFT and an ethernet W5500 component.
Here's the project I want to build to learn Arduino. However I wanted to change the board that already has an ethernet PoE here. The TFT I plan to use is a shield. It seems that pin D10 are being used by both components.
Is it possible through software to use a different Digital pin through software for either the board or the TFT display?  I have read where users are cutting traces and using jumper wires - would that be required in my case? I am planning on using SPI pins if possible. Thanks!


texts: On my board, there are 12 (2 groups of 6, each group consistent of 3 rows of 2 pins) weird male header pins. What are these, and how would you use them?


texts: How to perform action if two rfid tag UIDs have been detected?

texts:
I'm using an rfid-rc522 and I want to print to the serial a string of text if two rfid tags have been read in a given time period.

Essentially this:
 1. First tag is read (print to serial: Tag 1 has been read)
 2. Wait 2 seconds
 3. Second tag is read (print to serial: Tag 2 has been read)
 4. Print to serial: Tag 1 and Tag 2 has been read)
 5. Bonus: Keep this state - and then when a button is pressed (print to serial: Tag 1 and Tag 2 are finished)

I know how to read the UID and print to the serial if one is read.
Thank you so much for your help, it's greatly appreciated.

Here is my code so far:

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>
#include <MFRC522.h>

// For the breakout, you can use any 2 or 3 pins
// These pins will also work for the 1.8" TFT shield
#define sclk 4  // SainSmart: SCL
#define mosi 5  // SainSmart: SDA
#define cs   6  // SainSmart: CS
#define dc   7  // SainSmart: RS/DC
#define rst  8  // SainSmart: RES

Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, mosi, sclk, rst);

#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);

float p = 3.1415926;

void setup(void) {
  Serial.begin(9600);
  SPI.begin();
  Serial.print("Starting cornhole leaderboard...");
  mfrc522.PCD_Init(); // Init MFRC522 card
  Serial.println("Scan PICC to see UID and type...");
  // Use this initializer if you're using a 1.8" TFT
  tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab

  // Use this initializer (uncomment) if you're using a 1.44" TFT
  //tft.initR(INITR_144GREENTAB);   // initialize a ST7735S chip, black tab

  Serial.println("Initialized");

  uint16_t time = millis();
  tft.fillScreen(ST7735_BLACK);
  time = millis() - time;

  Serial.println(time, DEC);

  // large block of text
  tft.fillScreen(ST7735_BLACK);
}

void loop() {

  // Look for new cards
    if ( ! mfrc522.PICC_IsNewCardPresent()) {
        return;
    }

    // Select one of the cards
    if ( ! mfrc522.PICC_ReadCardSerial()) {
        return;
    }

    if (mfrc522.uid.uidByte[0] == 0xA4 &&
       mfrc522.uid.uidByte[1] == 0xB8 &&
       mfrc522.uid.uidByte[2] == 0xB8 &&
       mfrc522.uid.uidByte[3] == 0x96) {
          Serial.println("Nate has checked in to the game.");
          tft.fillScreen(ST7735_BLUE);
          tft.setTextSize(2);
          tft.setCursor(0, 0);
          tft.setTextColor(ST7735_YELLOW);
          tft.print("Nate ");
          tft.setTextColor(ST7735_WHITE);
          tft.println("has checked in ");
          tft.setTextSize(2);
          tft.println("to the game.");
          delay(2000);
          tft.fillScreen(ST7735_BLACK);
    }

    if (mfrc522.uid.uidByte[0] == 0x03 &&
       mfrc522.uid.uidByte[1] == 0xFD &&
       mfrc522.uid.uidByte[2] == 0xBC &&
       mfrc522.uid.uidByte[3] == 0x02) {
          Serial.println("Ted has checked in to the game.");
          tft.fillScreen(ST7735_RED);
          tft.setTextSize(2);
          tft.setCursor(0, 0);
          tft.setTextColor(ST7735_CYAN);
          tft.print("Ted ");
          tft.setTextColor(ST7735_WHITE);
          tft.println("has checked in ");
          tft.setTextSize(2);
          tft.println("to the game.");
          delay(2000);
          tft.fillScreen(ST7735_BLACK);

    }

}


texts: How to upload file from SD card by Micro SD adapter to ftp server using Filezilla?

texts:
I use Arduino Mega 2560 to send a file stored in a micro sd by a module "Micro SD adapter" to ftp server. I use the sim800l evb v2.0 module and I proceeded as follows:

I insert the AT command :

AT+SAPBR=3,1,"CONTYPE","GPRS"

AT+SAPBR=3,1,"APN","internet"

AT+SAPBR=1,1

AT+FTPCID=1

AT+FTPTYPE="I"

AT+FTPMODE=0

AT+FTPSERV="197.158.86.105"

AT+FTPPORT=42

AT+FTPUN="user"

AT+FTPPW="password"

AT+FTPPUTNAME="test.txt"

AT+FTPPUTPATH="/"

AT+FTPPUT=1

Results :

+FTPPUT:1,62

sometimes +FTPPUT:1,63
or +FTPPUT:1,64
or +FTPPUT:1,65
or +FTPPUT:1,78

what do I have to do. Please, can anyone help me? thank you


texts: door protector using arduino uno and GSM sim800 module

texts:
Please check the arduino program given below and help me to find out error. The program is for following hardware. GSM 800 module Arduino Uno board Limit switch(2)

We place two limit switch at main door & back door as main door is open the message will be send that is Main door is open & when it closed it will send message Main door is closed. This is same for Back door also.

We run this program & it run but it sends the massage repeatedly after some time. Please help me to find out error..

    const int Main = 7;
    const int Store = 8;
    const int Main_led =  13;
    const int Store_led =  14;
    bool i = false;
    bool j = false;
    bool k = false;
    bool l = false;
    int buttonState1 = 0;
    int buttonState2 = 0;
    void setup() {

      Serial.begin(9600);
      pinMode(Main_led, OUTPUT);
      pinMode(Store_led, OUTPUT);
      pinMode(Main, INPUT);
      pinMode(Store, INPUT);
    }

    void loop() {
      buttonState1 = digitalRead(Main);
      if (buttonState1 == HIGH && i == false ) {
        digitalWrite(Main_led, HIGH);
        Serial.println("OK");
        delay(1000);
        Serial.print("AT+CMGF=1\r\n");
        delay(500);
        Serial.print("AT+CMGS=\"+91-------------");
        Serial.print("\"\r\n");
        delay(5000);
        Serial.print("Main Door is closed");
        Serial.write(0x1A);
        delay(5000);
        i = true;
        j = false;
      }
      else
      { if (buttonState1 == LOW && j == false )

        { digitalWrite(Main_led, LOW);
          Serial.println("OK");
          delay(1000);
          Serial.print("AT+CMGF=1\r\n");
          delay(500);
          Serial.print("AT+CMGS=\"");
          Serial.print("+91---------------");
          Serial.print("\"\r\n");
          delay(5000);
          Serial.print("Main Door is open");
          Serial.write(0x1A);
          delay(5000);
          i = false;
          j = true;
        }
      }

      buttonState2 = digitalRead(Store);
      if (buttonState2 == HIGH && k == false) {

        digitalWrite(Store_led, HIGH);
        Serial.println("OK");
        delay(1000);
        Serial.print("AT+CMGF=1\r\n");
        delay(500);
        Serial.print("AT+CMGS=\"");
        Serial.print("+91-------------");
        Serial.print("\"\r\n");
        delay(5000);
        Serial.print("Store room is Closed");
        Serial.write(0x1A);
        delay(5000);
        k = true;
        l = false;
      }
      else
      { if (buttonState2 == LOW && l == false)
        {
          digitalWrite(Store_led, LOW);
          Serial.println("OK");
          delay(1000);
          Serial.print("AT+CMGF=1\r\n");
          delay(500);
          Serial.print("AT+CMGS=\"");
          Serial.print("+91------------------");
          Serial.print("\"\r\n");
          delay(5000);
          Serial.print("Store room is Open");
          Serial.write(0x1A);
          delay(5000);
          k = false;
          l = true;
        }
      }
    }


texts: Arduino as Slave to Return Multiple Values

texts:
I'm having trouble trying to get my two Arduino Unos to communicate with each other over i2c. I'm trying to have the master request for analog values from the slave by sending a request to the slave device for one of the six ADC pin values.

Master Code

#include <Wire.h>

void setup()
{
  Wire.begin();
  Serial.begin(115200);
}

void loop()
{
  Wire.beginTransmission(0x22); // Start communication with Arduino slave at address 0x22

  for(byte i=0;i<4;i++)
  {
    Wire.write(i);              // Request data from analog pin 'i'
    delay(5);                   // Give the slave a moment to sample ADC and respond
    while(Wire.available())
    {
      byte c = Wire.read();
      Serial.println(c);        // Print returned value to serial window
    }
  }

  Wire.endTransmission();       // End communication with Arduino slave
  delay(500);
}

Slave Code

#include <Wire.h>

void setup() {
  Wire.begin(0x22);
  Wire.onReceive(receivedHandler);
}

void loop() {
}

void receivedHandler() {
  byte data = Wire.read();
  byte analogValue;

  if(data == 0) analogValue = analogRead(A0)>>2;
  else if(data == 1) analogValue = analogRead(A1)>>2;
  else if(data == 2) analogValue = analogRead(A2)>>2;
  else if(data == 3) analogValue = analogRead(A3)>>2;
  else analogValue = 0;

  Wire.write(analogValue);
}

I can see that the data is being received by the slave, but the slave is not sending any data back, so I'm a bit confused how to send data back to the master. For the master there is "Wire.requestFrom(address, num of bytes)" to request a specific number of bytes, and for the slave "Wire.onRequest()" which will call a handler function to send back the number of bytes requested by the master, but for my application I won't be able to return more than 1 byte at a time.


texts:
I have just received inkshield purchased from Nerd Creation Labs, I stacked inkshield on my Arduino Mega and uploaded THIS CODE provided by the creator of inkshield,and it works pretty well.
I can print text ;)

Questions :

1: The code given above can only print text in a single Font. Can i add multiple Fonts in a single code.?

2: How can i change the Font to something like Times New Roman, Arial,calibri or more stylish Fonts like snell RoundHand and Zapfino.?

Please help

Thank you