texts:
I'm using Arduino Uno controller

How it is possible to know if controller connected to PC via USB, to detect if wire is plugged and get condition for variable in sketch.

I've tried Serial.available(), but I'm not sure, if I can do it this way:

if (Serial.available())
{
   val = true;
}
else
{
   val = false;
}

I want use this condition to avoid setup() commands by some unexpected reason in case if controller powered only with adapter


texts:
I am trying to run 2 TCS3200’s from one Arduino Due. Next, I must increase to 4 sensors. I need to read the data from the 2 digital pins but how do I read both within the same loop rather than in series to save time. The code reading one sensor tasoOutPin1 (pin 10) works but why can’t I place the second read command int detectColor(int taosOutPin2) before the { symbol?

int detectColor(int taosOutPin1) {

float white1 = colorRead(taosOutPin1,0,1);
float red1 = colorRead(taosOutPin1,1,1);
float blue1 = colorRead(taosOutPin1,2,1);
float green1 = colorRead(taosOutPin1,3,1);
}

Thanks,

Scott


texts: MPU6050 Accel/Gyro no-interrupt gives erratic accel readings

texts:
I am using the Electronic Cats MPU6050 lib to interface with an MPU6050 on an ESP32 without interrupt pin.
The basic code reads data from the MPU6050 and then displays it on the OLED
However the readings are very erratic. Even with the MPU taped to a table to give stability, the readings are very erratic and occasionally read close to 2g without any movement at all
#include "heltec.h"
#include "SSD1306Ascii.h"

#include "SSD1306AsciiWire.h"
#include "MPU6050_6Axis_MotionApps20.h"
#include "Wire.h"

SSD1306AsciiWire oled;

MPU6050 mpu;

bool dmpReady = false;
uint8_t devStatus;
uint16_t packetSize;
uint16_t fifoCount;
uint8_t fifoBuffer[64];
float MaxGx = 0, MaxGy = 0, MaxGz = 0;

Quaternion q; // [w, x, y, z] quaternion container

void setup() {
Heltec.begin(true /DisplayEnable Enable/, false /LoRa Enable/, true /Serial Enable/);

  oled.begin(&Adafruit128x64, 0x3C, 16);
  oled.setFont(System5x7);
  oled.clear();

  Wire.begin();  //pin 21 and 22 for ESP32
  Wire.setClock(400000);

  Serial.begin(115200);

  Serial.println(F("Initializing I2C devices..."));
  mpu.initialize();

  Serial.println(F("Testing device connections..."));
  Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));

  Serial.println(F("Initializing DMP..."));
  oled.setCursor(0,0);
  oled.println("Calibrate Acc/Gyro");
  devStatus = mpu.dmpInitialize();

  mpu.setXGyroOffset(220);
  mpu.setYGyroOffset(76);
  mpu.setZGyroOffset(-85);
  mpu.setZAccelOffset(1788); // 1688 factory default for my test chip

if (devStatus == 0) {
    mpu.CalibrateAccel(6);
    mpu.CalibrateGyro(6);
    mpu.PrintActiveOffsets();
    Serial.println(F("Enabling DMP..."));
    oled.print("Accel/Gyro Ready");
    delay(1000);
    oled.clear();
    mpu.setDMPEnabled(true);

    Serial.println(F("DMP ready!"));
    dmpReady = true;

    packetSize = mpu.dmpGetFIFOPacketSize();
} else {
    // ERROR!
    // 1 = initial memory load failed
    // 2 = DMP configuration updates failed
    // (if it's going to break, usually the code will be 1)
    Serial.print(F("DMP Initialization failed (code "));
    Serial.print(devStatus);
    Serial.println(F(")"));
}

}

void loop() {
// if MPU6050nprogramming failed, don't do anything
if (!dmpReady) return;

while (fifoCount < packetSize) {
    if (fifoCount < packetSize) {
      // try to get out of the infinite loop
      fifoCount = mpu.getFIFOCount();
    }
}

fifoCount = mpu.getFIFOCount();
if(fifoCount < packetSize){
      }
else if (fifoCount >= 1024) {
    // reset so we can continue cleanly
    mpu.resetFIFO();
  //  fifoCount = mpu.getFIFOCount();  // will be zero after reset
    Serial.println(F("FIFO overflow!"));

}

while(fifoCount >= packetSize){
mpu.getFIFOBytes(fifoBuffer, packetSize);
fifoCount -= packetSize;
}

        mpu.dmpGetQuaternion(&q, fifoBuffer);

         if (abs(q.x) > abs(MaxGx))
          {
            MaxGx = q.x;
          } else{
            MaxGx = MaxGx;
          }

        if (abs(q.y) > abs(MaxGy))
          {
            MaxGy = q.y;
          } else{
            MaxGy = MaxGy;
          }

    if (abs(q.z) > abs(MaxGz))
      {
        MaxGz = q.z;
       } else{
        MaxGz = MaxGz;
       }

      oled.setCursor(0,0);
      oled.clearToEOL();
      oled.println("ACCEL  X     Y     Z");
      oled.setCursor(0,1);
      oled.clearToEOL();
      oled.setCursor(20,1);
      oled.print(q.x,2);
      oled.setCursor(60,1);
      oled.print(q.y,2);
      oled.setCursor(95,1);
      oled.println(q.z,2);

      oled.setCursor(0,4);
      oled.println("MaxG   X     Y     Z");
      oled.setCursor(0,5);
      oled.clearToEOL();
      oled.setCursor(20,5);
      oled.print(MaxGx);
      oled.setCursor(60,5);
      oled.print(MaxGy);
      oled.setCursor(95,5);
      oled.println(MaxGz);

}


texts:
Having issues troubleshooting IO errors using i2C . Running a Python script on a raspberry Pi as master talking to an Arduino slave.
The problem is that when making any change in my code that results in an IO error, i2C seems to drop the connection to my arduino entirely!

Running

 i2cdetect -y 1

Shows no connected devices! And I am forced to reboot!

Does anyone know of a way to avoid this? i2C seems very fragile in this regard.


texts: Unable to upload sketch on Mac OSX El Capitan

texts:
I recently dusted off an old Arduino Duemilanove to play with. I can connect it to my Mac laptop with the same USB cable I used previously and I'm able to monitor the serial port and see the output from the last sketch I uploaded (five years ago). Everything is unplugged from the board.

When I try to upload a new sketch, the Arduino IDE gets stuck on Uploading... indefinitely:

Using Port                    : /dev/cu.usbserial-A800eGZI
Using Programmer              : arduino
Overriding Baud Rate          : 19200

The board itself has the green PWR LED and amber TX LED on solid once the currently loaded sketch starts running. Initiating an upload causes the amber L LED to blink three times, then the RX LED blinks twice, and finally the TX LED on solid.

Here is the exact board: https://www.sparkfun.com/products/retired/666

My research into this issue produced many suggestions that have not resolved the problem...

I disabled the built-in FTDI driver:

sudo kextunload -b com.apple.driver.AppleUSBFTDI

And made sure the FTDI driver from ftdichip.com was loaded:

sudo kextload /Library/Extensions/FTDIUSBSerialDriver.kext

I tried csrutil enable --without kext against my better judgement and saw no change.

I also tried a completely separate machine -- my PC running Windows 10 -- and the upload hung there too.

I have tried timing the upload to coincide with a board reset, hoping to sneak my upload in before the current sketch starts running. I did this a lot and got no satisfaction.

I haven't given up yet; there are too many signs of life to think that it's unrecoverable. I'm looking for more suggestions on how to troubleshoot.

I have already ordered another Arduino -- hopefully I can use it to burn the bootloader on the Duemilanove.


texts:
I am new to Arduino, however I have experience in web development, lately I have been using, meteor js and the mean stack for different projects. However, I am open to trying any language for development.

What I am trying to do is build a simple application to control the LED on the Arduino over the web.

I am working with another person, and the Arduino will be behind a firewall so I am not sure how to access it via the internet. I do have access to an Arduino Uun that I can use for testing at home which does have linio connected via bridge, which I don't quite understand what that does.

I've also heard of this, but would like to stay away from third party builds as much as possible if I can do it myself.

Whats the common way to do this with an Arduino behind a firewall? How do I do this with a Arduino Yun? Is it easier with a Yun?


texts: How do I connect this display to an Arduino Uno

texts:
I am completely new to this, and a novice when it comes to electronics but I want to learn.
Can someone pls tell me how I would connect the display in the photo here with an Arduino Uno (which I have ordered).  The plan is to interface my car with this transparent display to produce a form of HUD.
I have done some searching but to no avail so far, would appreciate being pointed in the right direction.
many thanks


texts: How do i generate exact number of PWM pulses in arduino?

texts:
So my code here generates a PWM wave of 38Khz on Port B pin 7 of arduino Mega 2560 . For that I have used a prescaler of 8 and then set the ICR1 register value to 51 . I have also set the WGM10 ,WGM11, WGM12 and WGM13 bits to 1 , to enable fast PWM mode with Top reference value as ICR1 contents . Similarly , COM1A1  is set , to enable clear output on compare equal else high . CS11 is set to high to enable the prescaler 8 .

My code is as follows -

#include<avr/io.h>
#include <avr/iomxx0_1.h>
#include<util/delay.h>
void pwm_init()
{
        // Configure PB.7 as output pin
        DDRB |= (1<<PB7);
        TCCR1A =  (1<<WGM11) | (1<<WGM10) | (1<<COM1A1);
        TCCR1B =(1<<WGM12) | (1<<WGM13) | (1<<CS11);
        ICR1 = 51;
}

void pwm_generate()
{
    OCR1A = (50 * 52)/100 ;
}
int main()
{
pwm_init();
pwm_generate();
}

What I require from the program is that , it should stop producing pwm pulses once a sufficient number of pulses are transmitted . For example - The program should output 7 pwm pulses of 38Khz and then it should give logic 0 as output for specified time period . And then after that specified period , it should produce 38 Khz pwm wave again of say, 5 pulses and then again logic 0 for certain duration . And so on ...
How do i achieve this ?

PS- This program is actually being written to simulate a pwm wave required by the IR transmitters in TV remote . The PWM pulses represent the ON period and the Logic 0 conditions would represent the gap in between two successive train of PWM pulses.

Picture of waveform for reference -


texts: Disable other buttons while one of buttons is pressed

texts:
I'm making a project with three buttons. What I'm trying to do is to disable other buttons (make them not respond to a click event) when one of three buttons is pressed.

For now I have this code:

    const int button1=3;
    const int button2=4;
    const int button3=5;

    int button1State=0;
    int button2State=0;
    int button3State=0;

    void setup() {
    pinMode(button1, INPUT);
    pinMode(button2, INPUT);
    pinMode(button3, INPUT);
    }

   void loop() {
   button1State=digitalRead(button1);
   button2State=digitalRead(button2);
   button3State=digitalRead(button3);

   if( button1State == HIGH){
   // do some stuff
   }

    if( button2State == HIGH){
    // do some stuff
    }

    if( button3State == HIGH){
    // do some stuff
    }

    }

Do you have any ideas how I could do it?

Thanks is advance for any suggestions!


texts: Converting Random Binary Data to PWM Signal

texts:
I am using a Arduino Due. I am doing a project on Visible Light Communication. I need to convert a binary data into a PWM Signal. Can anyone suggest me a method of generating that PWM Signal based on the binary data given?

Thank You.


texts: Sending A String from a Website to Arduino

