texts: Why does an Arduino UNO need two GND ports?

texts:
I have really bad eyesight, so whenever I plug in the power wire and the GND wire I always double check if I'm actually plugging in to the power port not one of the two GND ports.

Why does an Arduino UNO have two GND ports, and for what application would one use both of them?


texts: Getting a binary string and convert it to decimal

texts:
I have a 4 dipswitch to get a 1 or a 0, try to get that into a string and from that get a decimal, therefor if I get for example a 0011 a 3.

so, I know that from the variations of 0000 to 1111 is a decimal from 0 to 15, I already have my string but how do I convert the "binary string" to decimal?

to get the string I'm using this (the I is at 5because there is where is the dipswitch):

      for(int i = 5; i <= 9; i++){
           Serial.println(digitalRead(i));
           Dstate = Dstate + digitalRead(i);
      }


texts: I am working on a simple Arduino project where I am controlling 5 TowerPro servos. I read that each takes up 2.2 V each so that means the Arduino can only handle about 2 , if using 5V. So far Ive connected 4 with no issues but when I added the 5th the whole thing stopped and the 5V regulator was really hot. That means I don't have enough power and the Arduino is just having a hard time giving not enought volts for all five servos. I just don't know what to do now. Ive tried adding 3  3V battery packs instead of the Arduino but it was smoking. Is there another way to provide the right amount of power for 5 servos without breaking or burning anything!


texts: Arduino Clock Speed effect on Stepper Speed

texts:
I am running a Pololu A4988 Stepper driver with two (soon to be three) steppers using the AccelStepper library. I have wired 1/8th microstepping on both as smooth running is important.

The motors run fine however, when running simultaneously, if Stepper 1 finishes its move before the Stepper 2, there is a marked increase in speed in the Stepper 2 (evident audibly and visually).

The code I use to run the motors is:

void MoveAccelXY(int Xm, int Ym) // function 6
{
  X_Axis.moveTo(Xm);
  Y_Axis.moveTo(Ym);
  while(X_Axis.distanceToGo() !=0 || Y_Axis.distanceToGo() !=0)
  {
    X_Axis.run();
    Y_Axis.run();
  }
  Xpos = X_Axis.currentPosition();
  Ypos = Y_Axis.currentPosition();
  Serial.print("X" + Xpos);
  delay(50);
  Serial.print("Y" + Ypos);
  delay(50);
  Serial.print("C");
}

I would like there to be no speed drop on any steppers. Increasing the input voltage does not have an effect.

Is the Arduino clock speed the culprit?


texts:
I made an arduino nano IR sensor based auto liquid dispenser. Currently it is being powered by a 12V 2 amps adapter. The 12v adapter is connected to a LM2596 DC to DC buck converter which converts the 12V to 5V and powers the arduino, IR sensor and a regular green LED. Also I am using a RO valve solenoid (rated upto 24V DC) which is being powered by the 12V adapter. So whenever the IR sensor is triggered, the DC motor (5V 200mA) and solenoid (12V 300-500mA) are turned on for 3 seconds.

Now, I intend to power this system via batteries. I am considering the following 3 options.

a.) Lithium batteries in series (4 of 3.7V batteries). But again here I believe things would be complex as I have to make a BMS and charger for this. Is anything available off the shelf so that I can directly integrate the battery and charger with my existing system ?

b.) Connect 8 AAA batteries in series to get 12V. But how long would these batteries last for my application ?

c.) Connect 2 9V batteries in series. Again, can you guys please tell me how long these may last in the system.

Arduino nano I believe consumes 20mA and the IR sensor probably around another 10- 20mA.
If it wasnt for the solenoid, I was considering connecting a mobile power bank to power the system.


texts: Usbasp Arduino Uno Bootloader Flash Error - Win 10

texts:
I'm trying to flash an Arduino Uno using usbasp but i'm getting the following error,I have checked all the connection and voltage using multimeter but still this error:

Arduino: 1.8.8 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Users\SillyMonster\Desktop\arduino-1.8.8\hardware\tools\avr/bin/avrdude -CC:\Users\SillyMonster\Desktop\arduino-1.8.8\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cusbasp -Pusb -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m

avrdude: Version 6.3-20171130
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\SillyMonster\Desktop\arduino-1.8.8\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : usb
         Using Programmer              : usbasp
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : usbasp
         Description     : USBasp, http://www.fischl.de/usbasp/

avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: error: program enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude done.  Thank you.

Error while burning bootloader.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I have tried different three other Usbasp but still same error


texts:
Just this general question.As the titles says.

How does Arduino decide when to go into flashing mode and normal mode?

Is it by connecting certain pins to ground,so it's a hardware check or does it have to do with the code?

Other similar arduino like products such as the esp8266 work the same way as long as they use the same chip?


texts:
I am having issues getting the main program to run after flashing via BOSSA with a bootloader. Jump to the bottom for my question and TL;DR.

Here is my current situation:

UF2 bootloader successfully compiled for SAMD21G18A
Bootloader flashed with ATMEL ICE and runs correctly upon reset
Device shows up as external storage and also as a CDC device in BOSSA
Flashed a hex file successfully in BOSSA (with offset applied) and then reset device
Program on hex file doesn't ever run

The program is just the Arduino "Blink" example, converted to an AtmelStudio solution. The linker script has been modified to have the origin at 0x2000 (as expected by the bootloader).

Other things I've tried to no avail:

a variety of offsets
many different bootloaders of CDC and MSD variants
uploading the compiled program with the Arduino IDE, BOSSA, AtmelStudio etc

Other points worth noting:

The AtmelStudio solution contains two projects as is standard when importing an Arduino sketch. 1) ArduinoCore 2) Blink
LEDs on my board work as expected (breathing to indicate in the bootloader)
When I import the Arduino sketch into AtmelStudio and flash it to the device the device mounts as a CDC device (via the native USB port) to my computer. I don't know why this is happening as the linker script doesn't include any provisions for a bootloader and the program itself doesn't instruct the hardware to enable the USB port. I have no idea why this is happening.
it seems like the bootloader never detects a program as it always runs upon startup. This is the behaviour when a program cannot be found.
The .hex file generated by the Arduino IDE doesn't ever launch either
If flashed from Arduino IDE or AtmelStudio directly the program does run

TL;DR:
Known working main program/sketch never gets run with bootloader on SAMD21G18A.

My question:
What would cause the bootloader to not find the main program and hence never run it?

Any other insights as to why I have not had any success here would be greatly appreciated too. My suspicions are that this has something to do with the way the main program is being compiled and linked.

Cheers!


texts: Does a normal Ultra-Sonic sensor (HC SR04) sense through a Football Net like obstacle?

texts: I am planning to to use ultrasonic sensors mounted on a drone for obstacle avoidance. I am not sure if the sensors would be capable of detecting a Net Like obstacle in its path.


texts:
I have a boolean expression (I think it's called), and it will always return false after 32 seconds of running, and I'm very confused now.

if (millis() > stepTime+lightCmd[stepe][5]) {
  stepe = (stepe+1)%STEPS; //I'm bad at naming variables, sorry
  stepTime = millis();
  Serial.println("changing"); // debugging
}

This runs inside the main loop.

Also, I've tried using an exponent when trying to get some lights to appear to fade linearly and in about the same amount of time, 32 seconds, it would start fading in reverse.

EDIT:

millis(); wouldn't go backwards after it stopped working


texts: How to test Arduino behaviour on Windows?

texts:
Hello fellow Arduino enthusiasts,

I created an Arduino project for a Mega2560 board in Microsoft Visual Studio.
Before loading the code on the board I want to test it on my Windows desktop computer.

I'd like to automatically provide input (e.g. with a file containing some values) for the 4 hardware Serials as well as the I2C/Wire bus and check their output for validity.
How can one achieve that?

I read about mocking (e.g. "Arduino-mock") but this does not seem to be what I need since it is more a way of ignoring the absence of object implementations.
Are there maybe some simulators that can automatically generate input and create output logs or even check the output?

Thank you for any advice!


texts: Which timer does Arduino Nano use for each PWM pin?

texts:
I'm unable to find which Timer controls each PWM pin (3, 5, 6, 9, 10 and 11) in an Arduino Nano Board (ATmega328).
Any guesses?

Thanks in advance,

Eduardo


texts: All voltage directed to pin 3 when multiple pins are set to out put

texts:
I just finished testing a haptic device at university, and when I took it home I got the joy of finding the device not working. Here's what I can trace the problem to: when multiple pins are set to output (pin 2~11), pin 3 writes constantly to high and there is nothing I can do to make it stop.

Using a blinker program one pin at a time produces no problems, however when I run a blinker program that cycles through all pins, pin 3 is set to constant high. My actual code is similar in function but more complex. This program below though gets the same error.

void setup()
{
  for (int c =2; c<12; c++){
    pinMode(c, OUTPUT);
  }
}

void loop()
{
  for (int c =2; c<12 ; c++){
     digitalWrite(c, HIGH);
     delay(100);
     digitalWrite(c, LOW);
     delay(100);
  }
}

Is this a sign my arduino died? My device had been working for weeks on my prior code with no problem (and no updates).


texts: Atmega328P-PU: Programmer is not responding

texts:
Few days ago, I built my own custom Arduino on the breadboard. It is built according to tutorial on http://www.crash-bang.com/resource/breadboard-arduino/. The Atmega328P-PU is already burned with the Arduino bootloader with simple blink sketch.

For the programmer, I decided to use the Arduino USB2Serial. Again, it is connected as shown on crash-bang site. Problem is I get this error when uploading a different sketch:

avrdude -Cavrdude.conf -v -patmega328p -carduino -PCOM3 -b115200 -D -Uflash:w:build244630154737317489.tmp/sketch_may23a.cpp.hex:i

avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
     Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
     Copyright (c) 2007-2009 Joerg Wunsch

     System wide configuration file is "avrdude.conf"

     Using Port                    : COM3
     Using Programmer              : arduino
     Overriding Baud Rate          : 115200
     AVR Part                      : ATmega328P
     Chip Erase delay              : 9000 us
     PAGEL                         : PD7
     BS2                           : PC2
     RESET disposition             : dedicated
     RETRY pulse                   : SCK
     serial program mode           : yes
     parallel program mode         : yes
     Timeout                       : 200
     StabDelay                     : 100
     CmdexeDelay                   : 25
     SyncLoops                     : 32
     ByteDelay                     : 0
     PollIndex                     : 3
     PollValue                     : 0x53
     Memory Detail                 :

                              Block Poll               Page                       Polled
       Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
       ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
       eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
       flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
       lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
       hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
       efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
       lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
       calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

     Programmer Type : Arduino
     Description     : Arduino
     Hardware Version: 3
     Firmware Version: 4.4
     Vtarget         : 0.3 V
     Varef           : 0.3 V
     Oscillator      : 28.800 kHz
     SCK period      : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f
avrdude: reading input file "build244630154737317489.tmp/sketch_may23a.cpp.hex"
avrdude: writing flash (450 bytes):

Writing | avrdude: stk500_recv(): programmer is not responding

Most of the time I do not even get to this point and just end up with something like:

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xf5

What I have done so far:

I already tried to reset Arduino just before uploading the sketch.
According to the avrdude, bootloader is fine.
Reinstalled drivers, Arduino IDE
Changed the USB cable and connected it to another USB slot
Burned new bootloader using ArduinoISP

Thank you for help.


texts: How do I reduce this down to a smaller, more permanent prototype?

texts:
I've prototyped a little light/sunrise alarm clock w/ an Arduino Uno and a breadboard. How do I go about figuring out what components I'd need to reduce this down in to a more semi-permanent prototype?

Obviously I don't need everything the Uno has to offer and I'd like to slim this down into a custom box I build.

But what sort of microcontroller(s) would I need to size this down? How else can I simplify it?

To be clear, I'm not trying to turn this in to any sort of finished/super-polished product. Just wanting to get out of the breadboard and in to some soldering of something a bit more set in stone.


texts: Detecting distance moved by accelerometer?

texts: I have an accelerometer connected to an Arduino Uno board, is there a way I can detect the distance it this accelerometer moved on each of the 3 axis?


texts:
I'm creating a LCD frequency generator.

When TIMER1 reaches a set value, it's set to toggle Pin 9 (via OC1A).

Accidentally, I left the TIMER1 "interrupt on compare match A" enabled, but never defined the TIMER1_COMPA_vect interrupt vector.

This made the Uno reset itself - but not running through the bootloader, just the program part - whenever TIMER1_COMPA_vect would've been called.

Once I defined the ISR, even without it having any content, it would run as expected.

Is there a default content for ISRs, which resets the device / starts just after the bootloader? Shouldn't the compiler detect a completely missing ISR?


texts: Rescuing an Arduino With a Broken Setup()

texts:
I may have bricked my Arduino Pro Micro by writing a broken code into the setup() function. When I plug my Pro Micro into my PC, I see it register a COM port for a brief moment before it disappears. Grounding and ungrounding the RST pin causes the device to appear in my control panel again for a brief moment. Attempting to upload the blink example from the Arduino IDE fails, since the COM port disappears before the process can complete.

Is there an alternate way of flashing code to the arduino which I could possibly use to fix this? I have a working Pro Nano I could use if needed.


texts:
I'm trying to send data using these cheap parts.
When I check the voltage on the data port of the transmitter, I see what I expect, 1.2 and 0.6 fluctuating while sending.
But when I check the receiver I get 0. I've got 3 of the sets and tried them all. Also tried it with running the transmitter on 11V for some extra power. I've added a LED to the transmitter to see when it transmits and I've added a not-so-good antenna to both while they are only 5cm apart during my tests.

Any advice would be appreciated.

Receiver
FS1000A with a LR433A

#include <VirtualWire.h>

const int led_pin = 6;
//const int transmit_pin = 12;
const int receive_pin = 11;
//const int transmit_en_pin = 3;

void setup()
{
    delay(1000);
    Serial.begin(9600);  // Debugging only
    Serial.println("setup");

    // Initialise the IO and ISR
    //vw_set_tx_pin(transmit_pin);
    vw_set_rx_pin(receive_pin);
    //vw_set_ptt_pin(transmit_en_pin);
    //vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(1000);  // Bits per sec

    vw_rx_start();       // Start the receiver PLL running
}

void loop()
{
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
  int i;

        digitalWrite(led_pin, HIGH); // Flash a light to show received good message
  // Message with a good checksum received, print it.
  Serial.print("Got: ");

  for (i = 0; i < buflen; i++)
  {
      Serial.print(buf[i], HEX);
      Serial.print(' ');
  }
  Serial.println();
        digitalWrite(led_pin, LOW);
    }
}

Transmitter

#include <VirtualWire.h>

const int led_pin = 11;
const int transmit_pin = 12;
const int receive_pin = 2;
const int transmit_en_pin = 3;

void setup()
{
  // Initialise the IO and ISR
  vw_set_tx_pin(transmit_pin);
  vw_set_rx_pin(receive_pin);
  vw_set_ptt_pin(transmit_en_pin);
  vw_set_ptt_inverted(true); // Required for DR3100
  vw_setup(1000);   // Bits per sec
}

byte count = 1;

void loop()
{
  char msg[7] = {'h','e','l','l','o',' ','#'};
  Serial.println("sending");
  msg[6] = count;
  digitalWrite(led_pin, HIGH); // Flash a light to show transmitting
  vw_send((uint8_t *)msg, 7);
  vw_wait_tx(); // Wait until the whole message is gone
  digitalWrite(led_pin, LOW);
  delay(1000);
  count = count + 1;
}


texts:
I am making a fire fighting robot and I need a sensor. I want the sensor detection range to be about 6m or 7m (about 18ft to 20ft).

The question is which sensor should I choose to get that detection range? I've found that some small IR sensors are not suitable for my range required.

I'm making a simulated one. It might be confused if there are non-fire distractions so I'm asking for a technique that can improve the sensor range and determination very very effective... or which sensor should I choose??

I don't want the IR sensor to be more directional. If I need it to be more directional I can use 2 or 3 or more. It is no problem. I want the IR sensors to improve their detection range. I can only get 2m now. I want it to be about 4m or 5m.


texts: PubSubClient: Subscription working, but callback never called