texts: I'm quite new to Arduino and have looked at many tutorials featuring an Arduino requesting data from a web server through a Wifi Shield, but haven't seen one featuring the sending of data from a website/server to an Arduino. I'm attempting to use a JavaScript then PHP script to send a string variable to the Arduino, which would then of course run its code at this point. Is this possible if I have a Wifi Shield and the Arduino's IP address?


texts: How do I pull up D1-D6 using 10k ohm resistors?

texts: I'm using push buttons to control CR servos (button1=turn CW; button2=turn CCW). How do I pull up D1-D6 and what does that do exactly? I can't find a tutorial that explains it well enough how to use the resistors.


texts: #include  Error with WiFiClientSecureBearSSL.h

texts:
I am new to the Arduino world and it seems that this simple problem is keeping me at the start line.

I use the Generic ESP8266 Module as Board
In my sketch I just write:

#include < ESP8266WiFi.h >
void setup(){}
void loop(){}

The ERROR is :

BearSSLHelpers.h:148:34: error: 'virtual const unsigned char* BearSSL::HashSHA256::oid()' marked override, but does not override

 virtual const unsigned char *oid() override;

                              ^

How am I going to solve that? Any help is appreciated.


texts: Are there any electro-chemical sensors available to measure nutrient contents of soil?

texts:
I want to develop a soil fertility testing device and need an electro chemical sensor to do so.
I searched the online available sensors but didn't get any source. Does anyone knows anybody in development of such sensors ?


texts: How can I start freshly? Libraries mess Wemos D1 Mini

texts: I am using a wemosd1 MINI which has a ESP8266 module. I am using it for an IoT project, however a lot has been going wrong.  With libraries and version types. I want to start over but noticed that simply reinstalling arduino didnt do tha trick. How can i restart?


texts:
I am trying to connect to Wi-Fi with Digital pin declaration in setup() function it's not connecting to wi-fi. But connecting to wi-fi without digital pin diclaration. `

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
int m1 = 5;
int m2 = 6;
const char* ssid = "KS Infotech";
const char* password = "kalamsalam";
String readc = "";
void setup () {
pinMode(m1, OUTPUT);
digitalWrite(m1, LOW);
pinMode(m2, OUTPUT);
digitalWrite(m2, LOW);
Serial.begin(9600);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {

delay(1000);
Serial.print("Connecting..");

}

}

void loop() {
while (Serial.available()){  //Check if there is an available byte to read
delay(10); //Delay added to make thing stable
char c = Serial.read();
String T = String(readc);
    Serial.println(T);
if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status

HTTPClient http;  //Declare an object of class HTTPClient

http.begin("http://ksinfotech.co/kslab/write_to_database.php?incoming="+T+"&UID=surya");  //Specify request destination
int httpCode = http.GET();

if (httpCode > 0) { //Check the returning code

  String payload = http.getString();   //Get the request response payload
  Serial.println(payload);                     //Print the response payload
  if (payload == 'N');
  {
  digitalWrite(m1, HIGH);
  digitalWrite(m2, LOW);
  delay(2000);
  digitalWrite(m1, LOW);
  digitalWrite(m1, LOW);
}
      if (payload == 'F');
  {
  digitalWrite(m1, LOW);
  digitalWrite(m2, HIGH);
  delay(2000);
  digitalWrite(m1, LOW);
  digitalWrite(m1, LOW);
}

http.end();   //Close connection

}

delay(30000);    //Send a request every 30 seconds

}

The above code not working but the below code working.

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

const char* ssid = "KS Infotech";
const char* password = "kalamsalam";
String readc = "";
void setup () {

Serial.begin(9600);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {

delay(1000);
Serial.print("Connecting..");

}

}

void loop() {
while (Serial.available()){  //Check if there is an available byte to read
delay(10); //Delay added to make thing stable
char c = Serial.read();
if (c == '#'){
  break;                   //Stop the loop once # is detected after a word
}//Conduct a serial read
readc += c; //build the string- "forward", "reverse", "left" and "right"
}
String T = String(readc);
    Serial.println(T);
if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status

HTTPClient http;  //Declare an object of class HTTPClient

http.begin("http://ksinfotech.co/kslab/write_to_database.php?incoming="+T+"&UID=surya");  //Specify request destination
int httpCode = http.GET();
 //Send the request

if (httpCode > 0) { //Check the returning code

  String payload = http.getString();   //Get the request response payload
  Serial.println(payload);                     //Print the response payload

}

http.end();   //Close connection

}

delay(30000);    //Send a request every 30 seconds

}


texts: Serial Communication between ESP8266 and Arduino Uno

texts:
I want to send data from arduino to ESP8266. I have done all the RX and TX connections.
The problem is that data is not sent every second, it stops after a single byte. When I remove the arduino cable then data is read.

My Arduino Code :

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

void loop() {

    Serial.write("50");
    delay(1000);
}

My ESP8266 Code :

void setup() {

Serial.begin(9600);

  // connect to wifi.
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);

  while (WiFi.status() != WL_CONNECTED) {

    delay(500);
  }
  Serial.println("Connected !");

}

void loop() {

 Serial.print(Serial.readString());

}


texts: Working on my second project and I'm confused about proper procedure for turning on the arduino

texts:
The first project I did was just making the led blink (it was pulsing a signal to pin 13. I'm guessing most of you have seen similar tutorials).

Today I plugged in some wires and resistors and wrote a program for a volt meter.

How am I to stop the pulses on the output pins from my previous project from messing everything up in the newer project in that interval of time after plugging in the usb and before compiling/ uploading the new code?

The question occurred to me when I saw the led blinking from the last project, before I could hit the upload button... maybe I'm wrong, but I'm envisioning this causing problems for me in the future as my circuits become more and more complex.


texts:
class A {
    virtual ~A();
}

class B : public A {
    public:
      int foo;
}

void bar(A *foo_){
    B* b = dynamic_cast<B*>(foo_);

    if(b != nullptr){
         cout << (*foo_)->foo << endl;
    }
}

int main(){
    B b{};
    bar(b);
}

Compiling error:

error: 'dynamic_cast' not permitted with -fno-rtti

I thank sincerely for the help.


texts:
I'm working on a Android App able to update the content of my Arduinos. Start to work (reset the Arduino, communicate with STK500 protocol, get id of ATmega and so on).
But I face a question about the two hex files produced by the compiler.
Some FAQ, forum... give replies about the two, explaining: "the ino.hex file has only the code and the other as the code + the code of the bootloader".
After having a look at the hex files, that's true: you can find in the "with_bootloader" the code of the bootloader.

The "why" gives the following answer: "that's because when the bootloader receive the code, it erases the flash so the installed bootloader destroy itself. So if you send without bootloader, you will not have a bootloader any more in the Arduino".

Problems:

1) In that case, in order to change the bootloader why use an ISP? Just add the HEX code of your new bootloader in the main HEX file, send it with AVRDUDE and that's all...
2) When you use the Arduino IDE with AVRDUDE in Verbose mode you'll see AVRDUDE send the file....
without the bootloader!

So the question is: when you want to update the content of the flash, sending "manually" the data using STK500 protocol, do you need to send the "ino.hex" or the "ino.with_bootloader.hex" file? And why?


texts:
So my project is including detecting the temperature in the room by using dth11 sensor.
my idea is to add 3 LED lights were each light represent the temperature if its cold or hot or perfect.

the wiring and coding is done and it's working .However, i'm having a problem were the perfect temperature is always on no matter if the temperature is hot or cold.
example: if the temperature is cold the cold LED will blink and the perfect temperature LED will be on.

#include <Adafruit_Sensor.h>
#include <DHT.h>
#define DHTPIN A0
#define DHTTYPE DHT11
#define LED_TOO_COLD 6
#define LED_PERFECT 8
#define LED_TOO_HOT 7
DHT dht(DHTPIN, DHTTYPE);
void setup() {
  Serial.begin(9600);
  Serial.println("DHT11 test!");

  dht.begin();
}

void loop() {

  pinMode (6 , OUTPUT);
  pinMode (7 , OUTPUT);
  pinMode (8 , OUTPUT);
  delay(2000);

  float h = dht.readHumidity();
  float t = dht.readTemperature();
  float f = dht.readTemperature(true);

  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.println(" *C ");
  if (t < 22) {
    Serial.println("Too cold!");
    digitalWrite(6, HIGH);
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    delay (2000);
  }
   if (t >26) {
    Serial.println("Too hot!");
    digitalWrite(7, HIGH);
    digitalWrite(6, LOW);
    digitalWrite(8, LOW);
    delay (2000);

  } else {
    Serial.println("Perfect temperature!");
    digitalWrite(8, HIGH);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    delay (2000);
  }

}


texts: Controlling two AC devices, device turning on incorrectly

texts:
I am making use of the code below to control the speed of an AC fan and the intensity of an AC Lamp with an Uno.

The problem I am having is that, when I set the lamp intensity to low or medium, the fan turns on at a very low speed as well, and I cannot turn it off even when setting the fan to off.

Also if I turn the lamp on and then off, the fan (which is still set as off), will spin slowly for a second or two in random intervals.

For troubleshooting purposes, I did separate this program into two programs, controlling each device and its circuit separately, and it works perfectly, but when I combine them, I get the above problem.

Any assistance in troubleshooting or ideas to solve this would be appreciated.
Haven't attempted AC control before.

int PWM = 3;
int FAN = 4;
int dimming;

void setup()
{
  Serial.begin(9600);
  Serial.println("Serial connection started, waiting for instructions…n0 =     Offn1 = 25%n2 =50%n3 = 75%n4 = 100%");
  pinMode(PWM, OUTPUT);
  pinMode(FAN, OUTPUT);

  attachInterrupt(0, zero_crosss_int, RISING);
}

void zero_crosss_int()
// function to be fired at the zero crossing to dim the light
{
  int dimtime = (75 * dimming);  // For 60Hz =>65
  delayMicroseconds(dimtime);    // Off cycle
  digitalWrite(FAN, HIGH);   // triac firing
  delayMicroseconds(10);         // triac On propogation delay
  //(for 60Hz use 8.33)
  digitalWrite(FAN, LOW);    // triac Off
}

void loop ()
{
  if (Serial.available()) {
    char ser = Serial.read(); //read serial as a character

    switch (ser)
{

  /* Lamp Control  */

  case '0':
    analogWrite(PWM, 0);  //lamp Off
    break;
  case '1':
    analogWrite(PWM, 50);  //lamp low
    break;

  case '2':
    analogWrite(PWM, 130); //lamp medium
    break;

  case '3':
    analogWrite(PWM, 255); //lamp high
    break;

  /* Fan Control  */

  case '4':
    dimming = 128;  //fan off
    break;

  case '5':
    dimming = 90; //fan low
    break;

  case '6':
    dimming = 65; //fan medium
    break;

  case '7':
    dimming = 35; //fan high
    break;

  default:
    Serial.println("Invalid entry");

    }
  }
}

The circuits it controls is based on these :

Lamp

Fan

Also, these circuits and code are based on these post, if it may interest you:

Lamp
PWM AC Lamp

Fan
Dimmer AC Fan


texts:
I have 2 Xbee S1 models, 2 Arduino Wireless Proto Shields, 2 Arduino Megas, and an Xbee Explorer and am trying to make one Arduino Trigger another Arduino to send a pulse, I have tried to set up many tutorials on youtube and digi, but still cannot get it to work.

Can someone walk me through the steps for setup?


texts: Gas Sensors with Arduino + Interfacing Circuit

texts:
I am intended to use Gas Sensors (MQ series) on protoboard so I connect it to Arduino and perform analogue read.
I would like to request if possible to get the interfacing circuit (resistors, amplification.. etc.) or if there are schematics available.

Also, when I read the data digitized into 10bits ADC value, how can I convert it into units (ppm)?

Thank you so much in advance.


texts:
I'm using the Marlin 2.0.3 for a 3D printer project. I'd like to tear apart the code, but I don't see a #include to anything in the Marlin.ino, Configuration.h, Configuration_adv.h, nor Version.h.

If I use a verbose compilation, I see the ./src/HAL/HAL_AVR/HAL.cpp is the first thing it tries to include, but I don't see that writen in the code.

How does it know what to include?

Incase you can answer without downloading it:
Marlin.ino and Version.h is just comments.
Configuration.h and Configuration_adv.h are just a bunch of #defines.

Link to Marlin: https://github.com/MarlinFirmware/Marlin/releases/tag/2.0.3


texts:
How to generate 100khz square wave with 50% duty cycle using arduino uno
The following code was tried but did not give appropriate output

void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delayMicroseconds(5); // wait for 5 micro seconds, 100khz frequency with  50%
                           // duty cycle
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delayMicroseconds(5);              // wait for 5 micro seconds
}


texts: Firmata: how to set a particular pin to high on boot?

texts:
I'm working on a project that use J5, so is using the standard firmata, this project is using an opto 4 channel relay, when the board is booting the pins state are set to low, so as soon as I power the board my relay goes to a close state and make my motor run... this is a wrong behaviour for my purpose. How can I avoid that? By googleing around I stumble acros this:

A possible solution

but I can't uderstand if this is what I'm looking for.. plus I need only the PIN 7 to be set high on boot, any help please?

EDIT: SCHEMATICS

4 Channel 5V Relay Module


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

avrdude: can't open input file C:\Users\PETER_~1\AppData\Local\Temp\arduino_build_223764/nyu_probe_activity1_code.ino.hex: No such file or directory
avrdude: read from file 'C:\Users\PETER_~1\AppData\Local\Temp\arduino_build_223764/nyu_probe_activity1_code.ino.hex' failed
An error occurred while uploading the sketch
Invalid library found in D:\programs\ArDuInO\arduino-1.8.5\libraries\OLED_Mono_I2C: D:\programs\ArDuInO\arduino-1.8.5\libraries\OLED_Mono_I2C
Invalid library found in D:\programs\ArDuInO\arduino-1.8.5\libraries\OLED_Mono_I2C: D:\programs\ArDuInO\arduino-1.8.5\libraries\OLED_Mono_I2C

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


texts: Output set to 'low' when new variable in buffer

texts:
I would like to turn on and off the output of two pins on my arduino independently from each other. However, so far all my attempts have failed.

My current idea is to save the status (which I chose to be 0 as 'low' and 'high' as 1) of each of the pins in an integer array and then change the status of the pin depending of the entry in the variable. However, the entries in the variable are always set back to 0 and I do not know why this is happening.

This is my arduino code

const byte numChars = 32;
byte receivedChars[numChars];
boolean newData = false;
const int num_of_pins=2;
int output_pins[num_of_pins]={22,26};
int status_pins[num_of_pins]={0,0};

void setup() {
    int ii=0;
    Serial.begin(9600);
    for(ii=0; ii<num_of_pins; ii++){
        pinMode(output_pins[ii],OUTPUT);
    }

}

void loop() {
    recvWithStartEndMarkers();
    chooseFunction();
}

void chooseFunction(){
  if (receivedChars[0]==0){
    shutter();
    }
}

void shutter(){
        // get number of pin
        int pin_number_rcvd;
        int ii;
        int pin_status_rcvd;
        pin_number_rcvd=receivedChars[1];
        pin_status_rcvd=receivedChars[2];
        //check all status of pins and turn on and off
        for (ii=0; ii<num_of_pins; ii++){
          if (pin_number_rcvd==output_pins[ii]){
            status_pins[ii]=pin_status_rcvd;
          }
          if (status_pins[ii]==0){
            digitalWrite(output_pins[ii],LOW);
          }
          if (status_pins[ii]==1){
            digitalWrite(output_pins[ii],HIGH);
          }
        }
}

void recvWithStartEndMarkers() {
    static boolean recvInProgress = false;
    static byte ndx = 0;
    byte startMarker = 8;
    byte endMarker = 9;
    byte rc;

    while (Serial.available() > 0 && newData == false) {
        rc = Serial.read();

        if (recvInProgress == true) {
            if (rc != endMarker) {
                receivedChars[ndx] = rc;
                ndx++;
                if (ndx >= numChars) {
                    ndx = numChars - 1;
                }
            }
            else {
                receivedChars[ndx] = '\0'; // terminate the string
                recvInProgress = false;
                ndx = 0;
                newData = true;
            }
        }

        else if (rc == startMarker) {
            recvInProgress = true;
        }
    }
}

I use pyserial to send the input data to the arduino. my python code:

import serial
import time, struct, sys
ser=serial.Serial('COM17', 9600, timeout=10)
time.sleep(2)
ser.reset_input_buffer()
ser.reset_output_buffer()
pin_number= int(sys.argv[1])
high_or_low=int(sys.argv[2])

ser.write(struct.pack('>5B',8,1,pin_number,high_or_low,9))

I am using an ArduinoDue together with the arduino IDE.


texts:
Total Arduino newbie here.
I was playing with mBlocks, with the Arduino Uno extension enabled. That extension offers you to "update firmware" which I accidentally did. What exactly is this firmware? Is it just a compiled sketch or does it alter stuff like bootloader or reside permanently in the memory?


texts: Why does this code only compile when moving the setup() function or using an older Arduino IDE?

texts:
The following code does not compile using Arduino 1.8.13:
void setup() {}

template<typename T,size_t N>
struct foo {
  T t[N];
};

void ok() {
  foo<int,1> var;
}

void notOK( foo<int,1> &var) {

}

void loop() {}