texts:
I am using an ESP32 (https://heltec.org/project/wifi-kit-32/) with a AM2302 DHT22 and an LDR, talking to mosquitto on a Linux box.  Publishing data is working fine, other than the "exceeded timeout, disconnecting" lots of people seem to be having.  However, when a message is sent from another client to a topic I am subscribed to, my callback is never called, so I can't consume it.
In my reconnect function, I have
    boolean success = mqttClient.subscribe("sensors/basement/led");
    Serial.print("Subscribe returned ");
    Serial.println(success);

and it does return 1 which I believe is success (usually success is zero but I don't think that's the case here).  I also see the subscription in my mosquitto logs, which are currently cranked up to debug.
1610417274: New client connected from XXX.XXX.XXX.XXX as Basement1 (c1, k15, u'XXXXXXXXX').
1610417274: Sending CONNACK to Basement1 (0, 0)
1610417275: Received SUBSCRIBE from Basement1
1610417275:     sensors/basement/led (QoS 0)
1610417275: Basement1 0 sensors/basement/led
1610417275: Sending SUBACK to Basement1

When I send data to sensors/basement/led from the other client (mqttdash), the server receives it, and sends it to mqttdash, as well as Basement1, which is my ESP32:
It's definitely sending the message to the ESP32:
1610417546: mqttdash-3785c5ce 0 sensors/basement/led
1610417546: Sending SUBACK to mqttdash-3785c5ce
1610417578: Received PUBLISH from mqttdash-3785c5ce (d0, q0, r0, m0, 'sensors/basement/led', ... (1 bytes))
1610417578: Sending PUBLISH to Basement1 (d0, q0, r0, m0, 'sensors/basement/led', ... (1 bytes))
1610417578: Sending PUBLISH to mqttdash-3785c5ce (d0, q0, r0, m0, 'sensors/basement/led', ... (1 bytes))

However, my callback is never called.  Here is the setup of the callback:
WiFiClient espClient;
PubSubClient mqttClient(espClient);
...
void setupMQTT()
{
    mqttClient.setServer(MQTT_HOST, MQTT_PORT);
    mqttClient.setCallback(mqttSubHandler);
    mqttConnect();
}
...
void mqttSubHandler(char *topic, byte *message, unsigned int length)
{
    Serial.print("Message arrived on topic: '");
    Serial.print(topic);
    Serial.print("'. Message: ");
    String messageTemp;

    for (int i = 0; i < length; i++)
    {
        Serial.print((char)message[i]);
        messageTemp += (char)message[i];
    }
    Serial.println();
...

Full code at https://github.com/djsegfault/arduino/blob/master/basement_monitor/basement_monitor.ino
Does anyone know why the callback is not being called?  Thanks in advance.


texts:
I have to input 5 words and organize.
In order to organize words, I have to get them into Array of String to compare.
I succeed to get char[buffer] into String in_str but somehow in_str doesn't
get into str[5].
is String str[i]=in_str;  Wrong?? How can I put in_str to Array of String str??

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

void loop() {
  int state = 1, len = 0 ,i=0, k=1;
  char buffer[128];
  String str[5];
  while (true) {
    if (state == 1) {
      Serial.print("Enter the ");
      Serial.print(k);
      Serial.print("th Word --> ");
      state = 2;
    }
    while (Serial.available()) {
      char data = Serial.read();
      if (data == '\n') {
        buffer[len] = '\0';
        String in_str = buffer;
        String str[i]=in_str;
        Serial.println(in_str);

        i=i+1;
        k=k+1;
        len = 0;
        if(i>4){state = 3; }
        else {state = 1;}
        break;
      }
      buffer[len++] = data;
    }
  if(state==3){
    Serial.println("After Sorting");
   for (int i = 0; i < 4; i++) {
    for (int j = i + 1; j < 5; j++) {
      int compare = str[i].compareTo(str[j]);
      if (compare > 0) {         String temp = str[i];
        str[i] = str[j];
        str[j] = temp;
      }
    }
  }

   for (int i = 0; i < 5; i++) {
    Serial.println(String(i) + " : " + str[i]);
  }

    break;
  }

  }
}


texts:
It's the first time I use an ESP8266 and I didn't manage to get a proper response in the Arduino serial monitor. I only see weird characters, when I move the 3.3V wire.

You can see the connections in the following picture:

The code I run is the following one:

#include <SoftwareSerial.h>
SoftwareSerial BT1(3, 2); // RX | TX

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

void loop()
{
    String B= ".";
    if (BT1.available())
    {
        char c = BT1.read();
        Serial.print(c);
    }
    if (Serial.available())
    {
        char c = Serial.read();
        BT1.print(c);
    }
}

Maybe it's something really stupid. I am a total beginner, so I appreciate any help.

EDIT: I think power supply is 3.3V

SOLUTION: the problem was the power supply. I tried exactly the same using the 3.3V from the arduino instead of the power supply and it works perfectly!


texts: How do you use the plastic cover/case that came with Arduino?

texts: They have holes for screw on, on top of the holes on the Arduino itself. Where can I find parts that are compatible with this case/cover? What was the intended use of this case/cover? Thanks.


texts: How to make watchdog and automatically reset on esp8266

texts:
When my system is confronting at logical & hardwaretical problem,
I want to make system know It has some problem and reset automatically
because my esp8266(nodeMCU) is on the place where people usually cannot touch.

so I apply this 'ticker' code, but I think they are not working when it is on  problem status.

please see my code and give me some advice that how to make system know the problem status and do reset automatically.

//these are global values
Ticker ticker;
volatile unsigned int ISRcounter = 0;

void setup(){

ticker.attach(2,ISRdog);
//ticker always give Interrupt every 2 second.
//and when it get Interrupt, ISRdog function is called.
}

void ISRdog() {
  ISRcounter += 1;
//when ISR is called, ISRcounter is ++.

  if (ISRcounter == 10) {
    ESP.deepSleep(5e5); //reset
//and when it is 10, deepSleep for 5second and automatically wakeup.
//so it means, 'system reset'

  }

}

void loop(){

ISRcounter=0;
//when program running properly, system's flow always go to loop in final.
//so at the loop, make ISRcounter =0, for not making the system reset(ISRcounter==10)

.....
}

...and other functions ....

In short, this code is making reset until the system is not entering the  loop() over 20second.

so I expect when system get problem somehow, then system do not enter to the loop() and It means ISRcounter is getting 10, without =0. so system should be resetted.
but It did not worked. did not automatically resetted.


texts: Send data from an Arduino to a computer in another country

texts: I was wondering if it is possible to send data captured with an Arduino (video footage, gps location, ...) to a computer that is far away (in another country) wirelessly? Is this possible with a a WiFi-module? Would it consume a lot of energy (transmission frequency would be low)?


texts:
I've got an Arduino Micro, and a MAX4466 ECM / AMP breakout board (https://www.adafruit.com/product/1063). I'm powering the Arduino Micro from the USB port.

On the MAX4466 (to the Arduino), I've wired VCC to 3.3v, GND to GND, and OUT to A0. I've also wired 3.3v to AREF.

Using the following code, I'm noticing significant noise spikes on the output, as shown in the graph below.

I'm not entirely sure what I've done wrong here, and would appreciate any input / criticism that could lead to getting a clean signal.

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

void loop()
{
   Serial.println(analogRead(0));
}


texts: Send HTTP get request from GSM SIM800c and Arduino

texts:
I am trying to send Get request from my GSM Module but after connecting to server it is not responding any thing

#include <SoftwareSerial.h>
SoftwareSerial myGsm(2,3);
void setup()
{
myGsm.begin(9600);
Serial.begin(9600);
delay(500);
myGsm.println("AT+CGATT=1");
delay(200);
printSerialData();
myGsm.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");//setting the SAPBR,connection type is GPRS
delay(1000);
printSerialData();
myGsm.println("AT+SAPBR=3,1,\"APN\",\"wap.mobilinkworld.com\"");//setting the APN,2nd parameter empty works for all networks
delay(5000);
printSerialData();
myGsm.println();
myGsm.println("AT+SAPBR=1,1");
delay(10000);
printSerialData();
myGsm.println();
myGsm.println("AT+SAPBR=2,1");
delay(10000);
printSerialData();
myGsm.println("AT+HTTPINIT");
delay(2000);
printSerialData();
myGsm.println("AT+HTTPPARA=\"URL\",\"http://sensor.somee.com/api/Data/GetData?SensorID=1\"");// setting the httppara,
delay(1000);
printSerialData();
myGsm.println();
delay(10000);//the delay is important if the return datas are very large, the time required longer.
printSerialData();
delay(9000);
printSerialData();
delay(1000);
Serial.println("done ");
printSerialData();
}
void loop()
{
}
void printSerialData()
{
while(myGsm.available()!=0)
Serial.write(myGsm.read());
}

and the Out put is

AT+CGATT=1

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

OK
AT+SAPBR=3,1,"APN","wap.mobilinkworld.com"

OK

AT+SAPBR=1,1

OK

AT+SAPBR=2,1

+SAPBR: 1,1,"10.209.122.68"

OK
AT+HTTPINIT

OK
AT+HTTPPARA="URL","http://sensor.somee.com/api/Data/GetData?Sen
done


texts: Can't drive long NeoPixel strips with Due or Duemilanove?

texts:
I spent a significant part of today developing a sprite movement library for a 30-pixel NeoPixel strip using my Arduino Duemilanove (ATmega 168). It works like a charm. However, if I change N_LEDS to a significantly higher value, the program seems not to run. I can't get it to run on the Duemilanove for a strip of longer than 50.

In fact, (see the below code) a relatively high N_LEDS value won't even allow the test patterns to run as defined in setup(). This leads me to believe that inexplicably the constructor for Adafruit_Neopixel is failing.

A friend of mine (who has the ultimate application for this) is hoping to drive a strand of 750 LEDs using this code on an Arduino Due. I can't imagine memory would be an issue with the Due, so what's going on here?

Headers:

#include <Adafruit_NeoPixel.h>

#define PIN    6
#define N_LEDS 30      // <-- If this number is > ~50, nothing happens
#define MAXSPRITES 5
#define MIN_UPDATE_INTERVAL_IN_MS  15
#define MAX_UPDATE_INTERVAL_IN_MS  40
#define SENSOR_TIMEOUT_IN_MS  2000
#define SCANNER_WIDTH  9

Strip declaration:

Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);

setup() and loop():

void setup() {
    randomSeed(analogRead(0));

    strip.begin();

    darkenStrip();

    manager = new SpriteManager();
    manager->Add(new TestPatternSprite(0, 0xff0000));
    manager->Add(new TestPatternSprite(5, 0x00ff00));
    manager->Add(new TestPatternSprite(10, 0x0000ff));
}

loop() {
    ...
}

Are there any coding mistakes in the above that wouldn't allow us to run this code on the Due? Or is this a known limitation?


texts:
I'm brand new to development and planning a project with my daughter to track speed and time in motion of a ball.

Example, ball is at rest. It is then put into play, timer starts, and speed is tracked until ball is at rest. Is is possible to get accurate data with relatively inexpensive sensors?

Data would look like:
Moved 19 consecutive seconds, average speed during that time=33mph.

Direction, elevation, acceleration changes, etc. would be ignored at this time. To start we just want average speed over time in use. We're having a bit of trouble deciding between accelerometers vs gyro vs magnetometer (or combination)

Any assistance (even links to where to learn) would be greatly appreciated


texts: Could an `analogWrite` command and its variable output values be used to power multiple leds with same intensity?

texts:
I seem to be getting the right response on single LED but with multiple LEDS or a relay connected LED strip the voltage outputs seem to be insuffiecient.
What kind of analogWrite values does an LED respond to?


texts:
I have very little experience with the Arduino and am hoping that you may provide me with some helpful info.

I would like to build a device that records time spent on a project.  I envision the main Uno with a switch, microSD breakout, and an LED to indicate its tracking your time. When setup the user could simply press the switch/button (light up the LED to show you're "working") and while you plug away on your day job the Uno will track the time between switch on and switch off. Then at the time the switch is turned off, have the Uno write a simple data file containing the total time spent on that activity.

I have a basic idea of what I need hardware wise, but am hoping to find insight to the backbone of software programming to make something like this begin to take shape.


texts:
I'm developing an computacional module to create risk maps in agriculture, I am using one arduino mega as "GreenSeeker", generating "fake" data to transmit via RS232 connection to one Raspberry PI, where she is process the data and generate the maps with GPS coordinates.

But, I have this cable.

I need to transmit data throught Arduino mega, and catch this data in the Raspberry PI.

I`ve have doubt about where connect the Serials pins on Arduino, the USB go on connect on the Raspberry PI USB, and the Serial go on Arduino, i need the right pins and where to connect them, and some code example.


texts: I'm working on my system and I have to make arduino repeat such action or block of code if its the set time .. I'm using DS3231 module to track date and time .Example If I set the time in 6:00 AM and when the arduino reads the module and it turns out that its already 6:00 AM the arduino will now execute some action or the block of code .. sorry for my english ..


texts: xbee communication not established between arduino

texts:
I have 2 Xbee Series2 modules, one set to Coordinator AT (Connected to PC with XCTU via USB dongle) and other set to Router AT(Connected to Arduino is connected to PC USB... RX>TX  TX>RX and 5V GND)

http://continentalee.com.sg/xbee-adapter
My xbee adapter

I have the programme uploaded into Arduino, a very simple sketch to test xbee wireless communication.

Code is here

char msg = ' '; //contains the message from arduino sender
const int led = 13; //led at pin 13

void setup() {
Serial.begin(9600);//Remember that the baud must be the same on both arduinos
pinMode(led,OUTPUT);
}
void loop() {
while(Serial.available() > 0) {
           msg=(char) Serial.read();

           if(msg=='H') {
               digitalWrite(led,HIGH);
           }
           if(msg=='L') {
                digitalWrite(led,LOW);
           }
delay(1000);
}
}

The problem comes.

When I type "H" in the Serial Com, the led light up, and the letter "H" appears in the XCTU console.

however, when I type something into the XCTU console, nothing appears on my Serial monitor and no light is seen on arduino

Thank you for your help in advance.


texts: error C1083: Cannot open include file: 'Ethernet.h':

texts:
i'm trying to compile native code in VC++ using galileo sdk for windows iot.
I've copied Ethernet.h file to the include directory of
D:\galileo-sdk-develop\galileo-sdk-develop\source> but still getting error on cannot open include file "Ethernet.h"


texts: Arduino Ultrasonic Sensor and LCD - Help Needed-

texts:
I just recently purchased an Arduino Uno 3 and I wanted to make an ultrasonic distance sensor that outputs the readings to a 16x2 LCD. I followed this guide:
http://www.mertarduino.com/using-ultrasonic-distance-sensor-hc-sr04-with-lcd-display-and-arduino/2018/11/22/ but it gave an error when I uploaded the code. The error was: a function definition is not allowed here before '{' token. I don't know too much about Arduinos, so I need help.
Thanks to whoever responds!

Here is the code:

// put your setup code here, to run once:
#include <LiquidCrystal.h> //Please replace the single quote characters ('') with the parenthesis character (<>)

LiquidCrystal lcd(1, 2, 4, 5, 6, 7); // Creates an LCD object. Parameters:
(rs, enable, d4, d5, d6, d7)

const int trigPin = 9;
const int echoPin = 10;
long duration;
int distanceCm, distanceInch;

void setup() {

lcd.begin(16,2); // Initializes the interface to the LCD screen, and
specifies the dimensions (width and height) of the display
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);

}

void loop() {

digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);
distanceCm= duration*0.034/2;
distanceInch = duration*0.0133/2;

lcd.setCursor(0,0); // Sets the location at which subsequent text written to
the LCD will be displayed
lcd.print("Distance: "); // Prints string "Distance" on the LCD
lcd.print(distanceCm); // Prints the distance value from the sensor
lcd.print("  cm");
delay(10);
lcd.setCursor(0,1);
lcd.print("Distance: ");
lcd.print(distanceInch);
lcd.print("inch");
delay(10);
}


texts:
Below is some code I wrote to find the rolling average of a temp sensor hooked up to an arduino and display it to an lcd display. My issue is that for the first minute it is running, the average is not correct. It starts at 0 and then progresses up to where it should be (~85F) in increments of approximately 3. After the first minute it is fine and works as it should.

What I want the code to do is to simply take the average of the sum of the values that have been recorded in the first minute.

My knowledge of C is fairly limited(I only had a semester long class on it) so that is why it is simple. I am a mechanical engineering student and this code is for project at my internship.

#include <Adafruit_MLX90614.h>
Adafruit_MLX90614 tempSensor;

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

Adafruit_MLX90614 mlx = Adafruit_MLX90614();

double array[30];
double rollingaverage=0;
int i=0, j=0;
double sum=0;
double newreading;
void setup() {

  Serial.begin(9600);
  lcd.begin(20,4);
  mlx.begin();
  Wire.begin();

}

void loop() {
  if(j=0){
      newreading = mlx.readObjectTempF();
      array[i] = newreading;
      sum += array[i];
      if(i>0){
          rollingaverage = sum/(i+1);
      }
      j=1;
  }
  else{
      newreading = mlx.readObjectTempF();
      array[i] = newreading;
      if(i < 29){ //wraps i back around to 0 if it is at 29 to subtract the oldest value
          sum = sum + array[i] - array[i+1];
          rollingaverage = sum/30;
      }
      else{
          sum = sum + array[i] - array[0];
          rollingaverage = sum/30;
          i=0; //reset index to 0
      }
  }
  i++;

  lcd.clear();
  lcd.print("Belt: "); lcd.print(rollingaverage);
  lcd.setCursor(1,2);
  lcd.print("Air: "); lcd.print(mlx.readAmbientTempF());

delay(2000);
}

Its not a huge deal because it works fine after the first minute, it is just annoying that I can't figure out why it doesn't work as intended in the first minute. Thanks


texts: Which interrupts are enabled when programming an ATTiny85 with Arduino IDE?

texts:
I have programmed a tiny85 using the Arduino IDE. I am using the pulseIn() function. Wrapping it in noInterrupts()/interrupts(); appears to make the function more consistent. This would imply that interrupts are running.

Which interrupts are running? Can I disable them?

I am using the analogWrite() function to pins that have PWM support. Disabling the interrupts for a "long" time does not seam to effect these, this implies the PWMs are producing the analogue signal in hardware and so interrupts are not required.

(I know I can improve the code by not using pulseIn and using interrupts, however the question I have at the moment is which interrupts are running when I am not explicitly enabling any.)


texts: What is the best transmitter/receiver to use with an Arduino RC?

texts: I want to customize an RC car that I have because the controller is gone. I'm going to use an Arduino with a custom motor controller but I have no idea what to use for the transmitter/receiver. I've seen some IR sensors being used but I want something that uses a frequency channel. Has anyone had experience doing this? What is the easiest way to go about accomplishing a remote controlled Arduino car?


texts:
int j;
void setup()
{
   for(j=2 ; j<=9 ; j++)
      pinMode( j , OUTPUT );
   digitalWrite( 2, HIGH );
}
void one()
{
   digitalWrite( 3, HIGH );
   digitalWrite( 4, HIGH );
}
void all_off()
{
   for(j=3 ; j<9 ; j++)
      digitalWrite( j,LOW);
}
void loop()
{
   one();
   delay(1000);
   all_off();
   delay(3000);
}

Trying to do a blinking "1" (stopped at 1 before continuing other numbers because of this problem ) with a single-digit 7 segment display. Where pin 2 is comnected to the com pins of the display.

Expected: display 1 for a second , then turn off for 3 seconds.

Reality: display1 for 3 seconds then turn off for a second.

Tried putting the delay functions in the one and all_off functions but no use.

Tried changing the delay(1000) to delay(7000) , the off time increased.

Tried changing the delay(3000) to delay(1000) , the turn on time changed to 1 second.

The code should work in order, should it not?  What is happening? How to fix it?


texts: Optmizing print code when writing to file, and reducing print time

texts:
First things first, I have found some solutions to this problems but they all involved for printing to serial monitor. I am trying to take the information from the sensors and write them to an sd card. Here is my code so far:

//-----Writes Data to SD Card-----//
if(!Data) {
    u8g.firstPage();
    do {
       drawFileError();
    } while( u8g.nextPage() );
    while (1);  // don't do anything more:
}

dcounter++;
if (dcounter=1){

    Data = SD.open("Data.txt", O_CREAT | O_APPEND | O_WRITE);
    Data.println(Header);
    Data.print(strutcDate + "  ");
    Data.print(strutcTime + "  ");
    Data.print(strgpsStatus + "  ");
    Data.print(strmodeIndicator + "  ");
    Data.print(strlatitude + "  ");
    Data.print(strlongitude + "  ");
    Data.print(strspeedOverGnd + "  ");
    Data.print(strcourseOverGnd + "  ");
    Data.print(t);
    Data.print("  ");
    Data.print(f);
    Data.print("  ");
    Data.print(h);
    Data.print("  ");
    Data.print(hi);
    Data.print("  ");
    Data.print(press_pKa);
    Data.print("  ");
    Data.println(str);
    Data.close();
} else{
    Data.print(strutcDate + "  ");
    Data.print(strutcTime + "  ");
    Data.print(strgpsStatus + "  ");
    Data.print(strmodeIndicator + "  ");
    Data.print(strlatitude + "  ");
    Data.print(strlongitude + "  ");
    Data.print(strspeedOverGnd + "  ");
    Data.print(strcourseOverGnd + "  ");
    Data.print(t);
    Data.print("  ");
    Data.print(f);
    Data.print("  ");
    Data.print(h);
    Data.print("  ");
    Data.print(hi);
    Data.print("  ");
    Data.print(press_pKa);
    Data.print("  ");
    Data.println(str);
    Data.close();
}

two questions: is it possible for me to reduce this chunk of code into something smaller? is there a way to decrease print time?

Edit: Ahh I see, the problem with my code is that the last few values are floats.Any way to shorten those as well, or do i need to do it individually? I do agree about the adding string parts.


texts: Why are my objects losing their member's values?

texts:
I have a Channel class which on instantiation receives a _type via new Channel("type", ...). I can read the type back out via channelObject->getType() which returns a string.

This has always worked fine until today. I have no idea what changed but if I Serial.print(channelObject->getType()) I get a nasty amount of garbage in the terminal:

���QQ���� 00@��������'����������������������(�����������b���������������������������������������H���E���������������������������������������������������������������uD��DESC  initializedOoops, no LSM303 detected ... Check your wiring!Ooops, no BMP180 detected ... Check your wiring!Setting IMU ground: Setting front: !! set ground kalman initConnect Powerbooting up...SWATBOT SETUP COMPLETEtype_xelevatoraileronthrottlerudderaux1aux2serial in: DISARMED!E;1
B��LSM303(>.a+a+8L.�S2E/��BMP085.qL3GD20���T �4&�'�%�%�%&
naninfovf�!,�!H�!��!��!Њ!�D�s6/&������?)m((a&l1=#k2���_
X� +�����+����=� ��J�5�.d�6s'���z :����������-/�type_xtype_x    elevatoraileron    throttlerudderaux1aux2�F�OX4Vjx 7���2�?�xr����:~aileronaux1
�:~  elevator
 ~ throttle:):~rudder������=�@��>�̀?��=�=�@��>�����=�=�@��>�f�B��=�i�?�k��BMP085QF��D�C
�#<}D������D]v� ,B����^v�QF����P}D .?P���f�B.s�D2m .?�oIB��P��(=:@���A�A�@9�@ A@�@�?�A0SB0N�>dC9�@ A@�@�?�A ��A��dC��L?��L>s����C�B(��"�  (�  �"��
(�

"elevator", "aileron", "throttle", and "rudder" are types for objects that I know exist but why is it coming out like this? I'm also seeing other unrelated parts of my program being spit out too like "Ooops, no LSM303 detected ...". This is all so strange.

If I had to guess, there must be an awry pointer somewhere in my application but I'm having no luck finding it. Worst case I'll rollback my application and retrace my last implementations (a couple days worth of work).

Can anyone give me a clue as to what is going on here?

My broken application is online at: https://github.com/jacksonkr/SwatBotSpine/tree/master

Emphasis on Channel.h:68 which is where all the garbage is coming from.

Related code:

RemoteControl.h:37
RemoteControl::getChannel


texts: Problem sending array data from matlab to arduino

texts:
I've two LEDs connected to the arduino uno's pin 12 and 13. I want to control the LEDs independently from the MATLAB serial command.

Here is my MATLAB serial command from where I'm sending char array

s = serial('COM4','BaudRate',9600);
fopen(s);
output = [2,1];
data = char(output);
fprintf(s,'%d',data);
fprintf(s);

And this is my Arduino code to receive char array

char d[4];
void setup()
{
   Serial.begin(9600);
   pinMode(12,OUTPUT);
   pinMode(13,OUTPUT);
}

void loop()
{
    if(Serial.available()>0)
  {
    for(int i=0;i<3;i++)
    {
      d[i] = Serial.read();
    }
    d1 = d[0]-'0';
    if (d1 == 1)
   {
    digitalWrite(12, HIGH);
    delay(1000);
     digitalWrite(12, LOW);
    delay(1000);
    }
  else if (d1 == 2)
    {
    digitalWrite(12, HIGH);
    delay(2000);
    digitalWrite(12, LOW);
    delay(1000);
    }
    d2 = d[1]-'0';
    if (d2 == 1)
   {
    digitalWrite(13, HIGH);
    delay(1000);
     digitalWrite(13, LOW);
    delay(1000);
    }
  else if (d2 == 2)
    {
    digitalWrite(13, HIGH);
    delay(2000);
    digitalWrite(13, LOW);
    delay(1000);
    }
  }
}

The MATLAB command is intended to keep the LED on for the given seconds. When I tried this code for one LED(sending only single char) it worked fine. But when I tried it for two LEDs it turns on only LED connected to pin 12 twice.

Eg:
MATLAB command output = [2,1], turns on LED(pin 12) for 2 sec and then for 1 sec but I want it should be to turn on LED(pin 12) for 2 sec and LED (pin 13) for 1 sec.


texts: what is required to clear this error "expected unqualified-id before numeric constant"

texts:
void setup() {
  // put your setup code here, to run once:
}
void loop() {
  // put your main code here, to run repeatedly:
}

1 int switchState = 0;
2 void setup(){
3 pinMode(3, OUTPUT);
4 pinMode(4, OUTPUT);
5 pinMode(5, OUTPUT);
6 pinMode(2, INPUT);
7 }
8  void loop(){
9   switchState = digitalRead(2);
10  //check state of pin 2
11  if (switchState == LOW){
12  //the button is not pressed
13  digitalWrite(3, HIGH); //green LED
14  digitalWrite(4, LOW); //red LED
15  digitalWrite(5, LOW); //red LED
16  }


texts: Arduino Mega 2560 - TFT 3.5 Display is not working with libraries suggested

texts:
I attached two images of the shield.

I bought an Arduino Mega 2560 R3 with a TFT 3.5 Display shield in China.

What I know from my research is:

There are no data sheets available in the Internet.
The factory's web site, in China, is in Chinese, and there is no information in English.
I achieved to know the factory is www.mcufriend.com, because it is the only reference in the shield.
Apparently the drive to use is R61581.
Using suggested libraries from Henning Karlsen (http://www.henningkarlsen.com/electronics/library.php)
(UTFT, UTFT Geometry, tiny Fat, UTFT Tiny Fat, UTouch and UTFT buttons) . These libraries don't work with this shield.
Some people say that this shield requires 3.3 [Volts] to work, but the Vcc pin connected goes to 5V and it contains a Voltage regulator. I suppose it drops the voltage from 5[V] to 3.3[V] in the middle of the back side of the screen shield (see the upper photo - U1).
The specs that I found, say that this is a 262,144 Color 320x480 Dot Graphic LCD screen using a LCD driver a Si TFT Panel.
This screen includes a touch pad and a Micro SD memory reader.
After using the geometry test included in the library folder UTF Geometry mentioned on #5, and using all the drivers found in the documentation included by Henning Karlsen in a .pdf doc, I couldn't get this shield to work.

Does anyone know how to make this screen work?

I know is too much technology involved to be a fake shield, but it should be very useful to have this working. Do you agree with me?


texts:
I am working on a small project that will need to check for proper UPC's then if validated, lift a barrier gate to move along cardboard boxes. The Arduino comes in with the gate lifting. I have this barrier gate working with a very small servo that came included with the Arduino Starter Kit, but this could not hold the weight that might be pushing up against it with a longer arm. Has anyone had any experience with something like this or could someone direct of a power supply/servo combo that would be up to the task? These boxes could weigh up to 20 pounds.

Thanks!


texts: Servomotor losing its connection right after being connected to Arduino

texts:
I am working with two servomotors and both are having the same problem: right after i connect them to the arduino and upload the code, they do as the code says for a really small amount of time (0.1s maybe), and then they simply stop. If i keep connecting and reconnecting it again the servo answer to the code for a really small amount of time and then stop, as I said before.

#include <Servo.h>

#define SERVO 6 // Porta Digital 6 PWM

Servo s; // Variável Servo
int pos; // Posição Servo

void setup ()
{
  s.attach(SERVO);
  Serial.begin(9600);
  s.write(0); // Inicia motor posição zero
}

void loop()
{
  for(pos = 0; pos < 90; pos++)
  {
    s.write(pos);
  delay(15);
  }
delay(1000);
  for(pos = 90; pos >= 0; pos--)
  {
    s.write(pos);
    delay(15);
  }
}

I am using the code above, and it looks totally fine. Does anyone know what might be causing this problem?


texts: I need to build a char array from two integers

texts:
My C is rusty, so please forgive this simple problem.

This line works:

Tft.drawString("Test",200,200,2,WHITE);

But, this has compile errors:

String yStr = "Test";
Tft.drawString(yStr,200,200,2,WHITE);

The function in the library:

void drawString(char *string,unsigned int poX, unsigned int poY,unsigned int size,unsigned int fgcolor);

The error is "no known conversion for argument 1 from 'String' to 'char*'".

Conclusion - I need a character array. Here's what I am trying to accomplish.

I have two integers that I would like to display on my Tft screen. For example, 225 and 250 to be displayed as "225,250".

I haven't figured out a way to build the char array for the drawString() function.

Assistance would be appreciated.

Thanks for the quick reply Ignacio.
I tried that, but the compiler still doesn't like it.

Here's how I built the string:

string stringXY ;
stringXY += xStr;
stringXY += ",";
stringXY += yStr;
Tft.drawString(stringXY.c_str(),200,200,2,RED);

Error: invalid conversion from 'const char*' to 'char*' [-fpermissive]

I am apparently using c_str() wrong?


texts:
I'm trying to write a simple code for initializing and running the PCA9685. I tested the board with Adafruit library and it's working.

But I just want to develop a simple code to include it in my various modules library for future projects.

I wrote a code, but I think I'm not understanding the work of the internal registers.

But according to the datasheet I configured only the auto increment and left the rest to default settings. Then I headed up to the last registers which are the all_led_on and all_led_offas wanting to run the outputs on/off to blink the LEDs. But I think these two registers are for enabling/disabling the pins. Is that right?

This is my code:

void pca9685_init(void){
    uint8_t i,val[]={0x20,0x04};
    i2c_start(PCA9685_BASE_WR);
    i2c_tx(PCA9685_MODE1);
    for(i=0;i<2;i++)i2c_tx(val[i]);
    i2c_stop();
}

void pca9685_all_on(void){
    uint8_t i,val[]={0x00,0x10};
    i2c_start(PCA9685_BASE_WR);
    i2c_tx(PCA9685_ALL_LED_ON_L);
    for(i=0;i<2;i++)i2c_tx(val[i]);
    i2c_stop();
}

void pca9685_all_off(void){
    uint8_t i,val[]={0x00,0x10};
    i2c_start(PCA9685_BASE_WR);
    i2c_tx(PCA9685_ALL_LED_OFF_L);
    for(i=0;i<2;i++)i2c_tx(val[i]);
    i2c_stop();
}


texts: Can I run 3 devices on Arduino Uno with different power sources?

texts:
I'm pretty new to these types of projects I'd like to work on a greenhouse project with an Arduino Uno. The goal is to be able to sense temperature and control a heating lamp, detect humidity and control a humidifier, and connect a soil hydration sensor and connect a small water pump for irrigation.
Could the Uno support all of this power that could theoretically run at the same time? How would controlling the 3 isolated functions look in the Sketch?


texts:
I've reviewed the WiFi101 library but have found no way to make the 101 an ad-hoc network.  Am I missing something?  I'd like to be able to emulate the RedFly example:
http://notebook.kulchenko.com/embedded/storing-wifi-configuration-in-eeprom-on-arduino

Can the 101 become an ad-hoc network?  I understand the security problem with the ad-hoc capability so it would make sense that Arduino prohibits it.


texts: Turn Arduino on only by double tapping switch?

texts:
I don't have much experience with electronics. I was wondering if it is possible to create a push button switch, which will turn on the device only if it is tapped twice in quick succession?

If it is tapped only once, then the device should behave as if nothing happened (i.e. tapping the switch again after a specified duration should have no effect).


texts: Fail to return int value from a function

texts:
I have created myJSON library to simplify read and write values from/ to FLASH of my ESP8266 NodeMCU/ Wemos Mini.

I do not want to "mess up" the question, posting my entire code/ library - but to try to explain what happens -

I get a 0 value when reading a specific key (and not its saved value ). My assumption is that is has nothing to do with myJSON library, but my understanding in returning a value from a function.

Code is as follows:

(some explanations first):

1) json is an instance of myJSON library.

2) json.setValue(key, value) - gets a key and a value ( char/ int) and save it to FLASH.

3)json.getINTValue(key, return_var)- gets a key and return its int value to return_var. function return 1 - for successful read, and 0 when not.

inside setup()

int int_val;
// json.setValue("int_key",343); // commented out after first run - to be sure is is saved and read from flash.
Serial.println(json.getINTValue("int_key",int_val)); // NOTE 2
Serial.print("Value is: "); // NOTE 3
Serial.println(int_val);   //  NOTE 3

myJSON ( only relevant code )

bool myJSON::getINTValue (const char *key, int retval){
        StaticJsonDocument<DOC_SIZE> tempJDOC;
        myJSON::readJSON_file(tempJDOC);
        bool hasKey = tempJDOC.containsKey(key);
        if (hasKey){
          retval = tempJDOC[key];
          Serial.print("retval :"); // NOTE 1
          Serial.println(retval);  // NOTE 1
          return 1;
        }
        else {
          return 0; // when key is not present
        }
}

void myJSON::setValue(const char *key, char *value){
        StaticJsonDocument<DOC_SIZE> tempJDOC;
        myJSON::readJSON_file(tempJDOC);
        tempJDOC[key]=value;
        myJSON::saveJSON2file(tempJDOC);
}
void myJSON::setValue(const char *key, int value){
        StaticJsonDocument<DOC_SIZE> tempJDOC;
        myJSON::readJSON_file(tempJDOC);
        tempJDOC[key]=value;
        myJSON::saveJSON2file(tempJDOC);
}

result is (SEE NOTATIONS):

21:01:03.198 -> retval :343  // OUTPUT NOTE 1
21:01:03.198 -> 1            // OUTPUT NOTE 2
21:01:03.198 -> Value is: 0  // OUTPUT NOTE 3

As far a I could understand :

1) setValue works as needed ( inc. saving to flash ).
2) unexplained besides getting value = 0, is when setting a char value ( there are 2 myJSON::setValue functions to deal with int and char), code works as needed.

Appreciate any help ( and sorry for my English ).

Guy


texts:
Using an IR sensor, how can I get and decode signals from other IR devices? I've seen the IRRemote library and its forks, but it doesn't fulfill my second requirement which is that I need to be able to tell the signal strength of the IR signal.

In addition, do I have to use a higher-end TSOP module? Or could I just use one of these?

Thank you!


texts: fatal error: avr/io.h: No such file or directory

texts:
I'm compiling a project on Due that was working correclty using UNO. I get this error : 'avr/io.h: No such file or directory'. Searching across the web, it seams I'm not the only one to get that error when using Arduino Due but didn't clearly figured out why it appears.

Of course, the file is present where it should be, I verified ..\Arduino\hardware\tools\avr\avr\include\avr\io.h

I opened it and see something like that :

...

#if defined (__AVR_AT94K__)
#  include <avr/ioat94k.h>
#elif defined (__AVR_AT43USB320__)
#  include <avr/io43u32x.h>
#elif defined (__AVR_AT43USB355__)
#  include <avr/io43u35x.h>
#elif defined (__AVR_AT76C711__)
#  include <avr/io76c711.h>
#elif defined (__AVR_AT86RF401__)
#  include <avr/io86r401.h>
#elif defined (__AVR_AT90PWM1__)
#  include <avr/io90pwm1.h>
#elif defined (__AVR_AT90PWM2__)
#  include <avr/io90pwmx.h>
#elif defined (__AVR_AT90PWM2B__)
#  include <avr/io90pwm2b.h>
#elif defined (__AVR_AT90PWM3__)
#  include <avr/io90pwmx.h>
#elif defined (__AVR_AT90PWM3B__)
#  include <avr/io90pwm3b.h>
#elif defined (__AVR_AT90PWM216__)
#  include <avr/io90pwm216.h>
#elif defined (__AVR_AT90PWM316__)
#  include <avr/io90pwm316.h>
#elif defined (__AVR_AT90PWM161__)
#  include <avr/io90pwm161.h>
#elif defined (__AVR_AT90PWM81__)
#  include <avr/io90pwm81.h>

...

so I suppose that a line referring to my card is missing or something like that ?

I'm using Arduino 1.6.12


texts: Autolock transistor for powering Arduino

texts:
I have a portable project where I want to take care about batteries getting discharged.

Usually I just put a switch at the very beginning of my circuit that completely cuts off the electricity when switched off. The problem with this approach is that if you forget to switch it off your batteries will discharge.

So I was thinking about an approach that after some inactivity time cuts off the circuit (I want to completely cut off the electricity to minimize power consumption, so I'm not interested in sleeping modes or similar approaches).

So my approach consist in changing a switch for a regular push button that   enables the circuit when pushed, and then one of the arduino pins is used to lock the transistor until a function times out and the pin gets to a low voltage (see image)

In the arduino code I can just test a simple program that keeps the circuit closed for 10 seconds and then switches it off.

setup() {
    pinMode(3,OUTPUT);
    digitalWrite(3,HIGH);
    delay(10000);
    digitalWrite(3,LOW);
}

loop() {
}

For the transistor part I'm not sure what to use. I was thinking about using an motor driver L298 (which should work and also accepts some load for other electronics that I might have in the project)

However this looks like something that should already exist (either in a shield or maybe integrated in some Arduino variant).

Does anybody have experience with such an approach or a suggestion on any standalone transistor that would also do the job?

Any help is appreciated :)

.


texts: Is there software to make an interactive GUI for my TFT touch screen shield?

texts: I was wondering this, because realized it takes quite time consuming due to all the lines of code I have to write.


texts:
I have some neopixels, and I have one hooked up to my teensy.
I want to have the color change, when the push button is pressed vs not pressed. The LED will change colour when I upload the code, if I have the button pressed, green, if the button is not pressed, red.

The serial monitor reports changing button press statuses, so I'm not sure why the neopixel isn't changing.

The adafruit website is confusing to me, they have wonderful and involved project examples, but they never have just a basic IO example.

I would appreciate it, if someone could point out where Im going wrong with this code:

#include <Adafruit_NeoPixel.h>

#define PIN            0

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      1

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
const int buttonPin = 2;
int buttonState = 0;

void setup() {
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
  pinMode(0,OUTPUT);
  Serial.begin(9600);
  pixels.begin(); // This initializes the NeoPixel library.

}

void loop() {

buttonState = digitalRead(buttonPin);
Serial.println(buttonState);

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
      if (buttonState == LOW) {
          pixels.setPixelColor(PIN, pixels.Color(0,33,0)); // green
          pixels.show();

      }else{
          pixels.setPixelColor(PIN, pixels.Color(66,0,0)); // red
          pixels.show();
        }
        delay(500);
  }

this code compiles, without errors, and uploads just fine, but pressing the button won't change the LED color.


texts: glediator + PL9823 (WS2812B) + teensy = fail?

texts:
here is what I got:

teensy++ 2.0 with code below
Glediator configured for Glediator_Protocol/Single_Pixels/HL_TL/RGB/B_1000000
led matrix with the PL9823 leds (80 of them)

I first off have to set the code to 160 on the teensy just to get it to                     at least make the leds change. even when i have it set to that OR the 80 leds, it does not show what is on screen (see video below). I have no clue what to try next.

Code

#include "FastLED.h"
#define NUM_LEDS 160
const int dataline = PIN_B4;
CRGB leds[NUM_LEDS];

void setup()
{
    digitalWrite(6,LOW);
    Serial.begin(1000000);
    LEDS.addLeds<WS2812B, dataline>(leds, NUM_LEDS);
    for (int p=0;p< NUM_LEDS;p++)
    {
        leds[p] = CRGB::Black;
        FastLED.show();
    }
}

int serialReadBlocking()
{
    while (!Serial.available())
    {
    }
    return Serial.read();
}

void loop()
{
    while (serialReadBlocking() != 1)
    {
    }
    for (long i=0; i < NUM_LEDS; i++)
    {
        leds[i].r = serialReadBlocking();
        leds[i].g = serialReadBlocking();
        leds[i].b = serialReadBlocking();
    }
    FastLED.show();
}

https://www.youtube.com/watch?v=H6OuMWKtbmo


texts: ATTiny85 I2C connection with Arduino Nano

texts:
I am trying to send and receive data using I2C between an Arduino Nano and an ATTiny85.
The ATTiny is mounted on this board:
Link

I've tried to reach the slave with the simple I2C scanner, but I don't find anything.

Those are the codes:

Master (I2C scanner):

// --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// Version 6, November 27, 2015.
//    Added waiting for the Leonardo serial communication.
//
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#include <Wire.h>

void setup()
{
  Wire.begin();

  Serial.begin(9600);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}

void loop()
{
  byte error, address;
  int nDevices;

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

  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknown error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(500);           // wait 5 seconds for next scan
}

And this is the code of the ATTiny85 (slave):

#include <TinyWire.h>

#define led_pin 1

byte own_address = 10;

void setup() {
  // config led_pin as Output for driving an LED
  pinMode(led_pin, OUTPUT);

  // config TinyWire library for I2C slave functionality
  TinyWire.begin( own_address );
  // sets callback for the event of a slave receive
  TinyWire.onReceive( onI2CReceive );
}

void loop() {

}

/*
I2C Slave Receive Callback:
Note that this function is called from an interrupt routine and shouldn't take long to execute
*/
void onI2CReceive(int howMany){
  // loops, until all received bytes are read
  while(TinyWire.available()>0){
    // toggles the led everytime, when an 'a' is received
    if(TinyWire.read()=='a') digitalWrite(led_pin, !digitalRead(led_pin));
  }
}

Once I've programmedo both the boards I've connected SCL and SCK pins of the boards together.

If i open the serial monitor of the master this is what i get:

  I2C Scanner Scanning... Unknown error at address 0x20 Unknown error at
  address 0x21 No I2C devices found

  Scanning... Unknown error at address 0x78 No I2C devices found

  Scanning... No I2C devices found

  Scanning... Unknown error at address 0x08 Unknown error at address
  0x09 Unknown error at address 0x60 No I2C devices found

  Scanning... Unknown error at address 0x70 No I2C devices found

And so on.
Can someone explain me were I'm doing errors?


texts: Resistors on LCD - does a small difference matter?

texts:
I recently have tried to connect an LCD to my Arduino Uno. The tutorial
tells me I need a 220 Ohm resistor, but the only ones I have are 330 Ohm. Does it matter?

Here's the Fritzing diagram by the way:


texts:
#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}

I have found this code that makes servo go 180 and back, but when I switch 180 degrees with 90, which is what I need, my servo doesn't do that (I tried the code in Arduino simulator).

Do I have to change something elese in the code (like delay time) so it whould go 90 degrees up and then 90 down?

Here is the link of circuit:

https://circuits.io/circuits/3597808-servo-90-degrees


texts: What is wrong with this processing code?

texts:
I have written a processing code to work along with my arduino code for the arduino UNO. In this I'm trying to control the colour of the processing window by the arrow keys. However, I'm doing this in a bit roundabout manner because I wanted to see how the 2 codes work together to exchange information.

The processing code:

import processing.serial.*;
Serial port;
int data=0;
char c;

void setup()
{
 port=new Serial(this,"COM3",9600);
 background(0,0,0);
 size(500,500);
}

void draw()
{
 if(port.available()>0)
  {
data=port.read();
c=(char)data;
if(c=='U')
   background(255,0,0);
if(c=='D')
   background(0,255,0);
if(c=='L')
   background(0,0,255);
if(c=='R')
   background(255,255,0);
}//end of if
}

void keyPressed()
{
 if(key==CODED)
 {

  if(keyCode==UP)
     port.write('u');
  if(keyCode==DOWN)
     port.write("d");
  if(keyCode==LEFT)
     port.write("l");
  if(keyCode==RIGHT)
    port.write("r");

 }
}

The arduino code:

// Arrow key controller

char data;

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

}

void loop()
{
 while(Serial.available()>0)
  {
   data=Serial.read();
   if(data=='u')
      Serial.print("U");
   else if(data=='d')
      Serial.print("D");
   else if(data=='l')
      Serial.print("L");
   else if(data=='r')
      Serial.print("R");
  }

}

Here what Im doing is, i'm reading the arrow key press from processing. The correspoding small case letter is printed into the serial buffer, eg u for UP.
The arduino code reads this letter(u) from the serial buffer and prints the corresponding upper case letter(U) into the serial buffer. The processing code then reads the uppercase letter from the buffer and changes the colour accordingly.
But nothings happening when i push the arrow keys. What's wrong?


texts:
I bought this 2.8" OLED from Aliexpress a few weeks ago: https://www.aliexpress.com/item/32988174566.html?spm=a2g0s.9042311.0.0.72304c4dAWcHG8

And after a ridiculous amount of searching for a datasheet, I came across this one that seems to match the board I bought: https://www.buydisplay.com/download/manual/ER-OLEDM028-1_Series_Datasheet.pdf

Wiring up pins 1 and 2 to ground and 3.3V on a breadboard, I'd expect something to happen with the display, but I get nothing. The display is in 8080 mode, so I wire everything up to a standard UNO board and power everything on. Still nothing. Try changing the power to 5V, no joy.

During my testing, I noticed the back of the display is getting hot. Not sure if that's a good thing or not yet.

So what's the best way to 1) determine if the datasheet I found is correct? 2) check if the OLED is just broken? I don't have a ton of experience with these displays yet, so I'm not sure if just powering the thing on should net some visual response.


texts: ESP8266 Stops Working if I don't provide Wifi during specifc step

texts:
To test the WiFi connection I'm sharing the WiFi of my cellphone.

If I stop the WiFi sharing during the command below, the ESP8266 stops working.
It only works if I do a hardware reset.

If I don't stop the WiFi it works normally.

    if(client->POST(urlCal, host, payload))
  { RetornoPost = client->getResponseBody(); }

HTTPS Redirect (Version 2.0)
ESP8266 library version 2.4.2

Does anyone know why ESP8266 stops working?


texts: Duplication a power button signal with Arduino

texts:
Long story short, I have a old laptop motherboard, and have lost the keyboard, plus have no money to buy a new one, and I've seen some external usb keyboards with a power button. So how do I give the same signal with a arduino so I can turn on my pc?
Plz help
Best regards Alek


texts:
I have a stepper motor connected to my Arduino like this using the ULN2003A Darlington Array:

(Ignore the potentiometer)

And I have programmed it with the following code:

#include <Stepper.h>

int in1Pin = 22;
int in2Pin = 23;
int in3Pin = 24;
int in4Pin = 25;

Stepper motor(512, in1Pin, in2Pin, in3Pin, in4Pin);

void setup()
{
    pinMode(in1Pin, OUTPUT);
    pinMode(in2Pin, OUTPUT);
    pinMode(in3Pin, OUTPUT);
    pinMode(in4Pin, OUTPUT);

    motor.setSpeed(25);
}

void loop()
{
    int steps = 360;

    motor.step(steps);
    delay(500);
}

At the moment the motor rotates clockwise, how could I have it so it rotates in the opposite direction?

My code was copied and edited from here.

The problem was that I had the two middle wires the wrong way round as said here: http://forum.arduino.cc/index.php?PHPSESSID=kvi8dt2b5en5hhk02dlmjrotl5&topic=143276.msg


texts: What would cause a delay when using serial between the Arduino IDE & external clients?


texts: Leonardo - always on power, status remains between computer reboots?

texts:
I'm looking for two answer here.

Is it possible to power a Leonardo to be always on, separate from the power from the USB host - I've tried with a full size Leonardo and a power adapter but for some reason the code didn't run when I did that. I've bought a battery shield too which will be arriving soon.
I want it be power-able via a switch with batteries so that I do a few things. For a start avoid it's boot up time and have it pressing a key as soon as the booted computer sees it (I'm running it as a keyboard/mouse via USB-HID) and also at one point I have the computer send serial data to have the Arduino run a different part of it's code...at this point the host computer reboots. Obviously that means the Arduino will see it's USB host disappear then come back online, will that automatically reset it and thus start it from the beginning again, or can I set it so that with always on power it will carry on doing what it is, irregardless of it's connecting to the host?

Do I need to change code, or libraries to achieve any of this?

With the theory intact answered, here is some of my actual code, i've stripped most of it out as it's just a bunch of keyboard presses

#include <Keyboard.h>
#include <Mouse.h>
char returnKey = KEY_RETURN;
char tabKey = KEY_TAB;
void setup() {
Keyboard.begin();
Mouse.begin();
// delay(60000); //Deploy Delay
delay(3000); //Testing Delay
// Keyboard commands
Keyboard.write(returnKey);
delay(14000);
// Welcome Screen
Mouse.click(MOUSE_LEFT);
delay(100);
}

void loop() {
}


texts:
Firstly, I have tried to set the bootloader to be 8MHz internal oscillator.

I have tried the board setup from here - https://github.com/oshlab/Breadboard-Arduino.

And also the breadboard-1-6-x.zip setup from here - http://www.arduino.cc/en/Tutorial/ArduinoToBreadboard.

Burning the bootloader in both cases seems to work, with fuse settings of -Uefuse:w:0x05:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xE2:m (using Arduino IDE 1.6.7):

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0x05:
avrdude: load data efuse data from input file 0x05:
avrdude: 1 bytes of efuse verified
...
avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xDA:
avrdude: load data hfuse data from input file 0xDA:
avrdude: 1 bytes of hfuse verified
...
avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xE2:
avrdude: load data lfuse data from input file 0xE2:
avrdude: 1 bytes of lfuse verified

When I try and run the test sketch (below) at these voltages:

3.3V it fails (tried multiple 3.3V sources, all fail).
4.23V (3xAA rechargeable batteries) it works.
4.8V (3xAA alkaline batteries) it works.
5V it works.

To try and determine if it was my power sources or the bootloader that was the problem I uploaded this test sketch on my ATmega328P, an Arduino Nano (all Nanos are 16MHz?) and a 16MHz Arduino Pro to see if the red LED (with 100 Ohm resistor for ATmega328P) lights up in about the same time. This test sketch also does not work at 3.3V, and must be run at 5V to work.

(edit) When running this test sketch at 3.3V I see no 3.3V logic level on any output pin with my multimeter.  When running at 4.23, 4.28, 5V I see this logic level on all output pins.

(update) When connecting the +ve of the LED directly to 3.3V, the LED lights up.  So the 3.3V source has enough power to light the LED directly.

So I assumed that because my ATmega328P circuit has no crystal in it (and the Nano and Pro Mini are 16MHz), these loops would execute in different amounts of time?  But no, the loops do execute at the same speed (3 and a bit seconds) - so is my Nano/Pro Mini underclocked, or my ATmega still running at 16MHz but without a crystal??  Rather confused.

Thanks.

(update) I tried a second ATmega328P, same problem.

(code edited to use 14 output pins)

void setup() {
  for (int p=0; p<14; p++) pinMode(p, OUTPUT);
}

void loop() {
  // waste some time.
  int y = 0;
  for (int i = 0; i < 11; i++) {
    for (int j = 0; j < 11; j++) {
      for (int k = 0; k < 101; k++) {
        y+=analogRead(A0);
      }
    }
  }
  for (int p=0; p<14; p++) digitalWrite(p, y % 2);
  for (int p=0; p<14; p++) digitalWrite(p, HIGH);
  delay(1000);
  for (int p=0; p<14; p++) digitalWrite(p, !(y % 2));
  for (int p=0; p<14; p++) digitalWrite(p, LOW);
  delay(1000);
}


texts:
I am fully new to Arduino (even don't have one ... yet), however, I'm looking into possibilities to use both MIDI in/out and DMX together. If I understand correctly the MIDI library (re)uses the UART/COM while the DMX does the same.

I am wondering if it can be used together (e.g. use MIDI in to control MIDI out and/or DMX out).

(Also still checking if I would need some simple MIDI/DMX components or 'full' MIDI or DMX shields/boards.)


texts: Regarding the output voltage and current in arduino

texts:
This is basically an off-shoot from https://arduino.stackexchange.com/questions/20569/unexpected-output-pin-behavior-was-relay-on-off-doesnt-loop. It's the same schematics and so on, however, I'm now wondering what the output voltage and current is.

I've a 9V battery and the MOSFET transistor from the arduino starterpack (doesn't say the specs) connected to the 5V pin on the board. I need the following output current/voltage for it to activate a solenoid:

6V: 160 mA
7V: 190 mA
8V: 220 mA
9V 240 mA
10V :270 mA
11V :300 mA
12V :320 mA

and I'm just not sure how to calculate it since I'm not sure about the output from the transistor and all the way to the solenoid.

The solenoid: http://www.electrokit.com/en/plastic-water-solenoid-valve-1-2-12v.51108


texts:
I am trying to do a Hardware-in-the-loop (HIL) system with Arduino and Simulink but the driver of my motor (Pololu VNH5019) works at 20kHz and simulink PWM block only supports 490Hz.

I would like to read and modify the code before it is sent to the Arduino to modify this and add other libraries.

It would be that possible?

If it is not possible, there is any other visual environment (with blocs, like simulink or Xcos) to generate Arduino Code?


texts: Powering LED Strip at both ends shorts my psu?

texts:
I've got a 200 LEDs strip of sk9822's hooked up to a 5V 8A power supply.
As expected, at full white, there's considerable voltage drop and the far end of the strip turns from white to amber.

I wanted to hook up another set of V+ and GND at the far end of the strip, but doing so trips my psu? The strip blinks full white as a result.

Hooking up ONLY GND or ONLY V+ at the far end significantly improves the drop off where only the middle of the strip turns slightly amber-ish.
But! I do notice a faint buzzing from the PSU if I do this.

Am I doing something wrong here?


texts: 3 square wave pulse by 120° phase shift and 3 inverted of each by Arduino

texts:
I want to make a three phase inverter (DC to AC) bridge type using Arduino. For that I want to generate three square wave each is 120° phase shifted and other three waves of main three wave forms inverted for opposite switch.

Can anyone please help me out? I am new to programing in Arduino.

Code:

void setup() {
  pinMode( 9 , OUTPUT );
  pinMode( 10 , OUTPUT );

  TCCR1A = _BV( COM1A0 ) |_BV( COM1B0 );
  TCCR1B = _BV( WGM13) | _BV( WGM12);
  OCR1A = 0;
}
#define PRESCALER 1
#define PRESCALER_BITS 0x01
#define CLK 16000000UL

int setWaveforms( unsigned long freq , int shift ) {
  unsigned long clocks_per_toggle = (CLK / freq) / 2;
  ICR1 = clocks_per_toggle;
  unsigned long offset_clocks = (clocks_per_toggle * shift) / 180UL;
  OCR1B= offset_clocks;
  TCCR1B |= _BV( CS10 );
}

void loop() {
  setWaveforms( 50000 , 120 );
  delay(1000);
  setWaveforms( 50000 , 120 );
  delay(1000);
  setWaveforms( 50000 , 120 );
  delay(1000);
}

I had get 2 waves only but I want to get 6. I am new to Stack Exchange.


texts: Error when trying to write analog and digital signals from different pins (Arduino UNO)

texts:
I'm using the Arduino UNO and started noticing some funny behavior when I was trying a few basic projects. Specifically when trying to write an analog signal through one of the PWM pins, then a digital signal through another.

Using some LED's connected to a few different permutations of pins 8-13, I found that when I have an analog output set for one of the pins (in this case 9, 10, or 11 as they're the only one's of the set capable of PWM) and then try to output a digital signal from a different pin to another LED the digital signal seems much weaker. That is, the LED shines very very dim.

The pins 2-7 work fine.
Does the behavior described above indicate anything wrong with the arduino? are those pins potentially damaged, or is there something I'm not understanding here?

My code:

void setup()
{}

void loop()
{
   analogWrite(9, 255);
   delay(1000);
   analogWrite(9, 0);
   delay(2000);
   digitalWrite(8, HIGH);
   delay(1000);
   digitalWrite(8, LOW);
   delay(2000);
}


texts: Arduino Mega And L298N Motor Driver Board (Controlling using AccelStepper Library)

texts:
Can someone help me how to use AccelStepper library in setting the origin position of the stepper?

We are using a tact switch and an L298N driver for the stepper motor in setting the origin of the motor.

We encounter a problem in setting the origin when the motor hits the tact switch it will then continue the loop, but it doesn't set the origin.


texts: Connect a sensor to Arduino without knowing much info about the sensor

texts:
I am planning to buy a formaldehyde sensor and I would like to connect it to an Arduino Uno board (and later to a Raspberry). As far as I know, the sensor comes in a small box/bag without any other external components (e.g. amplifiers etc.). So I will end up having in my hand a sensor with two copper terminals for connection (see image below):

Is it possible to connect this to an Arduino board without having a connection scheme? If yes, where do I connect the two terminals of this sensor to the 5V, GND and the A## ports? Also, how to translate the voltage coming from the sensor to ppm (parts per million) only by having general specifications from the manufacturer and not some kind of table of conversion? Also, would I need an external component for this? If yes, which component?

I know that this question sounds very stupid, but so far I've used sensors that come with a code on Seeed Grove with a clear description and I assumed that the code is there because there is a link between the producer of a certain sensor and Groove. Thank you!

FYI: The producer writes some things about the sensor but that doesn't help me a lot:

  This sensor is of the two-electrode electrochemical type, operating by the
  diffusion principle and as such requires no external sampling hardware. In
  the presence of formaldehyde gas a small direct current is produced; the
  sensor requires no power supply of its own but this current requires
  amplification to make it readable using external data collection
  equipment.


texts: ESP8266 Send data to Firebase using Arduino Uno error

texts:
Good day everyone! I have a project, in which the data from a button (number of clicks) will be sent to a real-time Firebase database. Every time the button is clicked the counter increases and will be updated in the firebase database.

Wifi Module:
Esp8266 Esp-01 + Esp-01 Adapter

In my understanding, there are 2 ways to use this wifi module.

Upload the code to the Arduino Uno and use AT commands in the module to send data to the web.
Upload the code inside the WiFi Module itself and after that it can be a standalone SOC and does not need the Arduino anymore after the code has been uploaded.

I have tried the second way, but I got confused and stuck. So far I have successfully plugged the adapter in a breadboard and tested some AT commands.

Since I will be using the second way I won't be using these. So I tried this code:

 #include <ESP8266WiFi.h>
 #include <FirebaseArduino.h>

 #define FIREBASE_HOST "https://duck-917ba.firebaseio.com/"
 #define FIREBASE_AUTH "r3jNQCsxN2Y2dcfawimRlzjLjdBSXLjstwGeyB0oMK"

 #define WIFI_SSID "mywifi"
 #define WIFI_PASSWORD "621533515"

const int  buttonPin = 8;
int buttonPushCounter = 0;
int buttonState = 0;
int lastButtonState = 0;

void setup() {
  pinMode(buttonPin, INPUT);
  Serial.begin(9600);
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("connecting");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.print("connected: ");
  Serial.println(WiFi.localIP());
  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
  Firebase.setInt("clicks",0);
}

void loop() {
  buttonState = digitalRead(buttonPin);
  // compare the buttonState to its previous state
  if (buttonState != lastButtonState) {
    // if the state has changed, increment the counter
    if (buttonState == HIGH) {
      // if the current state is HIGH then the button went from off to on:
      buttonPushCounter++;
      Serial.println("on");
      Serial.print("number of button pushes: ");
      Serial.println(buttonPushCounter);
      Firebase.setInt("clicks", buttonPushCounter);
    } else {
      // if the current state is LOW then the button went from on to off:
      Serial.println("off");
    }
    // Delay a little bit to avoid bouncing
    delay(100);
  }
  // save the current state as the last state, for next time through the loop
  lastButtonState = buttonState;
}

So I have plugged my 4-pin adapter to the following:

ARD(TX)-ADAPTER(TX)
ARD(RX)-ADAPTER(RX)
ARD(5V)-ADAPTER(VCC)
ARD(GND)-ADAPTER(GND)

I have set the Generic ESP8266 Module Board.

Problems Encountered:

I am supposed to select the port of the ESP8266 but I only see the Arduino UNO port in the port list. When I compile the code I get this error:

I am now confused on what the error is all about. I thought since I am using an adapter I can use the PROGRAMMING MODE of the module easily. But it seems like my adapter is not doing its job. According to some of my research I have to use  TTL or FTDI USB-to-serial dedicated module / Ground some wires while compiling which is very confusing for a beginner like me.

So here are my final thoughts:

Can I input/flash code in my module using my Arduino and adapter?
Since the button is plugged in the Arduino's pin 8, does that mean that the code in the module will be successfully inserted? I will still need the Arduino to be plugged in the buttons?
What could be the reason why the module won't appear in the Port List and generates the errors?

I know this is quite a long and boring topic but I know a lot of aspiring IOT developers out there are having the same issues about this wifi module. I hope we can solve it together. Thanks!


texts: How do I scroll through the LCD vertically with joystick?

texts:
I have a device I'm working on and the only issue I'm running into is I can't manage to figure out how to get my LCD display to move around vertically with the joystick I have attached to it. I have a feeling with a tip this could be a very simple fix, but I'm just stuck. So the brief of this is that I need someone to fill in the ???'s for me provided in my example code.

//Include the LCD Library.
#include <LiquidCrystal.h>
#include <Wire.h>
//Declare the LCD object and define pins.
#include <MFRC522.h>
#include <SPI.h>

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define SAD 10
#define RST 5

//Ignore The below line it is for the master code
#define I2C_ADDR    0x27 // <<----- Add your address here.  Find it from I2C Scanner
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7

int n = 1;

LiquidCrystal_I2C  lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup() {

//Booting the LCD
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH);
  lcd.home (); // go home
  lcd.cursor();

//Starting settings
  lcd.begin(1,0);
  lcd.clear();

}

//Sometimes you have to hit reset on the device

//Joystick Defaults X=484 Y=513

void loop() {
  lcd.setCursor(0,0);
  lcd.print("Example");
  delay(100);

for (int positionCounter = 0; positionCounter = 1; positionCounter++) {
if(analogRead(1) > 584) {
  lcd.scrollDisplayLeft();
  delay(30);
  } else if(analogRead(1) < 384) {
    lcd.scrollDisplayRight();
    delay(30);
  } else if(analogRead(0) < 413) {
     lcd.???????????????????();
     delay(30);
  } else if(analogRead(0) > 613) {
     lcd.??????????????????();
     delay(30);
    }
  }
}


texts:
I've already sent you the code but you told me to format it, so I tried this way ..

the problem I got is it doesn't read good the 2 slave (sender) to the master

(reader) ...you told me LAST TIME (DON'T DO SERIAL PRINTLN IN THE CALLBACK

ROUTINE) so I tried this code (I've got some data from both but not in order)

here's the slave 1 and 2 code (I only change the  slavedeviceId address)

#include "Wire.h"

//
// i2c_test_01

//
// This demonstrates a master transmitting to a slave.
//

// The master transmits a value read from an analogue port.

// The slave sends the value to the serial device.
//

byte x = 0;
//
const byte AnalogueInputPin = 0;

const byte SlaveDeviceId = 2;

void setup() {
  // Start I2C bus as master
  Wire.begin();
}

void loop() {
  int input0 = analogRead(x);
  // Send two bytes to slave.
  Wire.beginTransmission(SlaveDeviceId);
  Wire.write(input0 >> 8);
  Wire.write(input0 & 255);
  Wire.endTransmission();

  delay(10);

  x++;
  if (x == 4) {
    x = 0;
  }

  delay(40);

}

here's the master (reader)

thanks for your time it is realy intructive for me !!!

#include "Wire.h"

const byte SlaveDeviceId = 1;
const byte SlaveDeviceId2 = 2;
int S1;
int S2;
int c;
int cc;

void setup() {
  // Start I2C bus as a slave
  Wire.begin();
  Wire.onReceive(receiveCallback);
  Serial.begin(9600);
}

void SLAVEone() {
  Wire.begin(SlaveDeviceId);
  delay(5);
  Wire.onReceive(receiveCallback);
  delay(5);
}

void SLAVEtwo() {
  Wire.begin(SlaveDeviceId2);
  delay(5);
  Wire.onReceive(receiveCallback2);
  delay(5);
}

void receiveCallback(int aCount) {
  if(aCount == 2) {
    int receivedValue  = Wire.read() << 8;
    receivedValue |= Wire.read();
    //Serial.print(c);
    //Serial.print(" S1 = ");
    //Serial.println(receivedValue);
    S1 = receivedValue;
  } else {
    Serial.print("Unexpected number of bytes received: ");
    Serial.println(aCount);
  }
  c++;
  if (c == 4) {
    c = 0;
  }
}

void receiveCallback2(int aCount2) {
  if (aCount2 == 2) {
    int receivedValue2  = Wire.read() << 8;
    receivedValue2 |= Wire.read();
    // Serial.print(cc);
    //Serial.print(" S2 = ");
    //Serial.println(receivedValue2);
    S2 = receivedValue2;
  } else {
    Serial.print("Unexpected number of bytes received: ");
    Serial.println(aCount2);
  }
  cc++;
  if (cc == 4) {
    cc = 0;
  }
}

void loop() {
  for(int y = 0; y <= 3; y++) {
    SLAVEone();
    Serial.print(c);
    Serial.print(" = S1 = ");
    Serial.println(S1);
    delay(10);
  }
  for(int y = 0; y <= 3; y++) {
    SLAVEtwo();
    Serial.print(cc);
    Serial.print(" = S2 = ");
    Serial.println(S2);
    delay(10);
  }
}


texts: i have a problem with mdns i'm using an ESP8266

texts: I am working on a project on which I have to drive a DC 12V motor. I use an ESP8266 I manage to manage my engine remotely but my only problem is the mdns I use the mdns but it does not work. when I upload no error is displayed but I can not access my esp using his name.local


texts: Burning bootloader and uploading sketch on ATMEGA328

texts:
I have a ATMEGA328-PU (not a atmega328P-PU) and managed to install the boot loader on it using an Uno as ISP, but now i can not upload any sketch, this are the steps I've done so far:

connected this pins:

reset to pin10

11 to 11

12 to 12

13 to 13

and 5V to 5V and ground to ground.

uploaded ArduinoISP from examples and then changed the programmer to Arduino as ISP.

Then i changed this line in avrdude.conf:

part parent "m328"
    id          = "m328p";
    desc        = "ATmega328P";
    signature       = 0x1e 0x95 0x0F;

    ocdrev              = 1;
;

to:

part parent "m328"
    id          = "m328p";
    desc        = "ATmega328P";
    signature       = 0x1e 0x95 0x14;

    ocdrev              = 1;
;

selected burn bootloader and uploaded the boot loader with success.

and then i removed pin 10 to 13 and connected reset to reset, RX to RX and TX to TX and removed the chip from Arduino UNO.

added this lines to boards.txt:

##############################################################

uno328.name=Arduino328

uno328.vid.0=0x2341
uno328.pid.0=0x0043
uno328.vid.1=0x2341
uno328.pid.1=0x0001
uno328.vid.2=0x2A03
uno328.pid.2=0x0043
uno328.vid.3=0x2341
uno328.pid.3=0x0243

uno328.upload.tool=avrdude
uno328.upload.protocol=arduino
uno328.upload.maximum_size=32256
uno328.upload.maximum_data_size=2048
uno328.upload.speed=115200

uno328.bootloader.tool=avrdude
uno328.bootloader.low_fuses=0xFF
uno328.bootloader.high_fuses=0xDE
uno328.bootloader.extended_fuses=0xFD
uno328.bootloader.unlock_bits=0x3F
uno328.bootloader.lock_bits=0x0F
uno328.bootloader.file=optiboot/optiboot_atmega328.hex

uno328.build.mcu=atmega328
uno328.build.f_cpu=16000000L
uno328.build.board=AVR_UNO
uno328.build.core=arduino
uno328.build.variant=standard

Selected that from board menu changed the programmer to AVRISP mkll and tried to upload the blink sketch but it stuck on "uploading" and after a while says "an error occurred during upload".

I triple checked the wiring!


texts:
I am studying NRF24L01+ module. I see, that only 6 receivers can be connected with the transmitter, via their unique pipes. What I can’t get is why the pipe id (address) has 5 long bytes.

As to me,1 byte would be much more than enough.
What is the purpose in 5-byte address in 5 bidirectional communications?


texts:
Ok, serialEvent "runs after loop()" and it is not an interrupt.
AS far as I know main() has two functions  - setup and "infinite" loop.
So where does serialEvent comes in?

And if I do not want loop()  to run and use only setup than  I cannot use serialEvent.


texts:
I am trying to read a specific register from a device. In this case I am trying to read the value stored in register 0X1F from slave device 0x08. On the scope I see writes for

ADDRESS_SLAVE(Wire.beginTransmission), ADDRESS_TESTCOMP0 (Wire.write)

and

ADDRESS_TESTCOMP0 (Wire.requestFrom(ADDRESS_TESTCOMP0,8))

but I don't see the register values reading out.  Here is my code:

#include <Wire.h>

int ADDRESS_SLAVE = 0X08;
int ADDRESS_TESTCOMP0 = 0X1F;

void setup()
{
 Wire.setClock(3400000);
 Wire.begin();
 Serial.begin(9600);
}

void loop()
{
   Wire.beginTransmission(byte(ADDRESS_SLAVE));
   Wire.write(byte(ADDRESS_TESTCOMP0));
   Wire.endTransmission(byte(ADDRESS_TESTCOMP0));

   Wire.requestFrom(ADDRESS_TESTCOMP0,8);
   char read = Wire.read();
   Serial.println(read);

   delay(1000);
}


texts: How to keep the regulator cool while battery powering the arduino and accessories?

texts:
I'm trying to build a battery operated hand lantern. It has the Arduino, an MPU6050 accelerometer, and 4 APA106 (WS2812B-like) LEDs.

If everything's powered through the Arduino's 5V pins, that's 80mA for the Arduino, 240mA for the 4 LEDs, and let's round up to 5 mA for the MPU6050.

If I'm using 5x AA batteries for 7.5V (at full charge) that should be 2.5V * 325mA of power wasted or just under a watt that'll be heating up the regulator? I'm not sure if that's huge or tiny or in between or what.
What's the most sane way to power this device for an absolute newbie?


texts: Shall an active piezo buzzer module draw as much as 10mA on its signal pin?

texts:
I have connected an active piezo buzzer to my arduino: KY-012 Active buzzer module.

I was a bit surprised that it drew like ~10mA on the signal pin from my nodemcu, which I find a bit weird, since the signal generator itself is powered separately. Even if 10mA is in spec of the GPIO pins I wonder if that much current is considered a normal amount to expect.

The module draws an additional ~10mA from the power supply line.

Has probably someone the possibility to provide comparable measurements?