Error message:
sketch_aug08a:13:13: error: variable or field 'notOK' declared void
 void notOK( foo<int,1> &var) {
             ^~~
sketch_aug08a:13:13: error: 'foo' was not declared in this scope
sketch_aug08a:13:17: error: expected primary-expression before 'int'
 void notOK( foo<int,1> &var) {
                 ^~~
sketch_aug08a:13:25: error: 'var' was not declared in this scope
 void notOK( foo<int,1> &var) {
                         ^~~
exit status 1
variable or field 'notOK' declared void

The code compiles when using Arduino 2:1.0.5+dfsg2-4.1 from Debian Stable or when changing it slightly so that the setup() function is moved further down:
template<typename T,size_t N>
struct foo {
  T t[N];
};

void ok() {
  foo<int,1> var;
}

void notOK( foo<int,1> &var) {

}

void setup() {}

void loop() {}

Why?


texts:
I'm having a strange issue where in order to get the expected serial output on my serial monitor, I have to set the baud rate on my serial monitor to be 8 times higher than the rate that i set in my Serial.begin(). For example, Serial.begin(4800) works with a serial monitor baud rate of 38400.

The setup is an atmega328P and an atmega8u2 built up on a breadboard similar to an UNO R1. I followed Nick Gammon's tutorial and his scripts to flash the 328P with the bootloader (http://www.gammon.com.au/forum/?id=11637), and I used the DFU programmer (on OS X) to flash the 8u2. When I plug my computer into the USB connector on the breadboard, the device correctly shows up as an Arduino Uno in my computer's devices list using lsusb. I can also flash sketches to the 328P using the breadboard tutorial (https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard).

The fact that I get the expected results on my serial monitor (even though it's at the wrong baud rate) leads me to believe my hardware is set up correctly. I'm thinking that it could be a bit/byte confusion in the firmware, has anyone encountered something like this or have ideas? I currently can't flash sketches over the USB connector and I believe it is due to the baud rate mismatch.


texts: I have an Arduino uno3 which gets data from a digital caliper and shows the data in serial monitor. Now I should make a connection between this Arduino and my Beaglebone black through SPI to get the data sent from caliper in Beaglebone black. and I don't know what to do and how to create codes related to this purpose.


texts: compiler says I have to declare my hexidacimal I try to compare

texts:
#include <IRremote.h>

int RECV_PIN = 11; // IR Receiver - Arduino Pin Number 11
IRrecv irrecv(RECV_PIN);
decode_results results;

int led = 12;

void setup() {
  pinMode(led, OUTPUT);
  digitalWrite(led, LOW);
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if(irrecv.decode(&results)) //this checks to see if a code has been received
{
    if(results.value == FF6897) //if the button press equals the hex value FF6897
    {
        digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
        delay(1000);               // wait for a second
        digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
        delay(1000);               // wait for a second//do something useful here
    }
    irrecv.resume(); //receive the next value
}
  }

The issue is in the second if in the void loop the error I get is

  exit status 1 'FF6897' was not declared in this scope

why does he do this? Why doesnt it just accept my IRcode for comparison.


texts: What are the parameters of the browseUrl() callback in the Ethercard library?

texts:
I'm reading a code that uses Arduino as a webclient and when he tries to catch the info from the site, he uses a callback with the following parameters:

static void response_callback (byte status, word off, word len)

Can anyone explain me how does each one of this parameters work exactly?

PS.: The example I got it from:

#include <EtherCard.h>

#define HTTP_HEADER_OFFSET 0
static byte mymac[] = {0x12,0x34,0x56,0x78,0x90,0xAB};
char website[] PROGMEM = "www.yourwebsite.com";

byte Ethernet::buffer[700];
static uint32_t timer = 0;

static void response_callback (byte status, word off, word len) {
  Serial.print((const char*) Ethernet::buffer + off + HTTP_HEADER_OFFSET);
}

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

  if (!ether.begin(sizeof Ethernet::buffer, mymac, 10))
  {
    Serial.println("Failed to access Ethernet controller");
    while(1);
  }
  else
    Serial.println("Ethernet controller initialized");
  Serial.println();

  if (!ether.dhcpSetup())
  {
    Serial.println("Failed to get configuration from DHCP");
    while(1);
  }
  else
    Serial.println("DHCP configuration done");

  if (!ether.dnsLookup(website))
  {
    Serial.println("DNS failed");
    while(1);
  }
  else
    Serial.println("DNS resolution done");

  ether.printIp("SRV IP:\t", ether.hisip);
  Serial.println();
}

void loop() {
  ether.packetLoop(ether.packetReceive());

  if (millis() > timer) {
    timer = millis() + 5000;
    ether.browseUrl("/", "yourpage.php", website, response_callback);
  }
}


texts:
My power supply is feeding the esp32-pico with 5v tho it says that there is 0 amps power drain, already there I know something isn't working since the power drain should be around 0.080amps, (it can be all the way up to 0.250amps if wifi on)
when I measure the vdda pin where the power goes into the chip it reads 3.3v which is perfect, but any of the other vdda power pins reads 0v, is the chip turned of cause I'm not powering the EN pin directly from the power supply?
in other words, do the other power pins turn off with the chip?
I have now tried pulling 3v straight from the power supply to the EN pin, and it then goes up to using around 0.160amps, but I still get nothing in the com port
a bit clueless for what is wrong?
other information:
I have a powerbumb turning the 5v into 3.3v
if EN = low: module is turned off if EN = high module is on
(don't leave EN floating)
https://www.espressif.com/sites/default/files/documentation/esp32-pico-d4_datasheet_en.pdf
(I know the antenna doesn't work)


texts: How come `MyClass.MyStaticMethod()` doesn't work, but `Serial.begin()` does?

texts:
MyProject.ino:

#include "MyClass.h"

void setup()
{
  Serial.begin(9600);
  // MyClass.MyStaticMethod();
  MyClass::MyStaticMethod();
}

Both uncommented lines work, but the commented (when uncommented, of course) results in this error: expected unqualified-id before '.' token.

Now, I know this is because of the incorrect scope-resolution. Yet, how come Serial manages to call static functions without the need to use :: to correction to scope-resolution.

How come MyClass.MyStaticMethod() doesn't work, but Serial.begin() does?


texts:
I really want to understand how can I use this library for my purposes.

I'm trying to encrypt a message that comes through the serial port of the Arduino, and send it through another serial port. But I'm having issues understanding how to use the library.
I have read the documentation of the library, but I still get errors, I need a little help with this.

This is the code I have (without involving the serial ports), initially I wanted to check if I could define my strings and use them in another way instead of using the TestVector Function:

 #include <Crypto.h>
 #include <Speck.h>
 #include <SpeckSmall.h>
 #include <SpeckTiny.h>
 #include <string.h>

 struct EncryptText
 {
     const char *name;
     byte key[32];
     byte plaintext[16];
     byte ciphertext[16];
 };

 EncryptText test ;

   static TestCipher {

   test.name = "Speck-128-ECB";
   test.key = {0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
                     0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00};
   test.plaintext = {0x6c, 0x61, 0x76, 0x69, 0x75, 0x71, 0x65, 0x20,
                     0x74, 0x69, 0x20, 0x65, 0x64, 0x61, 0x6d, 0x20};
  test.ciphertext = {0xa6, 0x5d, 0x98, 0x51, 0x79, 0x78, 0x32, 0x65,
                     0x78, 0x60, 0xfe, 0xdf, 0x5c, 0x57, 0x0d, 0x18};
   }

Speck speck;
SpeckSmall speckSmall;
SpeckTiny speckTiny;

byte buffer[16];

//void testCipher(BlockCipher *cipher, const struct TestVector *test, size_t keySize, bool decryption = true)
void testCipher(BlockCipher *cipher, size_t keySize, bool decryption = true)

{

    Serial.print(" Encryption ... ");
    cipher->setKey(key, keySize);
    cipher->encryptBlock(buffer, plaintext);

    for(byte b=0; b<16; b++)
   {
      Serial.print(buffer[b], HEX);
   }

    if (memcmp(buffer, ciphertext, 16) == 0)
        Serial.println("Passed");
    else
        Serial.println("Failed");

    if (!decryption)
        return;

    Serial.print(" Decryption ... ");
    cipher->decryptBlock(buffer, ciphertext);

    for(byte b=0; b<16; b++)
   {
      Serial.print(buffer[b], HEX);
   }
    if (memcmp(buffer, plaintext, 16) == 0)
        Serial.println("Passed");
    else
        Serial.println("Failed");
}

I'm getting the error: "exit status 1 'TestCipher' does not name a type"

EDIT: The full error that I get is:

 Speck_4-08-2017:27: error: 'TestCipher' does not name a type    static
 TestCipher {
           ^ Speck_4-08-2017.ino: In function 'void testCipher(BlockCipher*, size_t, bool)': Speck_4-08-2017:62: error:
 'key' was not declared in this scope
      cipher->setKey(key, keySize);
                     ^ Speck_4-08-2017:63: error: 'plaintext' was not declared in this scope
      cipher->encryptBlock(buffer, plaintext);
                                   ^ Speck_4-08-2017:70: error: 'ciphertext' was not declared in this scope
      if (memcmp(buffer, ciphertext, 16) == 0)
                         ^ Speck_4-08-2017:80: error: 'ciphertext' was not declared in this scope
      cipher->decryptBlock(buffer, ciphertext);
                                   ^ Speck_4-08-2017.ino: In function 'void perfCipher(BlockCipher*, const TestVector*, size_t, bool)':
 Speck_4-08-2017:104: error: 'key2' was not declared in this scope
          cipher->setKey(key2, keySize);
                         ^ Speck_4-08-2017.ino: In function 'void setup()': Speck_4-08-2017:158: error: 'testVectorSpeck128' was not
 declared in this scope
      testCipher(&speck, &testVectorSpeck128, 16);
                          ^ exit status 1 'TestCipher' does not name a type

Any guidance would be very helpful.


texts: typedef function pointer array declaration problem

texts:
Thanks for all your feedback. It helped.

I rewrote this yet another time and this time it works perfectly. I included three variations: a simple example using an array of function pointers, a Lambda version and a complex version like what I started with.

#define TASK_COUNT          3

typedef void ( *taskPointer ) ( );

//  Simple Version:
void taskS1 () { Serial.println ( ( char* )"SIMPLE TASK 1" ); }
void taskS2 () { Serial.println ( ( char* )"SIMPLE TASK 2" ); }
void taskS3 () { Serial.println ( ( char* )"SIMPLE TASK 3" ); }

//  Array of pointers to tasks
taskPointer callSimpleTask [ ] = {
taskS1,
taskS2,
taskS3,
};

//  Run the simple test
void showSimpleVersion () {
    Serial.println ( F ( "\nSimple Version:" ) );
    for (uint8_t i = 0; i < TASK_COUNT; i++) {
        callSimpleTask [ i ] ();
    }

}

//  Lambda Version: No separate task definitoins
void ( *callLambdaTask [ ] ) ( ) = {
    [ ] {Serial.println ( ( char* )"LAMBDA TASK 1" ); },
    [ ] {Serial.println ( ( char* )"LAMBDA TASK 2" ); },
    [ ] {Serial.println ( ( char* )"LAMBDA TASK 3" ); },
};

//  Run the Lambda test
void showLambdaVersion () {
    Serial.println ( F ( "\nLambda Version:" ) );
    for (uint8_t i = 0; i < TASK_COUNT; i++) {
        callLambdaTask [ i ] ();
    }

}

//  Complex Version: Each array element is a struct containing a
//  pointer to the corresponding task and related properties
struct complexTaskDefinition {
    taskPointer task;
    bool repeat;                //  Repeat flashing after delay
    int32_t iterations;         //  # times to repeat... -1 = forever
    uint32_t delay;             //  MS to wait before execution
};

//  Create a pointer to a task definition
complexTaskDefinition *task;

//  Prove that called function can call other functions:
void taskC1 () { showTaskC1(); }
void taskC2 () { showTaskC1 (); }
void taskC3 () { showTaskC1 (); }

void showTaskC1 () {
    Serial.println ( ( char* )"COMPLEX TASK 1" );
}
void showTaskC2 () {
    Serial.println ( ( char* )"COMPLEX TASK 2" );
}
void showTaskC3 () {
    Serial.println ( ( char* )"COMPLEX TASK 3" );
}

complexTaskDefinition tasks [ ] [4] = {
    {taskC1, true, -1, 1000 },  //  taskC1 repeats forever every second
    {taskC2, true, 10, 2000 },  //  taskC2 runs 10 times pausing for 2 seconds between iterations
    {taskC3, false, 3, 3000 },  //  taskC3 runs 3 times with 3 second delays between each, then dies
};

void showComplexTaskList () {
    Serial.println ( F ( "\nComplex Task List:" ) );
    for (uint8_t i = 0; i < TASK_COUNT; i++) {
        task = tasks [ i ];
        Serial.print ( '[' );
        Serial.print ( i );
        Serial.print ( F ( "] REPEAT:" ));
        Serial.print ( ( task->repeat ) ? "YES" : "NO" );
        Serial.print ( F ( ", DELAY:" ) );
        Serial.print ( task->delay );
        Serial.print ( F ( ", ITERATIONS:" ) );
        Serial.print ( task->iterations );
        Serial.println ();
    }
}

void showComplexVersion () {
    Serial.println ( F ( "\nComplex Version:" ) );
    for (uint8_t i = 0; i < TASK_COUNT; i++) {
        task = tasks [ i ];
        task->task ();
//      (( *tasks ) [ i ]).task ();
    }
}

void setup () {
    Serial.begin ( 115200 );
    while (!Serial.availableForWrite ()) {}

    showSimpleVersion ();

    showLambdaVersion ();

    showComplexVersion ();

    showComplexTaskList ();
}

void loop () {
}

Here is the output:
Simple Version:

SIMPLE TASK 1
SIMPLE TASK 2
SIMPLE TASK 3

Lambda Version:
LAMBDA TASK 1
LAMBDA TASK 2
LAMBDA TASK 3

Complex Version:
COMPLEX TASK 1
COMPLEX TASK 1
COMPLEX TASK 1

Complex Task List:
[0] REPEAT:YES, DELAY:1000, ITERATIONS:-1
[1] REPEAT:YES, DELAY:2000, ITERATIONS:10
[2] REPEAT:NO, DELAY:3000, ITERATIONS:3

I want to run one more experiment, this time with the complex version as a class.


texts: i am unable to make a correct program using the pushbutton to toggle LED on/off?

texts:
I want to toggle the the LED on on my first complete click(i.e. pushing and even releasing the pushbutton) and i want to make my LED off at my second click.

This is the program :-

int led = 13;
int buttonpin = 8;
boolean lastbuttonstate = LOW;
boolean ledon = LOW;

void setup ()
{
  digitalWrite(buttonpin,HIGH);
  pinMode(buttonpin,INPUT);
  pinMode(led,OUTPUT);
}

void loop ()
{
  if( digitalRead(buttonpin) == HIGH && lastbuttonstate == LOW && ledon = !digitalRead(buttonpin))
  {
    digitalWrite(led,HIGH);
  }
  else if (digitalRead(buttonpin) == LOW && lastbuttonstate == HIGH && ledon =!digitalRead(buttonpin))
  {
    digitalWrite(led,HIGH);
  }
   if( digitalRead(buttonpin) == HIGH && lastbuttonstate == LOW && ledon =digitalRead(buttonpin))
  {
    digitalWrite(led,LOW);
  }
  else if (digitalRead(buttonpin) == LOW && lastbuttonstate == HIGH && ledon =digitalRead(buttonpin))
  {
    digitalWrite(led,LOW);
  }
}

I have connected all the connections on my breadboard according to schematic but there is something wrong in the program itself.


texts:
I need to install my Arduino drivers, but Windows 8.1 doesn't seem to like Arduino, and it greys out the update driver button. Therefore I can't select the drivers from the drivers folder in my Arduino IDE folder.

There are drivers that need to be installed. But Windows 8.1 greys out the update driver software button. Also, it refers to Arduino Uno as an unknown device. How do I install the Arduino drivers and make Windows let me install the drivers?


texts:
I am wondering if anyone here knows where the source code for the Arduino "firmware" is available for reading? I think it must be more than the 'boot loader' but I am not sure. Thanks!

p.s. I assume this kind of question is ok here, even though it's not ok on StackOverflow?


texts:
I am trying to measure current from an LFG with Arduino Uno and Grove current sensor (A12-200). I found a code at this link you can see Arduino code here.

The code works, but there are some operations that I don't understand. Let me copy and paste the code here (for further information, please follow the link above).

/****************************************************************************/
//  Function: Measure the amplitude current of the alternating current and
//            the effective current of the sinusoidal alternating current.
//  Hardware: Grove - Electricity Sensor
//  Date:    Jan 19,2013
//  by www.seeedstudio.com
#define ELECTRICITY_SENSOR A0 // Analog input pin that sensor is attached to

float amplitude_current;               //amplitude current
float effective_value;       //effective current

void setup()
{
    Serial.begin(9600);
    pins_init();
}
void loop()
{
    int sensor_max;
    sensor_max = getMaxValue();
    Serial.print("sensor_max = ");
    Serial.println(sensor_max);
    //the VCC on the Grove interface of the sensor is 5v
    amplitude_current=(float)sensor_max/1024*5/800*2000000;
    effective_value=amplitude_current/1.414;//minimum_current=1/1024*5/800*2000000/1.414=8.6(mA)
                        //Only for sinusoidal alternating current
    Serial.println("The amplitude of the current is(in mA)");
    Serial.println(amplitude_current,1);//Only one number after the decimal point
    Serial.println("The effective value of the current is(in mA)");
    Serial.println(effective_value,1);
}
void pins_init()
{
    pinMode(ELECTRICITY_SENSOR, INPUT);
}
/*Function: Sample for 1000ms and get the maximum value from the SIG pin*/
int getMaxValue()
{
    int sensorValue;             //value read from the sensor
    int sensorMax = 0;
    uint32_t start_time = millis();
    while((millis()-start_time) < 1000)//sample for 1000ms
    {
        sensorValue = analogRead(ELECTRICITY_SENSOR);
        if (sensorValue > sensorMax)
        {
            /*record the maximum sensor value*/
            sensorMax = sensorValue;
        }
    }
    return sensorMax;
}

effective_value=amplitude_current/1.414

I don't understand why dividing amplitude_current by 1.414 we'll get effective_current.

And in the function getMaxValue(), I know what it does, but I don't understand why we just need maxvalue.


texts: ESP8266 Repeated Crashing When Pulling JSON Information

texts:
I am trying to create a simple LCD device that pulls a random Jeopardy question from here: http://jservice.io/api/random, then cycles through the category/value, clue, and correct question at the push of a button. However, I am running into problems when I pull the clue. I am running this on an AdaFruit Feather Huzzah esp8266, but the board repeatedly crashes before returning the GetJeopardy function. In particular, I get errors like this:
--------------- CUT HERE FOR EXCEPTION DECODER ---------------

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3584, room 16
tail 0
chksum 0xb0
csum 0xb0
v2843a5ac
~ld

The function is as follows:

typedef struct {
  const char* cat;
  int val;
  const char* clue;
  const char* corr;
} jeop_problem;

jeop_problem GetJeopardy(){
  jeop_problem JQ;
  const size_t bufferSize = JSON_OBJECT_SIZE(2) + JSON_OBJECT_SIZE(3) +
                            JSON_OBJECT_SIZE(5) + JSON_OBJECT_SIZE(8) + 370;
  DynamicJsonDocument doc(bufferSize);
  if (WiFi.status() == WL_CONNECTED) {
    Serial.println("Pulling Jeopardy");
    HTTPClient http; // Object of class HTTPClient
    WiFiClient client;
    http.begin(client, "http://jservice.io/api/random");
    int httpCode = http.GET();
    deserializeJson(doc, http.getString());
    http.end(); // Close connection
    const char* cat = doc[0]["category"]["title"];
    JQ.cat = cat;
    Serial.println(cat);
    int val = doc[0]["value"];
    JQ.val = val;
    Serial.println(val);
    const char* clue = doc[0]["question"];
    JQ.clue = clue;
    Serial.println(clue);
    const char* corr = doc[0]["answer"];
    JQ.corr = corr;
    Serial.println(corr);
  }
  else {
    // We don't have a connection, return blank problem
    JQ = {"ERROR: RESET", -1, "ERROR: RESET",
                                    "ERROR: RESET"};
  }
  Serial.println("Pulled Jeopardy!");
  return JQ;
}

In particular, the board is always crashing before printing "Pulled Jeopardy" to the Serial console.
Thanks in advance!


texts: Arduino resets when I call network.begin()

texts: I have included the RF24Network library in my project. I tried to use the Simple Transmit/Receive example from here but when it calls the network.begin() my arduino restarts. I placed some Serial.println() in order to understand where is the problem. This problem appears only in my Arduino Mega 1280. I tried the same code on my Arduino Pro mini and it works like a charm. What causes this? How to fix that? It is very important to use the specific library. Thanks in advance.


texts: Ensure board is always on the same port?

texts: I want to make a VB.NET program to communicate over serial with the board, but I need to be sure it knows which port. Instead of programming in more advanced methods of verification, for this project I would simply prefer to keep the board on the same (internal) USB port. Will it always appear on the same serial port (COMx) and will VB always be able to find it there?


texts: Connecting BMP280 sensor to microcontroller

texts:
I am building my own board with integrated pressure sensor.
(microcontroller is 3V3 logic)
I want to know which parts do i need. In datasheet there are only 2 capacitors but on breakout board there are also 4 resistors.
Also in datasheet are 2 100 nF capacitors and on breakout board are 1uF and 0,1uF.
schematics from datasheet:

breakout board schematics:


texts: Running sensor input for given time, stopping, then running seperate scheduled relay output

texts:
I've set up an Arduino Uno to run a pretty basic garden watering schedule, with the delay function.

I've now built a solar thermal water heater with a pump and tried running it separately through a 555 timer using a thermistor (33k Ohm approx). I couldn't get this running as the change in resistance with a water temperature rise to 30 deg or so wasn't enough to trip and untrip the 555 timer (thermistor at about 20 k at 20 deg, maybe 50k at 30 deg). (Any pointers to circuits that achieve this would be appreciated by the way.)

I've decided to try to run the solar thermal motor with my arduino set up as I have 2 relays free in a relay shield. My question is how I can run the sensor to start the solar thermal pump, then stop operating the solar thermal system and return to the garden watering code, then restart the sensor input, and so on. The issue is that my power supply is only 1 Amp, and running both systems at once might overheat it.

Hope this makes sense,
Brian


texts: Briefly "wake up" Arduino in response to an event

texts:
I want to connect a device to a door handle, so whenever someone opens the door I'll be able to send a message via my arduino that is connected to a WIFI shield.

I have a simple orientation sensor, so I know when the handle is being pushed. The problem is I don't want to keep the Arduino on all of the time (energy issues).

The orientation sensor closes a circuit for about 100ms, so I thought to connect the battery to the Arduino in series with the sensor, but the problem is that it might take more than 100ms to connect and send the data - I need at least 5 seconds to be sure.

Any ideas on how to make the Arduino "power up" for 10 seconds each time someone uses the door handle and then to cut off the power?


texts: How to flash the "atmega328" with AVRDUDE?

texts:
I have an external device using an ATmega328, not a ATmega328-P as used by the Arduino Uno.

Now I want to use AVRDUDE and an Arduino Uno to flash a hex file on this chip. Therefore I removed the ATmega that came with the Arduino and popped in the one without the "-P".

With the Arduino IDE, it doesn't work, so I tried AVRDUDE:

avrdude -c arduino -P com3 -p ATMEGA328 -b 19200 -U flash:r:sdint.hex:r

However, I'm doing something wrong here, because it does not work:

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

What commandline should I use to flash an Arduino Uno with an ATmega328?


texts:
I'm currently working on a Arduino Mega (GPS + IMU + SD card logging + BT). I need the Mega for extra memory and serial port.
I would like to transition to something with a smaller form factor now. I need help with suggestions for a smaller form factor board/version of Mega.

Any suggestions?
I can't really find anything.

The only small size yet meeting requirements (in terms of memory) option seems to be a Microduino -
but I'm not whether all the libraries (SDfat etc.) will work on this.


texts: Serial to wifi using arduino nano and esp8266

texts:
I am trying to configure ESP8266 from Arduino Nano through software serial, after this I am sending some data through esp8266 to a PC (server). And I am lighting 3 leds, led #1 for AT ok, #2 for connecting esp8266 to the router #3 for connecting esp8266 to the server. But when I unplug the esp8266 from power supply, the leds keep turned on, I want them to be off when I unplug the power, as I am using serial.find(). The code I am uploading is just for AT OK command if you want the complete code i can give.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11);

int D3 = 3;

void setup() {

  Serial.begin(9600);
  mySerial.begin(115200);
  delay(1000);

  pinMode(D3, OUTPUT);
  mySerial.write("ATE0\r\n");
  delay(1000);
}

void loop() {

  char pak[10];

  int i = 0;

  mySerial.print("AT\r\n");
  delay(100);

  if (mySerial.available())

  {

    while (mySerial.available()) {
      pak[i] = mySerial.read();

      if (mySerial.find("OK")) {
        digitalWrite(D3, HIGH);
      } else {
        digitalWrite(D3, LOW);
        while (1)
          ;
      }

      Serial.write(pak[i]);

      for (i = 0; i < 10; i++)

        pak[i] = 0;

      delay(100);

    }
  }
}


texts: Why does an `.ino` file have to be in a folder of the same name?

texts:
I'm trying to organise a very complicated project and I want to put all the actual code in a folder named src (source), but I want to keep the main .ino file as main.ino (it will also be in src). Then when I try to open the code, the IDE says that main.ino has to be in a folder named main.

Why is this?

I fully understand the error message, but why does the file naming in Arduino has to be so. Is there a way to change that?


texts: How to load page from SD card and still show live data from sensors?

texts:
I am just wondering, how can we display page from SD card and still show live data from sensors?

I have web server running on Arduino mega using ethernet shield, in my sketch I am doing client.print to build content of a page being displayed, and refreshing it display live data.

But I can't think of a way how can I load page from SD card and display data from sensors.


texts: inttypes vs Arduino defined integral types

texts:
In my Arduino projects I use both Arduino types and types defined in the "inttypes.h" file, which #includes stdint.h. So far I've always written code only for the ATmega328P microcontroller (either in the UNO board or "standalone").

To be clear, in this question I'm referring to the following types:

"Arduino": char, int, long; byte, word, unsigned long
inttypes: int8_t, int16_t, int32_t; uint8_t, uint16_t, uint32_t

What is the actual difference between e.g. int and int16_t?
Is implicit conversion between corresponding types always possible, or should I avoid it even if the compiler doesn't complain? (quite often in my programs I pass an int16_t as int argument to a function and it always works, but is it good practice to do it, in general?


texts: Servo moving in steps of 10º after Servo.attach without any write command

texts:
I am new to Arduino and I was trying to test some code with servos. However, once I place the Servo.attach(myPin) to the code my servo starts moving continuously in steps of around 10º, with a delay of around 0.5 seconds. I tried to eliminate all code but this only line, no Servo.write, no code on void loop() and it still moves the same way. I am sure it is not reading other code, since when I eliminate the attach it stops moving.
Thanks in advance.


texts: What is the highest baud rate that can work between Android device and an Arduino connected to an HC05?

texts:
I see a lot of baud rates in the AT Command documentation for the HC05 however I am not sure what is the fastest that can work between the Arduino controlled embedded system and the Android phone. I also do not know of a way to change the baud rate of the Bluetooth communication in software. I am writing the application in Java with Android Studio IDE.
I read the documentation for HC05 and realize that it only operates with one Bluetooth profile. i.e the Serial Port Profile. The documentation says that this profile offers a maximum data-rate of 128000 bits/sec. However, the HC05 has a max baud rate option of 1382400 bits/sec. Why would this option be there if it is not possible to use? Can you please explain what I am missing and point me into the direction of some useful information? Thank you.


texts:
I am new to ESP programming on Arduino, as before I was developing on eLua. There were some memory problems in Lua, so I decided to move to Arduino.

After looking at some examples, I found a library called AsyncTCP and I was very glad because it provides callbacks for events just like Lua. But I was very disappointed when I found no example of an async TCP server. Instead there is an AsyncWeb Server but I don't want to use an HTTP server: I want a simple telnet server. Does someone have a working example?


texts: What is the timing between reset and avrdude/spi communication? (re: avrdude problem)

texts:
I'm trying to troubleshoot an issue with avrdude involving a Raspberry Pi and a transistor to control the reset pin on an Arduino Pro Micro (atmega32u4).
Where can I find information on the reset/programming process for the atmega32u4 or Arduino?  The atmega32u4 data sheet provides a bit of information but some of it is above my head.
For example, avrdude (and other programmers) require the microcontroller to be reset before uploading a new program or interacting (ie. fuses) with the chip.
Why is this?
The atmega32u4 specifies a minimum reset pulse of 400ns (ie. high to low to high again), but how long afterwards is the chip available for communication to avrdude?


texts:
I want to collect data (both Humidity & Temperature) from 80 sensors. let's say I have 80 "DHT 11 Humidity & Temperature" sensors (for ex. in a warehouse) and one Arduino Uno R3 pack. It's clear that arduino has no so many pins to connect. I'm sorry that I don't know if it's possible. If so, what can I use to achieve this?
Thank you all for your suggestions.


texts:
I have a breadboard connected to an Arduino Uno, 220k resistors connected to an led, of course it has a common ground and a pin connected to 5v. All pins are digital.

Now, I want led 1 to turn on for one second, the next led for two seconds and the next for three seconds, but that means, when the second led which has to be on for two seconds then the first led will come back on after one second has past on the second led, the third led would be on for three seconds, so the second led will also be on when two seconds pass and the first would be on when one second passes. So basically, all leds are on for their given duration.

How do I do this? I have been trying to do this since three days. It would be a pleasure if someone helps me out. Thanks.

int ledPin1= 2;
int ledPin2 = 4;
int ledPin3 = 7;

void setup(){
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  }

  void loop(){
  digitalWrite(ledPin1, HIGH);
  delay(500);
  digitalWrite(ledPin1, LOW);
  delay(500);

  digitalWrite(ledPin2, HIGH);
  delay(1000);
  digitalWrite(ledPin2, LOW);
  delay(1000);

  digitalWrite(ledPin3, HIGH);
  delay(1500);
  digitalWrite(ledPin3, LOW);
  delay(1500);
    }

So far this is the code. But it delays the whole program. Need leds on at given times.


texts: Need help with independent speed control on multiple steppers

texts:
I am a NOOB. I admit to a huge lack of understanding of programming. I just need my machine to work.
I cannot wrap my head around getting independent speed control of 2 steppers since it seems that controlling the speed is dependent upon adjusting the length of delay between sending pulses to the motors, however sketches only contain one Loop and any delay in that loop has a global effect.
Here is my code so far
// My sketch to control 1.8 degree stepper motors operating the Gizmoto V3 Braiding Machine
// One 10k Pot speed-controls 2 braiding steppers,
// Second Pot speed-controls 3rd stepper which operates the take-up capstan

// Rev 1.0  March 10 2021

// Defines pins numbers

const int braidStepPin = 3;
const int braidDirPin = 2;

const int capstanStepPin = 5;
const int capstanDirPin = 4;

//Define variables here

int braidDelay; // Controls the speed of the braiding drive according to braidSpeed function
int capstanDelay; // Controls the speed of the capstan drive according to capstanSpeed function

void setup() {
  // Sets the pins as Outputs
  pinMode(braidStepPin,OUTPUT);
  pinMode(braidDirPin,OUTPUT);
  pinMode(capstanStepPin,OUTPUT);
  pinMode(capstanDirPin,OUTPUT);

  digitalWrite(braidDirPin,HIGH); // Sets the braid motors' direction
  digitalWrite(capstanDirPin,HIGH); // Sets the capstan motor's direction
}
void loop() {

  digitalWrite(braidStepPin, HIGH); // Sends the braid motors one pulse
  digitalWrite(braidStepPin, LOW);
  delayMicroseconds(braidSpeed);

  digitalWrite(capstanStepPin, HIGH); //Sends the capstan motor one pulse
  digitalWrite(capstanStepPin, LOW);
  delayMicroseconds(capstanSpeed);
}
// Function for reading the Braiding Potentiometer
int braidSpeed() {
  int braidDelay = analogRead(A0); // Reads the potentiometer
  int newBraidDelay = map(braidDelay, 0, 1020, 200, 700); // Converts the read values of the potentiometer from 0 to 1023 into desired delay values
  return newBraidDelay;
}
// Function for reading the Capstan Potentiometer
int capstanSpeed() {
  int capstanDelay = analogRead(A1); // Reads the potentiometer
  int newCapstanDelay = map(capstanDelay, 0, 1020, 200, 700); // Converts the read values of the potentiometer from 0 to 1023 into desired delay values
  return newCapstanDelay;
}


texts:
In my current project I am measuring temperature using K-type thermocouple and MAX31855 breakout board and Arduino uno.

I have used Adafruit-max31855 library and example code from that library. But monitoring on serial monitor after some reading it is giving NaN.

Here is the code I have used:

#include "Adafruit_MAX31855.h"

int thermoDO = 5;
int thermoCS = 6;
int thermoCLK = 7;

Adafruit_MAX31855 thermocouple(thermoCLK, thermoCS, thermoDO);

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

  Serial.println("MAX31855 test");
  // wait for MAX chip to stabilize
  delay(500);
}

void loop() {
  // basic readout test, just print the current temp
   Serial.print("Internal Temp = ");
   Serial.println(thermocouple.readInternal());

   double c = thermocouple.readCelsius();
   if (isnan(c)) {
     Serial.println("Something wrong with thermocouple!");
   } else {
     Serial.print("C = ");
     Serial.println(c);
   }
   //Serial.print("F = ");
   //Serial.println(thermocouple.readFarenheit());

   delay(1000);
}

Circuit Diagram:

Output:

What could be the possible error for this and how can I solve this?


texts: Who knows this Mega2560 with two Crystal Oscillators: 12 000 MHz and 16 000 MHz? What is the use of them?


texts: More than 3 SPI devices read by a single arduino

texts:
I've been working on a project that involves SSI Rotary Encoders from CUI. They are being read through the SPI interface, and I am bit-shifting appropriately to account for the differences between SSI and SPI. Unfortunately, I am pretty limited in knowledge of how the SPI interface works, but I am attempting to connect 5 of these encoders to the Arduino (nano) to create a simple robot.

Everything was working great when I had 3 encoders, however, when I add a fourth to the same Arduino, all of the encoders stop reading. I am struggling to determine my next steps. According to one source, it appears that an Arduino is allowed a maximum of three SPI devices, but I am wondering if it is possible to have the other two read through a software interface? Here's a link to the source I found: https://esp32.com/viewtopic.php?t=1972. If you have any suggestions, please let me know!


texts: LCD is not printing strings, only integers with Arduino

texts:
As mentioned in the title I'm facing a problem in printing strings in the LCD. It's printing actually weird characters.

#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup() {
  lcd.begin(16, 2);
  Serial.begin(9600);

  lcd.print("hello, world!");
}
void loop() {

 lcd.setCursor(0, 1);
  lcd.print(millis()/500);
}

You can find the output of the LCD in the picture below:


texts: How to sense toggle switch using OPTOCOUPLER

texts:
I am using an EL817 Photocoupler, here is the Datasheet. I have designed a circuit to sense the Switch using EL817 and it is connected to the GPIO pin of Arduino. How can I sense the switch? The circuit either open the circuit or connects ground to GPIO.

But I am unable to sense of switch is on/off. I am using simple on off switch. Here is my circuit. The Toggle switch is connected to ground when on and when off it is not connected to anything. The other side of opto is connected to ground and to Arduino GPIO. The coupler works on 24V.

I need help in coding and how to sense the switch if it is connected to ground or left open.


texts: Speaker not producing the right sound after a led strip was introduced

texts:
Grove speaker:
http://www.seeedstudio.com/depot/Grove-Speaker-p-1445.html
ws2812-led strip

Hi, I have been working to produce tones on a speaker and it works with the following code

    int melody[] = { NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3, NOTE_B3, NOTE_C4};
    ...
    ...
    tone(pin, melody[pitch]);

After I included my addressable LED strip sketch codes, the speaker does not produce the same tone as normally it does. It sounded distorted this time round.

void loop()
{
  strip.Update(); //NeoPatterns strip(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800, &StripComplete);
}

Class:

// NeoPattern Class - derived from the Adafruit_NeoPixel class
class NeoPatterns : public Adafruit_NeoPixel
{
  public:

// Member Variables:
    ...
    ...

void (*OnComplete)();  // Callback on completion of pattern

// Constructor - calls base-class constructor to initialize strip
NeoPatterns(uint16_t pixels, uint8_t pin, uint8_t type, void (*callback)())
  : Adafruit_NeoPixel(pixels, pin, type)
{
  OnComplete = callback;
}

// Update the pattern
void Update()
{
  if ((millis() - lastUpdate) > Interval) // time to update
  {
    lastUpdate = millis();
    switch (ActivePattern)
    {
      case RAINBOW_CYCLE:
        RainbowCycleUpdate();
        break;
      default:
        break;
    }
  }
}

// Initialize for a RainbowCycle
void RainbowCycle(uint8_t interval, direction dir = FORWARD)
{
  ActivePattern = RAINBOW_CYCLE;
  Interval = interval;
  TotalSteps = 255;
  Index = 0;
  Direction = dir;
}

// Update the Rainbow Cycle Pattern
    void RainbowCycleUpdate()
    {
      for (int i = 0; i < numPixels(); i++)
      {
        setPixelColor(i, Wheel(((i * 256 / numPixels()) + Index) & 255));
      }
      show(); // When I comment this line, the speaker will work properly. What is happening?
      Increment();
    }


texts:
Well, googling didn't do much to help me here and I'm shocked that something I can do in two lines of code in C#

DateTime dateTime;
string text = dateTime.ToLongDateString();

is this difficult for Arduino, but how do you get a string version of a date time stamp?

I want the current date and time as a string in this format

  May 4, 2016 17:15:33

Since I can't use any of the C++ includes, like ctime, I'm not sure how to accomplish this.


texts: Storing random and different values of millis() while inside a loop?

texts:
Is it possible to store a value of time while you're inside a loop? Entertain the condition:

if (condition && value > 0)
{
timeTrans = millis() + 2000;
timeTrans - millis() = value;
}

basically i want it to begin counting down from 2 to 0 no matter what time it is at, but the problem is if it's inside the loop tineTrans will update as millis counts up, and value will always be 2000 and will never count down to 0. And the condition stated in the if function cannot be called in void setup(), so there's no hope in that direction. I'd post my code but it's a little long, if it will help find a solution i will post it and point around to what i'm working on.

Also, the condition is met randomly. I do not know when, or at what time/millis() it will be met at.

I also tried using for loops as well but it counts wayyyy too fast for it to be viable, and obviously i cant delay it while its inside a void loop(). Is there any other way i can go about with this?

I've been looking at the beginners guides and here's where i'm at right now, this is about as clear and concise as this question is going to get

is there any way to make "time-2000" a constant variable in this example?

unsigned long time, timeNow, timePast, timeStart, value;
unsigned long period;

void setup() {
  Serial.begin(9600);
  timeStart = 0;

}

void loop() {
  time = millis();
  if (time > 3000) //Using time bigger than 3 sec as a condition substitute to trigger my event
  period = time-2000; //Since in my example, we'll know at what time the condition was triggered (once it's triggered), I set the "period" to that.
    if ((time - timeStart) > period) //aaaaannndd the attempt
      timePast = period;

  Serial.print("Time: "); //debugging
  Serial.print(time);
  Serial.print(" please work ");
  Serial.println(timePast);

that "time-2000" just needs to be turned into a constant somehow. After that, i'll be golden. Anybody know a way around this?


texts: Arduino I2C external 32Kb fram data organization

texts:
Hey guys I am a noob when it comes to data structures and storing types of data, I have been recently working on a project where I needed to store long term data for later retrieval. I decided to buy a Adafruit 10$ 32kb i2c fram Which works, it can store a byte Of data per address which I can successfully do, I can also read those bytes on any address no problem.
One issue I first came across was storing floats into the chip which only took bytes, After googling I managed to spit a float using a union successfully and also storing those in a 4 byte array. Now I did this with 3 different float values which means every 4 bytes stored is basically one split float value.
The second issue is how do I retrieve this data in an organized way and also as a float. I found out you can use a union to do the opposite as well. But how do I tell my code to read every 4 bytes and convert back to float?
Is there a system that can allow me to store data in a structured way using the arduino? Like a time stamped data using an external rtc? Such that when I click retrieve it will print that data in an organized fashion.


texts:
A have Arduino Mega 2560. I found in the spec that the maximum output current for each I/O pin is 40 mA.

Can i use 40 IO in parallel? That's mean 40*40ma*5 volt = 8000 mw = 8 watt.

What about the heat?!


texts:
I'm trying to set up a GPS tracking solution in a rural area. The catch is the GPS trackers need to be lower cost (power and cash), because there will be a good amount of them.

So I'm trying to find a solution where I can benefit from A-GPS using a beacon of some sort to handle any cpu/server calculations while receiving GPS noise from the tracking devices (I think that's the idea). I've read up a bit on Mobile Station Assisted (MSA) GPS, but I'm not entirely sure what solutions there are to handle this.

Any help or advice is appreciated.

Example:

Arduino GPS tracker x 200 ---[RF comms/GPS noise]--->  Beacon/Tower  ---[Internet]---> GPS Server


texts: Call a class method from inside the same class

texts:
If i have file cSpeedOfSound.h:

#ifndef cSpeedOfSound_h
#define cSpeedOfSound_h
#include "Arduino.h"
#include "math.h"
class cSpeedOfSound{
    public:
        cSpeedOfSound(float *i,float *C);
    private:
        float *C;
        float *a;
        float *i;
    };
#endif

and file cSpeedOfSound.cpp:

#include "cSpeedOfSound.h"
cSpeedOfSound::cSpeedOfSound(float *i,float *C){
    //some code...
    *C =roundto(*C,2);}
float cSpeedOfSound::roundto(float x,float dp){
return (round(x*pow(10., dp)) / pow(10., dp));}

where i want to run function roundto inside class, but it doesnt seems to work. So what im making wrong and how to do it properly?

Ps: Im begginer to arduino (want it to learn robotics + C language) and know python (learnd for about 1+ year), so pls do not hate me if i made crucial mistakes.


texts: How to connect RFID Module to Arduino UNO

texts:
I brought 860mhz-960mhz UHF rfid reader module for chip card skimmer from follow link:

https://www.alibaba.com/product-detail/860mhz-960mhz-UHF-rfid-reader-module_60312310172.html

I want to do communication with arduino uno so is it possible to connect

VCC to VCC
GND to GND
RX to TX
TX to RX

and what is meaning of EN and GPIO if any one know please help me to do serial communication.


texts: Want to setup a wireless communication using nrf24l01

texts: I want to transmit a alphabet from one arduino to another using nrf24l01 trans-receiver and receive the same alphabet on the receiver nrf. I want to get a transmitter and receiver code with explanation to do so. Looking forward for guidance.


texts: Is it possible to overload the digital pins for an Arduino?

texts:
I worked on an Arduino project for school that was a self-driving security robot that also acted as a smart home system.

It was essentially a self-driving Roomba-like car that included several LED's(resembling home appliances), three distance sensors, an LCD screen, a motion sensor, an audio amplifier with a speaker, an SD card module to store .wav files, a Bluetooth module to connect with MIT App Inventor, and a motor driver that controlled two electric motors. It's a long list of modules so the Arduino Mega was required. When assembling all of these modules and building the code, I would perform intermittent tests that would isolate the obstacle avoidance and driving, turning on appliances(LED's), and sending and receiving data from the phone app. Every aspect of the project worked in isolation until I combined everything.

When everything was combined, instead of simply driving forward until an obstacle is detected as its programmed, the car would jitter around and not react to walls or obstacles. Also, the LCD screen was heavily dimmed as opposed to when the Arduino was running off of laptop power. Especially when the phone app called for turning on heat or AC, the proper LED's would turn on, but the whole system seemed to respond to the initial load required to read a .wav file and play the corresponding audio and made the jitter worse.

So my question is this, with all these modules plugged into an Arduino, is it possible that the number of modules all needing some input from the digital pins has highlighted a current limitation? All of these issues were exacerbated when the laptop power was replaced with a 9v battery. I was able to confirm that the code was not the issue as I would simply comment out major portions but leaving all the pins initialized. Also, if there is a current output limitation, is there any way to explain why? Thank you for reading my lengthy post and for giving feedback.


texts: control a jack/cylinder to open/close a window

texts:
I want to open the window to let the cat enter or go out, but the mecanism of the window may me think that the best way should be to use a jack/cylinder (I don't know what term is more appropriate in english for that) to open and close the door.

I will use rfid or another wireless think to know it the cat is in the place and then open the wondow but I want to close the window and let the wndow close event if there is little bit of wind, so I need domething robust.

Do you know a good hardware with (this would be the best) piece of code that can help me for that?

Thanks in advance


texts: Why does the MKR WiFi 1010 LED_BUILTIN sometimes pulsate?

texts:
Sometimes the built-in LED pulsates after an upload. It could be after a failed upload but I'm not entirely sure. What does this indicate? I haven't been able to find any information about it.
It doesn't blink like in the Bliky example. It pulsates.
The led is not controlled by a Sketch. Usually this happens after a failed upload, and the previous Sketch doesn't work anymore.


texts: Would an Arduino Uno be suitable for a simple time-based locking circuit?

texts:
Background: I'm looking to start on my first real electronics project and I have an Arduino Uno I bought a while back. I've only done a few of the starter Arduino tutorials and that was a while back as well. Starting from very little electronics knowledge, I'm trying to get a bit of advice on how to tackle my first project.
TL;DR: I have an Arduino Uno but very little experience with it or electronics.

Project: I want an object that locks, I want the duration of the time it stays locked for to increase by ~1-3% every time it locks. I want to put my nicotine products in there to gradually pull myself off nicotine. I have designed a rough 3D model of the box, which I can 3D print so now I'm looking at the electronics.
TL;DR: A box which stays locked for longer, every time it locks.

Electronics: A microcontroller/Arduino/Pi to increase the locking duration; a locking circuit and some form of power supply.

My 2 questions are

Would the Arduino Uno be suited to this type of project?
What sort of components should I be looking for for the locking circuit and power supply (I'm thinking some sort of solenoid actuator and a battery pack)?


texts:
I would like to make a smart home using Arduino. My system must be wireless. I want to control power outlets and lamps and I want to be able to turn off and on power outlets and lamps wirelessly, using my android app, using nRF24L01.

Do I need an Arduino for each power outlet and lamp? Do I need to put an Arduino, nRF24L01 and relay inside each power outlet and lamp?


texts: Using SlickEdit to compile Arduino files

texts: I would like to compile my Arduino sketches in SlickEdit.  I have turned on the verbose compile output in the standard IDE and I can see the compile and switches, but it doesn't appear that there is a Makefile in use.  I don't see the "Entering" and "Leaving" messages that I associate with Make anyway.  Is using a third party tool to control the build an Arduino no-no?  Has anyone used Make to build Arduino?


texts: How to safely remove arduino nano from breadboard?

texts:
I did some prototyping with arduino nano in breadboard. And then after i done with the design, I was gonna implement it in a printed pcb so i need to remove the nano from breadboard. And this is when the disaster happened.

The board is kinda hard to pull by hand, so i use a long-thin screwdriver in the gutter to pull the nano up (just like i did many times to dip ICs with no problem). And successfully detached the nano from breadboard and also broke the tantalum under the nano in the process. So the question is:

How do you usually remove the nano board from breadboard safely? And
The tantalum i broke is 4.7uF smd. I can't find any 4.7uF tantalum in nearby shops, but i have electrolyte caps rated 4.7uF 16v. Can i use it for replacement?


texts: How to make two wheels turn only for a particular amount of time?

texts:
I am trying to make a robot turn (dc motors are being used) back 180 degrees. So I used an l289n for it and made one wheel turn clockwise and vice-versa.
But as I wan't it to make only a 180 degrees turn, I wanted to set an amount of time for it to turn.  Is there any other way to do the same thing, if yes, please tell, if no, help me...


texts:
Take this motor as an example - https://www.robotshop.com/en/12v-100rpm-583-oz-in-brushed-dc-motor.html

it has torque of 42kg.cm

I know all the calculation to find the payload of dc motor from here - https://www.quora.com/How-do-I-calculate-how-much-weight-can-DC-motor-carry

My main concern is the output power. Power formula is:-

power = voltage x Stall Current
      = 12 x 2A = 24W

But the specification says that the power is 5W. Which value should I use in my calculation?


texts: What are the unused pins in an Arduino L293D motor shield? I want to connect the shield using wires instead of directly mounting on top of the Arduino board.


texts:
I started out again with Arduino (beginner), but I wanted to know if I could connect another human infrared sensor like this to the Arduino Uno. I know how to connect a simple pir like this one, but I dont know for sure how to connect the 12V one (if its possible). Guess the red wire goes to a seperate 12V power supply, brown goes to ground and blue then goes to a digital pin on the arduino arduino? I didnt really understand the description that was available for the 12V sensor, so thats why I am asking (I want to be entirely sure before buying).

Thanks


texts: How to program an Arduino pro mini using native serial port (on my mainboard)

texts:
How can I program my Pro Mini using the native RS232 Serial port on my Mainboard (aka com1).

Google-ing did not really help and a quick search here for "pro mini programming com1" did not deliver any results.

I already have a MAX232 module connected between the Pro Mini and the PC.

I have already tested the com1 port for function by sending stuff to an Arduino mega via its usb-to-serial port and echo-ing that to com1.

Which succeeded (at least sort-of [receiving some random clutter in between characters or missing some characters at all])

I did try the obvious (i.e. selecting pro mini from the board menu and then selecting the com1 port and hit upload).

But that did just produce a timeout-error…

An Option to set the programmer to simple Serial Connection or something similar does not exist to my knowledge (well it does but only if we're talking about STM32 based boards like the blue pill).


texts: How will Arduino sketch and Android app communicate over GPS?

texts: How will I make Arduino with GPS communicate with an Android app? I just need this for my school project.


texts:
I'm going bonkers here. I'm using a Macbook Pro with Yosemite. Connected to the MKS Gen-2Z V1.1 reprap board (ATmega 2560).

The Arduino IDE only shows the cu port being available and not the tty.

Any attempts at opening the CU port show it as being busy. This is also true when I open the port using PronterFace (3d printer software). Yet, the PronterFace shows the tty port and gladly opens it and communicates. I downloaded Arduino 1.0.6 and the tty is available in the dropdown menu and it will open the port. But my 3D printer firmware will fail building on any Arduino IDEs prior to 1.6.0.

I found a few suggestions on creating a file "lock" in /var/ and then changing the r/w permissions. Also doing the same for /var/spool/uucp. Changing both of those permissions did nothing for me.

I may just have to build it and use AVRdude directly so I can use the tty port, but I have no idea why the cu would be busy all the time. Any suggestions?

Here's the Arduino output when I try to upload:

  avrdude: ser_open(): can't open device "/dev/cu.usbserial-AL00YS9R": Resource busy
      ioctl("TIOCMGET"): Inappropriate ioctl for device
      ioctl("TIOCMGET"): Inappropriate ioctl for device
      avrdude: ser_send(): write error: Bad file descriptor
      Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.


texts: Need help with the basics on serial control

texts:
I am struggling to get my head around why this just won't work. In my simple mind this simple sketch should do as it's told. But I am obviously missing something fundamental.

If anyone could shed some light on what I am doing wrong that would be very good!

The sketch is just to control a relay by typing on or off into the serial monitor. However although it uploads, all I get is the Serial.println repeating and no action on the physical relay.

I can manage to control things over serial by using the switch, case statements but I wanted to try it using full words rather than single chars and also using IF statements etc.

Thanks in advance!

EDIT
I just changed the string inputs to a char input and serial.readstring to just serial.read and it works with just entering a 1 or a 2 for example. So to re-ask my question - how can I get it to respond the same but using words? Thanks!

int relay=8;
String serialInput;

void setup() {
  Serial.begin(9600);
  pinMode(relay, OUTPUT);
}

void loop() {
  Serial.println("To toggle relay enter on or off");
  while (Serial.available()==0) {}
  serialInput = Serial.readString();
  if(serialInput=="on") {
    digitalWrite(relay, HIGH);
  }
  if(serialInput=="off") {
    digitalWrite(relay, LOW);
  }
}


texts:
The IDE tells me the included library isn't? I tried restarting the IDE and my computer but it doesn't work. The other libraries work fine it's only with Keyboard that it fails.

My code:

#include <Keyboard.h>

int buttonState = 0;

void setup() {
  pinMode(2, INPUT);
  pinMode(13, OUTPUT);

  Keyboard.begin();
}

void loop() {
  buttonState = digitalRead(2);
  if (buttonState == HIGH) {
    digitalWrite(13, HIGH);
    Keyboard.press('A');
  } else {
    digitalWrite(13, LOW);
    Keyboard.releaseAll();
  }
}

Error log:

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

D:\Documents\Test\Test.ino: In function 'void setup()':

Test:9: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
   Keyboard.begin();

   ^

D:\Documents\Test\Test.ino: In function 'void loop()':

Test:16: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
 Keyboard.press('A');

 ^

Test:19: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
     Keyboard.releaseAll();

     ^

exit status 1
'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?


texts:
i'm making a device that's kind of based on Russian roulette.
I have 5 LED's  that are normally  white, and when you press the button one of the LED's is marked red.
After some tinkering I figured out how to do this with  the help of adafruit neopixel, but i also want to have a RGB strip with a rainbow effect running on the same arduino at the same time (or only just before the button is pressed).
The problem is that it interferes with the activation and running of my  Russian roulette.
I know you can't run two loops at a time, but is there some kind of way to solve this?
I will put my code below, thanks in advance!
#include <Adafruit_NeoPixel.h>

const int buttonPin = 2;

int buttonState = 0;

#define LED_PIN  6

#define LED_COUNT 5

#define LED_PIN2  7

#define LED_COUNT2 60

Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip2(LED_COUNT2, LED_PIN2, NEO_RGBW + NEO_KHZ800);

uint32_t wit = strip.Color(255, 255, 255);
uint32_t wit2 = strip2.Color(255, 255, 255);

void setup() {

  randomSeed(analogRead(0));
  strip.begin();
  strip.show();
  strip.setBrightness(255);
  strip2.begin();
  strip2.show();
  strip2.setBrightness(255);
  pinMode(buttonPin, INPUT);

}

void loop() {
    rainbow(10);
    shotknop();
}

void shotknop (){
  buttonState = digitalRead(buttonPin);
    strip.fill(wit, 0, LED_COUNT);
    strip.show();
    if (buttonState == HIGH) {
    theaterChase(strip.Color(255, 255, 255), 150);
    shot(strip.Color(0, 255, 0), 100, 5000, 0);
    }
    else{
      }
}

void shot (uint32_t color, int wait1, int wait2, int rng) {
    strip.clear();
    rng = random(LED_COUNT);
    for(int a=0; a<15; a++) {
      strip.setPixelColor(rng, color);
      strip.show();
      delay(wait1);
      strip.setPixelColor(rng, (0, 0, 0));
      strip.show();
      delay(wait1);
  }
    strip.setPixelColor(rng, color);
    strip.show();
    delay(wait2);
}
void colorWipe(uint32_t color, int wait) {
  for(int i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, color);
    strip.show();
    delay(wait);
  }
}
void theaterChase(uint32_t color, int wait) {
  for(int a=0; a<10; a++) {
    for(int b=0; b<3; b++) {
      strip.clear();

      for(int c=b; c<strip.numPixels(); c += 3) {
        strip.setPixelColor(c, color);
      }
      strip.show();
      delay(wait);
    }
  }
}
void rainbow(int wait) {
  for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) {
    for(int i=0; i<strip2.numPixels(); i++) {
      int pixelHue = firstPixelHue + (i * 65536L / strip2.numPixels());
      strip2.setPixelColor(i, strip2.gamma32(strip2.ColorHSV(pixelHue)));
    }
    strip2.show();
    delay(wait);
  }
}


texts: Writing analog voltages on analog pins of Arduino

texts:
Can we write a analog voltage to analog pins A0-A7 of the Arduino Nano (for example)?

As in:

pinMode(A3, OUTPUT);
analogWrite(A3, 200);


texts:
I have an arduino uno which is powered by batteries. I have 6 AA-Batteries (1,5V each) connected to Vin and GND.

Thats cool because I don't have any cables and works pretty good.
The reason I need 6 AA batteries is, that I have a SIM900-module connected to my arduino uno. My USB Port (5V and 500mA) and my standard external power supply (9V and 1A) doesn't deliver enough current for the SIM900. But with the batteries the SIM900 gets enough power (current).

But there is the problem, that the batteries get sucked empty pretty fast and i don't want to exchange them every day. :-)

I searched for an power supply which can deliver 3A with 9V and found one. But i'm not sure if the arduino uno can handle that input via the on-board power-jack? The reason I want a 3A power supply is, that some users on the internet say that the sim900 sometimes uses more than the maximum current written in the documentation (which is 2A).

I'm an electronic noob.

So is there a risk if I try to use the 9V-3A power supply?
Does the arduino only pull the power it needs? So when it needs only 900mA, it only takes 900mA even if the power supply can deliver 3A?
As far as I know, it should work, because the batteries deliver as much current as the arduino (ad sim900) needs. So the batteries don't have an ampere limit, right?


texts: problem data I2C to sensor GY955/BNO055 (China)

texts:
I want to ask, I have a problem when running the Arduino sensor, I can't output data, but it's detecting that the sensor address has been paired.
Like I2C has a problem or locks it.

Last night it worked only because my twin sensors tried another with the same program after I compiled and uploaded, I see the serial monitor is only a detection sensor, but it doesn't display data, so the pitch evaporates and the roll data is 0.0,0.

There seems to be a problem with i2c: the data does not come out, it only detects the sensor address but the contents are all zero. Have you ever experienced this?

This initially worked, because the sensor was the same and I tried it with the same program after reading GY 955 / BNO055 on Euler_streaming it only showed zero per axis.

This is code in the bread board

/****************************************************************************

    Euler_Streaming.pde - part of sample SW for using BNO055 with Arduino

   (C) All rights reserved by ROBERT BOSCH GMBH

   Copyright (C) 2014 Bosch Sensortec GmbH

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

 **************************************************************************/
/*  Date: 2014/01/07
     Revision: 1.2

*/
#include "BNO055_support.h"     //Contains the bridge code between the API and Arduino
#include <Wire.h>

//The device address is set to BNO055_I2C_ADDR2 in this example. You can change this in the BNO055.h file in the code segment shown below.
// /* bno055 I2C Address */
// #define BNO055_I2C_ADDR1                0x28
// #define BNO055_I2C_ADDR2                0x29
// #define BNO055_I2C_ADDR                 BNO055_I2C_ADDR2

//Pin assignments as tested on the Arduino Due.
//Vdd,Vddio : 3.3V
//GND : GND
//SDA/SCL : SDA/SCL
//PSO/PS1 : GND/GND (I2C mode)

//This structure contains the details of the BNO055 device that is connected. (Updated after initialization)
struct bno055_t myBNO;
struct bno055_euler myEulerData; //Structure to hold the Euler data

unsigned long lastTime = 0;

void setup() //This code is executed once
{
  //Initialize I2C communication
  Wire.begin();

  //Initialization of the BNO055
  BNO_Init(&myBNO); //Assigning the structure to hold information about the device

  //Configuration to NDoF mode
  bno055_set_operation_mode(OPERATION_MODE_NDOF);

  delay(1);

  //Initialize the Serial Port to view information on the Serial Monitor
  Serial.begin(115200);
}

void loop() //This code is looped forever
{
  if ((millis() - lastTime) >= 100) //To stream at 10Hz without using additional timers
  {
    lastTime = millis();

    bno055_read_euler_hrp(&myEulerData);            //Update Euler data into the structure

    Serial.print("Time Stamp: ");               //To read out the Time Stamp
    Serial.println(lastTime);

    Serial.print("Heading(Yaw): ");             //To read out the Heading (Yaw)
    Serial.println(float(myEulerData.h) / 16.00);       //Convert to degrees

    Serial.print("Roll: ");                 //To read out the Roll
    Serial.println(float(myEulerData.r) / 16.00);       //Convert to degrees

    Serial.print("Pitch: ");                //To read out the Pitch
    Serial.println(float(myEulerData.p) / 16.00);       //Convert to degrees

    Serial.println();                   //Extra line to differentiate between packets
  }
}


texts: Arduino IDE / Specified folder/zip file does not contain a valid library

texts:
I trying to add library here but it doesn't seem to work https://github.com/esp8266/Arduino

This happens
"Specified folder/zip file does not contain a valid library"

This problem make me no longer upload any library. any solution about this??
Manual installation does not either.


texts:
I'm creating a weather station and want the station to be completely power independent. I'm using the Arduino Fio (https://www.arduino.cc/en/pmwiki.php?n=Main/ArduinoBoardFio) and have estimated the power requirements of the station to be an average of 273 mAh / day with a max load of .06A. I'm pretty sure I'll use the 850 mAh battery (https://www.sparkfun.com/products/13854) but need to know if a solar panel will work to charge the battery. Based on my current home location, I have about 3 hours of good sun per day during the winter.

The Arduino Fio has a Mini USB that seems like its sole purpose is to charge the battery but will a solar panel work or is the Fio designed to have that be a more regulated power supply? If so, will this 2W Panel (https://www.voltaicsystems.com/2-watt-panel) be compatible with the Fio to charge the battery and suite my needs.

Thanks for the help


texts:
I understand that each model of Arduino has limited cpu, ram, etc.

However, I have this very powerful Mac that it’s hooked up to.

Am i able to use my Mac for expensive computation and just pass results to my arduino in real-time?

Basically arduino takes in sensor data - passes it to Mac. Mac computes and returns an output to arduino.