texts:
Does anyone know a way to call an interrupt when an Arduino loses power to have it fire a small function real quick?

It'd be a quick EEPROM write of one variable.

I know you can use interrupts on certain pins when they get pulled low, I'm just not sure if it's possible on the power pin.

Or if there would still be enough power in the controller to finish that function.

I have the Node MCU board but it's programmed in Arduino c++.


texts:
i have an ultrasonic sensor. The sensor normally works stably. But I have to carry the data cables of this sensor for 50 meters and take reading. When i do this, when I extend the cable, the values I get from the sensor are not read stably.
I need to raise the sensor voltage so I can fix this problem, how can you help me?


texts: Sending constant int from Arduino to PC causes error

texts:
I am using Arduino Uno Rev 3, and according to this link we can achieve 2000000 baud rate.

This problem can be easily repeated by the following code:

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

void loop() {
  int val = 234;
  Serial.println(val);
}

I am using the serial-USB cable. To read the data, I used Python pyserial (< 20 lines of code including empty lines and import lines):

import serial
import matplotlib.pyplot as plt

LEN = 10000
data = []
ser = serial.Serial('COM3', baudrate=2000000)
for i in range(LEN):
    try:
        data.append(int(ser.readline()))
    except:
        pass
ser.close()

# %% Plot data
plt.figure(figsize=(6, 4))
plt.plot(data)
plt.savefig('data.png')

Here is what I got:

Edit below

Chris mentioned a good point that it might be the high baud rate of 2,000,000 causing the instability. I did think about that when I first ran into this, but then I did a little trick: adding a sinusoid into the constant. If I do that, the weird spiking goes away! I think it indicate that this is not a high baud rate issue... Is it?

Code:

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

void loop() {
  int val = 234;
  val += int(512 * (sin(float(millis()) * 0.01) + 1)) * 0.1;
  Serial.println(val);
}

Output:


texts: Interconnected Arduinos via digital pins and magnets

texts:
Before i get too far into the design phase of a project i have in mind, is there a way to connect arduinos in a non-master/slave manner to pass a few different combinations of HIGH/LOW (say 5) or 'information' both ways using digital pins? Perhaps some library i don't know about?

Each of these modules should be identical and be able to connect on any face to any other module. I've included a crude image of what I would like to accomplish.

I've already determined that i can solder to these neodymium magnets without loss of magnetic properties by having the little magnets attached to a stronger magnet during the soldering process. Magnet to magnet connection shows only a very tiny resistance.

If it can't be accomplished, i will need to abandon the project and look for some other means to make my project. Thanks in advance!

~zen


texts: Arduino Mega, PWM analogWite doesn't work with Timer interrupt

texts:
Can anybody explain me, why the PWM doesn't work in such a simple example?

Generally, Timer interrupt is being called once per 100 ms and then in the interrupt function the bool flag (state ) is being set. Then in the main loop the flag is checked and when it is 1 (true) several instructions are being executed. Next, PWM is generated and measured via ADC and also displayed on the LCD.

The problem is that the PWM is generated as 0 or sligthly over the 0, even when the value put to the  analogWrite is 255 (max of 8 bit). Variable counter is incremented without problems and this value is being put to the analogWrite and despite it the PWM doesn't work.

I don't know, totally, what can be wrong.

Can anybody help me?

 #include<LiquidCrystal.h>
 #include<TimerOne.h>

  LiquidCrystal lcd(52, 50, 48, 46, 44, 42, 40);

  int out = 12;
  int in = A7;
  volatile bool state;

  int counter = 0;
  volatile int y;

  void setup()
  {
    lcd.begin(16, 2);
    lcd.clear();
    pinMode(out, OUTPUT);
    pinMode(in, INPUT);

    analogReference(DEFAULT);
    Timer1.initialize(100000);
    Timer1.attachInterrupt(functionInterrupt);

     state = 0;
      y = 0;
   }

   void loop()
   {
     y = analogRead(in);
     y = y / 4;
     y = y - 128;

    if (state == 1)
    {
      state = 0;

      counter++;
      if (counter > 255)
      //counter = 0;
      counter = 200;

      //state = 0;
     }

      analogWrite(out,counter);

      lcd.home();
      lcd.setCursor(0, 1);
      lcd.print(counter);
      lcd.setCursor(12,1);
      lcd.print(y);
     }

    void functionInterrupt()
    {
      state = 1;

     }


texts: Get data from website with ESP8266 using AT commands

texts:
I'm trying to get data from a website by sending a HTTP GET request via AT commands for the ESP8266. Here is my current code:

#include <SoftwareSerial.h>

const byte rxPin = 2;
const byte txPin = 3;

SoftwareSerial ESP8266 (rxPin, txPin);

void setup() {
  Serial.begin(9600);
  ESP8266.begin(9600);
  delay(2000);
}

void printResponse() {
  while (ESP8266.available()) {
    Serial.println(ESP8266.readStringUntil('\n'));
  }
}

void loop() {

  ESP8266.println("AT+CIPMUX=1");
  delay(1000);
  printResponse();

  ESP8266.println("AT+CIPSTART=4,\"TCP\",\"192.168.1.19\",80");
  delay(1000);
  printResponse();

  String cmd = "GET /test.html HTTP/1.1";
  ESP8266.println("AT+CIPSEND=4," + String(cmd.length() + 4));
  delay(1000);

  ESP8266.println(cmd);
  delay(1000);
  ESP8266.println();
  delay(1000);
  printResponse();

  delay(5000);
}

Running this code I get the following response:

AT+CIPMUX=1

OK
AT+CIPSTART=4,"TCP","192.168.1.19",80
4,CONNECT

OK
AT+CIPSEND=4,27

OK
>
Recv 27 bytes

SEND OK

+IPD,4,

It looks like it gets a response, but nothing is printed.

I tried doing the same thing by sending the AT commands manually using this code:

#include <SoftwareSerial.h>

const byte rxPin = 2;
const byte txPin = 3;
SoftwareSerial ESP8266 (rxPin, txPin);

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

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

With this approach I actually get a response:

AT+CIPMUX=1

OK
AT+CIPSTART=4,"TCP","192.168.1.19",80
4,CONNECT

OK
AT+CIPSEND=4,27

OK
>
Recv 27 bytes

SEND OK

+IPD,4,275:HTTP/1.1 200 OK
Date: Thu, 22 Dec 2016 20:20:47 GMT
Server: Apache/2.4.23 (Win64) PHP/5.6.25
Last-Modified: Thu, 22 Dec 2016 19:37:22 GMT
ETag: "13-5444465f69339"
Accept-Ranges: bytes
Content-Length: 19
Connection: close
Content-Type: text/html

THIS IS MY WEBSITE!4,CLOSED

Does anyone know what is happening and how I can get this to work with my Arduino code?

Other ways to get data from a website are also welcome.


texts: Since double and float represent the same data type (usually), which is preferable?

texts:
It looks like on ATMega based boards, float and double are equivalent 32-bit (4-byte) data types.

However, on the Arduino Due, doubles are 64-bit (8-byte) where floats are 32-bit (4-byte), same as the ATMega boards.

I also saw one source on avr-gcc that listed double as non-standard.

So, when writing code for ATMega based boards are floats preferable to using doubles, since that would make the code equivalent for Due boards? Or are doubles preferable for any reason?


texts: How to receive and process a long string sent over serial?

texts:
I want to receive about 5kb of data in Base64 format. The following code does not work. Only a few characters are received, sometimes CPU crashes.

String content = "";
char character;

while (Serial.available()) {
       character = Serial.read();
       content.concat(character);
}

I do not care about ram usage since on ESP32 there is plenty.
How can I get all the data? Example input: https://pastebin.com/wYG5AhHK


texts: Unable to determine why the LCD shield does not initialize

texts:
I have an Arduino UNO and a 16x2 LCD Shield that have been lying unused for one year, or perhaps more. Yesterday I connected the Arduino via USB, uploaded a couple of simple sketches, played around with the LED and button bricks and everything seemed to be working fine. Then I tried to connect the LCD, but it wouldn't work. I eventually adjusted the potentiometer until one row had solid white squares on it and the other did not, with the backlight lit.

I tried both connecting the shield directly on top, or separately using wires and wiring up the +5V, GND and 12, 11, 5, 4, 3, 2 pins. I also checked the wires and the pins using digitalWrite and digitalRead. The problem doesn't seem to be there. No matter what I try I cannot get it to display anything else other than squares.

I have tried using different pins and changed the LiquidCrystal initialization accordingly, I have also tried the I2C  Scanner and it just kept reporting that no LCD was found (with the shield mounted and lit).

I have no idea what to do next or how to determine whether the LCD panel controller is broken or not.


texts: Send Email through Cayenne serial connection

texts:
I have an Arduino Uno connected to Cayenne through the serial connection, currently i am reading the data from a sensor of temperature and humidity DHT12 and showing it in the Dashboard of Cayenne correctly.

I need to know if i can send emails from the Arduino using the connection that cayenne let me use, because i can't stay with the pre-defined alerts that the platform have.


texts: Arduino keeps blinking when LED is in high

texts:
I have implemented a very simple program that turns a LED off when a switch is pressed.

My code works, but, when the LED is in high state, the LED blinks fast then turns off.

When I try to use the switch, the LED lights up without me even touching the switch. It seems like there is an invisible current that flows.

Observing carefully, I found out that the body of my laptop is probably causing this issue. My laptop has a metal body.

Since my Arduino is powered via USB from my Laptop, on "HIGH" state and I touch the body of my laptop, the LED turns off but when I let go of my laptop, the LED turns back on but blinks very fast.

Pushing the switch button, turns off the LED but when I release the button, the LED lights up but blinks very fast again.

I tried using a power adapter set to 12V but it just lights up the LED on the arduino board but not the LED on the breadboard.

I tried plugging the USB to a desktop, it lights up the LEDs on the arduino board but not the LED on the breadboard as well.

The schema is like below.

My code works. It's just the rapid blinking stuff. Is it the static electricity or noise or something that is causing this issue?

const int ledPin = 13;
const int buttonPin = 7;

int buttonState = 0;

void setup(){
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT);
}

void loop(){
  buttonState = digitalRead(buttonPin);
  if(buttonState == HIGH) {
    digitalWrite(ledPin, HIGH);
    Serial.println("LED ON +++++++++++");
  }
  else{
    digitalWrite(ledPin, LOW);
    Serial.println("LED OFF ------------");
  }
}


texts: Problem with a function having a parameter with a default value

texts:
I've got a problem using a default value for a function parameter.
This code gives "'blink' was not declared in this scope":
void loop(void) {
  blink(12, 2, 1000);
}

void blink(const uint8_t led, int num, const uint16_t l = 12) {
  Serial.println(led);
  Serial.println(num);
  Serial.println(l);
}

but it works if I don't assign a default value to the "l" arg:
void blink(const uint8_t led, int num, const uint16_t l) {

or if I put the blink function before the loop:
void blink(const uint8_t led, int num, const uint16_t l = 12) {
  Serial.println(led);
  Serial.println(num);
  Serial.println(l);
}

void loop(void) {
  blink(12, 2, 1000);
}


texts: WS2812B not fully working with NodeMCUv2 [ESP8266]

texts:
I have a problem with my NodeMCU v2 board and my WS2812B led matrix with 256 (32x8) LEDs.

The Board cannot be able to turn on the 191th led and stops working after the 190th without changing the color of the rest of the strip.

I'm using an external power supply 5V 20A and the strip is connected as shown below

I tested the problem with the FastLED library.

#include <Arduino.h>
#include <FastLED.h>
#define NUM_LEDS 256
#define DATA_PIN 2

CRGB leds[NUM_LEDS];

void setup() {
  Serial.begin(9600);
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}

void loop() {
  for(int dot = 0; dot < NUM_LEDS; dot++) {
      leds[dot] = CRGB::Red;
  }
  FastLED.show();
  delay(10000);
  for(int dot = 0; dot < NUM_LEDS; dot++) {
      leds[dot] = CRGB::Black;
  }
  FastLED.show();
  delay(10000);
}

The result is this

How I can solve this?


texts: Everything is ready for project . I have one doubt! I am using transmitter + Arduino *Uno*..and receiver + arduino *nano* will it work?

texts:
Everything is ready for project except hardware!

I have one doubt!

I am planning to use transmitter of Arduino Uno and receiver of Arduino Nano.  Will it work? Both Uno and Nano obey for same program? (The transceivers used are  Nrf24lO1 pa+lna!)


texts:
I have made this If-Then-Else code, but it doesn't work.

First I tough only the analog code is wrong, but if I take a digital port, the code doesn't work either.

What did I do wrong?

int sensorPin = A0;    // select the input pin for the potentiometer
int sensorValue = 0.00001;  // variable to

void setup() {
  pinMode(13, OUTPUT);  //LED BORD UIT
  pinMode(12, OUTPUT);  //LED4
  pinMode(11, OUTPUT);  //LED3
  pinMode(10, OUTPUT);  //LED2
  pinMode(9, OUTPUT);   //LED1
  pinMode(8, OUTPUT);   //Elektro Magneet
  pinMode(A0, INPUT);
}

void loop() {
  if (A0 == HIGH) {
     digitalWrite(13, LOW);
     digitalWrite(12, HIGH);   //LED on, magnet off
     digitalWrite(11, HIGH);
     digitalWrite(10, HIGH);
     digitalWrite(9, HIGH);
     digitalWrite(8, LOW);

  } else {
     digitalWrite(13, LOW);
     digitalWrite(12, LOW);   // LED Off, magnet on
     digitalWrite(11, LOW);
     digitalWrite(10, LOW);
     digitalWrite(9, LOW);
     digitalWrite(8, HIGH);
  }
}


texts: How to use pins for I2C that is used from other hardware?

texts:
I am using ESP32 CAM for one project and I have a sensor that is I2C connected to pins 21 and 22 (default I2C). The sensor is working fine until I turn on the camera. The camera uses this pins (21,22) as input output, not for I2C communication. When I try to read the sensor data in the loop I can't reach the sensor. I want to check the sensor data mainly and if there is some indication from the sensor to turn on the camera.
 How I can make this redefinition of the pins in the main loop?
I did try to declare the pins with  Wire.begin(21,22, 100000); in the loop but is not working.


texts: Is there any way or library to communicate two Arduino devices with encrypted connection using modules NRF24L01 or "433Mhz RF" ? Similar encryption like CCMP in Wi-Fi network.


texts: Maximum baud rate for sending a byte of data via SoftwareSerial from master Arduino UNO to slave Arduino UNO

texts:
I am trying to read data from a Blynk widget via ESP8266 and Arduino UNO and trying to send it to another slave Arduino UNO.  But, the problem is the data is taking some time to reach to the slave Arduino for further processing and I need it to be fast as it is needed for controlling a drone.
If any one can help, please help. I am a tenth grader and a newbie. So, I don't have a lot of experience.
Here is the code for the master Arduino:
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SoftwareSerial.h>   //We are using software serial so as not to conflict with serial download and monitor

SoftwareSerial mySerial(5,6); // RX, TX

int of=0;
int throttle=0;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "auth";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "wifi_name";
char pass[] = "wifi_pass";

// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1
// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200

ESP8266 wifi(&Serial);
WidgetLED l(V3);

void setup()
{
 // Debug console
 Serial.begin(9600);
 delay(10);
 // Set ESP8266 baud rate
 Serial.begin(ESP8266_BAUD);
 delay(10);
 Blynk.begin(auth, wifi, ssid, pass);
 mySerial.begin(9600);
}

void loop()
{
 Blynk.run();
 l.on();
 mySerial.write(of);
 mySerial.write(throttle);
}

BLYNK_WRITE(V1)
{
  of = 100+param.asInt();
}

BLYNK_WRITE(V2)
{
  throttle = param.asInt();
}


texts: What could cause interrupts from MCP23017 suddenly stop working?

texts:
I have 4 rotary encoders connected to an MCP23017 which in turn is connected to interrupt port 0 on the arduino (and to I2C of course). Everything works fine: I get interrupts for all 4 rotary encoders, can read the values for them and even store these values in the EEPROM and load them in setup.

Now, I connect a WS2812 LED to the arduino (with a resistor and a capacitator in front of it). I connect the UNO and the led lights up. I attach the serial console (resetting the UNO) and it stops working (LED does not light up). This could just be simple wiring mistake and is not my real problem.

I remove the LED (and the capacitor) from the board and start everything up again. I can see via the serial console that the UNO works, however it does not receive any interrupts anymore. I exchange the MCP23017 thinking I fried it somehow but that doesn't change anything either...

Is there some sort of state the UNO has I could have affected?

Or could I have fried the interrupt "sub-system" on the UNO (again: all the other stuff still works)?

EDIT: The code is here: https://github.com/qollin/Liting/blob/master/src/Liting.cpp


texts:
Please, someone.

I want to use a temperature sensor (DS18B20) in an I2C only shield (Tentacle Mini), but this sensor is One Wire only. Can I write an I2C code to change the 1-Wire to I2C for this sensor? I think to use the (DS2482-800) bridge, but I don't know how to do...

Thanks!


texts: In ESP-12E NodeMCU, what's the pin number of A0?

texts:
In ESP-12E NodeMCU, all digital pins can be called with a number. Here is the list:

static const uint8_t D0   = 16;
static const uint8_t D1   = 5;
static const uint8_t D2   = 4;
static const uint8_t D3   = 0;
static const uint8_t D4   = 2;
static const uint8_t D5   = 14;
static const uint8_t D6   = 12;
static const uint8_t D7   = 13;
static const uint8_t D8   = 15;
static const uint8_t D9   = 3;
static const uint8_t D10  = 1;

So these two lines of code will do the same:

pinMode (D0, INPUT)
pinMode (16, INPUT)

What's the corresponding number for A0 (the only analog input of this board)?


texts:
The Arduino IDE used to warn you when your sketch used too much memory. This warning now seems to have been removed. I compiled a sketch, and was surprised to see it use 175% of data memory...but not give me any explicit warning that this would be unstable, much less be physically unable to load onto the Arduino.

What are program and data memory usage levels that you should be concerned about? I seem to remember the best practice was to keep data memory under 80%. Is this still true? Is there any general rule for program memory?


texts: Syncing/taking external clock for SPI on Arduino Due

texts:
I have an Arduino Due with a SAM3X8E chip and am trying to read SPI data from an external source that is communicating in SPI. I was able to get data by identifying specific bytes that are identifiers but realized that the clock for my board is not synced with the source coming in. I print out the bytes in hexadecimal format (08 00 FF AB etc) and each message is 128 bytes long.

To be clear, the source is an SPI master that is sending out data on its own MOSI line, but I am currently treating my board as a master as well since I do not know how to do Slave mode on Due. I connect the Slaves MOSI line to my boards MISO line, and just transfer data and read 128 bytes but it would appear that I am not getting the same data. Is there a way for my to take in the clock from the external clock and synchronize my board with that clock to make sure? My source code is below. The only methods I can think of are to either figure out how to implement the board in slave mode (i'm not familiar enough with the registers and how to change this, or read data in slave mode) or synchronize the clocks so my board is reading and sampling the source data correctly.

Could someone check if my thinking is correct, or do I not need to make any changes since the data is in a shift register?

Thanks

void setup(){
Serial.begin(9600);
SPI.begin();
SPISettings settings (50000000, LSBFIRST, SPI_MODE1); //Sampling rate    50Mhz, source's max speed
SPI.beginTransaction(settings);
}

void loop(){
  int i = 0;
  uint8_t value;
  value = SPI.transfer(0x00);
  while (value != 8){//searching for identifier 0x08
    value = SPI.transfer(0x00);
  }
  SPI.transfer(buffer, 127);//get the rest of the 127 bytes
  Serial.print(value, HEX);
  Serial.print(" ");
  for (i = 0; i < 127; i++){
    if (buffer[i] == 0){
      Serial.print(buffer[i],HEX);
      Serial.print(0, HEX);
    }
    else{
      Serial.print(buffer[i], HEX);
    }
    Serial.print(" ");
  }
  Serial.println("\n");
}


texts:
I just bought a motor shield for my UNO, in the pic below:

Plugging it into the uno leaves no pins accessible on the board. I’d like to use it to build a robot car, but there’s nowhere to plug in the ultrasonic sensors. Do I need to solder some pins to the row at the top of the pic, or to the through-board holes on the right labelled A0-5?


texts: Why the 4.7 K Ω resistor in this pitch follower sketch?

texts:
I am reading Arduino for Dummies, and I am blocked at the pitch follower exercise. It consists in making a piezo vary with a light sensor. I can't see the point of the resistor (and why 4.7?) in this sketch:

Any help for a dummy is appreciated! :-)


texts:
I'm trying to display a bitmap on gLCD 128x64, I stored the bitmap into txt file 1.txt in a SD card this is a part of bit map  as following:

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0,
0xC0, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00.......

I want to convert the content of this text into array:
Unsigned char logo[] with making a split on ",".

Any help please


texts: Need help with idea before I buy parts. Want to use arduino to act as the button on a TRRS wire to answer and hang up calls

texts:
I intend to buy CH340G USB Microcontroller Board Arduino UNO R3 ATmega328P Development Module

I want to use it and a MOSFET or whatever needed to act as a button for a TRRS wire I already have home made to act as a call button. I know it has to be 0ohm when activated but im not sure if this can be done and with what and how.

I was hoping to have a key on my computer activate the code from the arduino which I dont mind figuring out later but I just need to get an idea on what to use for the button and how I would activate it after wiring.


texts: Ultimate GPS Logger Shield : Soft Serial Sketch Error

texts: Im using a OSEPP Uno R3 Plus to connect with a Ultimate GPS Logger Shield. I am currently working through the Adafruit Ultimate GPS Logger Shield pdf. When connecting in Soft Serial Mode and loading a parsing sketch. In the com window my values are showing but unreadable. I have included an image. Any help is appreciated.


texts:
   I'm trying to teach myself some low[er] level code, but I just can't get it to work. I've tried OR-ing stuff in, AND-ing stuff in, and just straight up defining stuff, but it's not blinking! What am I doing wrong here?

I am using an Arduino UNO R3 DIP for this. I am just using the on-board LED, (on pin13/PORTB_5)

Current code:

#define STATE B00001000
#define ZERO B00000000
void setup() {
    DDRB = STATE;
    }

void loop(){
    PORTB |= STATE;
    delay(500);
    PORTB &= ZERO;
    delay(500);
    }


texts: Capacitive sensor MPR121 on Arduino Uno—how many will work?

texts:
I need to attach several capacitive sensors MPR121 with each of them using all of its 12 electrodes to an Arduino Uno.

Could you please tell me, how many will work with the voltage and current Arduino Uno supplies?


texts:
Hello, I apologise for being such a noob but can someone help with this.
I am having trouble working with this. When I insert the arduino's pins into my new usb host shield , there is no indication light and when I plugged my Xbox receiver into the shield it does not turn on as it would with my desktop. Any thoughts? Please post below


texts: Getting individual outputs from 4 load cells

texts:
This is my first time using an Arduino, and I want to connect 4 load cells to one Arduino board and then get 4 separate outputs for each load cell on a computer.
What would I need to accomplish this and how would I set it up?
Can all four load cells connect to a single Arduino?

Also, could I get it to work with these load cells in particular:

https://www.amazon.co.uk/HALJIA-Weighing-Resistance-Half-bridge-Original-Silver/dp/B0792WCGJC/

or would I have to use ones with a 4 wire output?


texts:
I've soldered a featherwing on my feather, then unsoldered it because it had stopped working: after the soldering of the featherwing, I was unable to upload new software to the board.

But now that the featherwing was removed, I still can't upload a software onto the board.

Here's the complete log I get:

$ ~/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/bin/avrdude -C~/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -P/dev/ttyUSB0 -b57600 -D -Uflash:w:/tmp/arduino_build_190205/Blink.ino.hex:i

avrdude: Version 6.3, compiled on Jan 17 2017 at 11:00:16
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "~/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf"
         User configuration file is "~/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyUSB0
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

avrdude done.  Thank you.

I used to have this error from time to time before, but I always was able to make it work, either by using another USB port, choosing the right port for the arduino or rebooting Linux, but now nothing I do works.

So, I think I might have broken the board because of the soldering/unsoldering.

I attached the pictures of both sides of the board.

Three LEDs continue to blink: the red one when I connect the board to the USB, the battery one and the RX one when there is an attempt at transmission.

Can you tell me whether the board looks damage?


texts:
I am trying to port a simple project I have working in an Arduino UNO to a NodeMCU but I am stuck as I am using the analog gpio to receive the input from some buttons, I am always getting always low values (between 0 and 5) while in the working arduino sketch I get values from 0 to 1023.

I have tried deactivating the wifi while trying to retrieve the values, but I got no luck trying that, as I have read that sometimes the NodeMCU A0 gpio malfunctions when the wifi is not sleeping.

I am setting up the gpio in the setup method like this:

void setup(void){
    pinMode(sensorPin, INPUT_PULLUP);
    ...

And my sensorPin variable is declared in the beginning of the sketch

int sensorPin = A0;

Any ideas why when I read the value in the NodeMCU I don't get the same behaviour as in an Arduino board?


texts: I am currently using a simple protocol I created to send three bytes (unit information, data, and XOR) individually over an XBee radio (3 bytes are considered a single transmission). However, this is not always reliable if a byte is dropped. For this reason I'd like to encapsulate each individual byte as a packet in a way that the Arduino could identify which byte is which and if a byte is lost then just wait for the next transmission. What I am not sure about is creating a packet. I haven't been able to find any tutorials or example code.


texts: I cannot get my code to play music in a or manner. I have to open one switch then the other. Music should play with either door open

texts:
Problem is if I open the necklaceDoor first, nothing happens. I have to open the ringDoor first. That turns everything on. Then with the necklaceDoor open, the stepper motor will turn off and the lights and music will continue to play. But I want to be able to open the necklaceDoor first and play the music with the lights. I do not want it to matter which one is opened first. I also realized that if I can get an or statement to work within an and statement I could do away with the fourth if statement completely. Both ringDoor open and necklaceDoor open, as well as ringDoor closed and necklaceDoor open have the same outcome. Now if I switch the door states in the third if statement, I get necklaceDoor only plays audio after closed(original problem) but if both doors are open and then ringDoor is closed, the music will shut off after the stepper timer is done and then start again after necklaceDoor is closed?!?!?!?
#include <SD.h>
#include <TMRpcm.h>
#include <Stepper.h>
TMRpcm tmrpcm;

const int stepsPerRevolution = 2048;   //Number of pulses per revolution
const int ringDoor=2;                  //Ring door
const int necklaceDoor=7;              //Necklace door
const int relayPower=22;               //Turn relay on

Stepper myStepper = Stepper(stepsPerRevolution, 8, 10, 9, 11);

void setup() {
  Serial.begin(9600);                         //Start connection with computer

  if (!SD.begin(53))                         //Chip pin on card
  {
    Serial.println("failed!");                //SD card did not read
    return;
  }

  tmrpcm.speakerPin = 46;                      //Speaker output pin
  myStepper.setSpeed(5);                       //Stepper speed
  pinMode(ringDoor,INPUT);                     //Check state of ring door magnetic switch, NO
  pinMode(necklaceDoor,INPUT);                 //Check state of necklace door magnetic switch, NO
  pinMode(relayPower,OUTPUT);                  //Relay enable for 12V LED
  digitalWrite(ringDoor,HIGH);                 //Make door closed read high on start up
  digitalWrite(necklaceDoor,HIGH);             //Make door closed read high on start up
  digitalWrite(relayPower,LOW);                //Make relay off on start up
}

void loop() {

  if ((digitalRead(ringDoor)==HIGH)&&(digitalRead(necklaceDoor)==HIGH))
  {                                                                                //ring door and necklace door is closed, everything is off
    digitalWrite(relayPower,LOW);
  }

  if ((digitalRead(ringDoor)==LOW)&&(digitalRead(necklaceDoor)==HIGH))
  {                                                                                //ring door is open and necklace door is closed, lights on, stepper motor spinning, music playing
    digitalWrite(relayPower,HIGH);
    tmrpcm.play("music.wav");
    myStepper.step(stepsPerRevolution);
    delay(500);
    myStepper.step(-stepsPerRevolution);
    delay(500);
  }

  if ((digitalRead(ringDoor)==LOW)&&(digitalRead(necklaceDoor)==HIGH))
  {                                                                                //ring door closed and necklace door open, lights on, stepper motor off, music playing
    digitalWrite(relayPower,HIGH);
    tmrpcm.play("music.wav");
  }

  if ((digitalRead(ringDoor)==LOW)&&(digitalRead(necklaceDoor)==LOW))
  {                                                                                //ring door and necklace door open, lights on, stepper motor off, music playing
    digitalWrite(relayPower,HIGH);
    tmrpcm.play("music.wav");
  }
}

Please and thank you to any and all who help. It is greatly appreciated.
Yes, I asked the the original question and the answer I received not only did not work, somehow neither latch worked anymore.


texts:
I am doing my CBT, and i need help...
I need a Webservice in C#, and it will send commands to my Arduino( Mega 2560 + Ehternet Shield )...
My Webservice will recibe commands from Android and Web

EDIT

I wanna know what kind of C# WebService Project I have to create...


texts:
This is my send and receive code in STM32 (blue board).
But i can't send and receive data . why?
I did use Enrf24.h .
Enrf24 link: https://github.com/spirilis/Enrf24
send code is:

#include <SPI.h>
#include <Enrf24.h>
#include <nRF24L01.h>
#include <string.h>
#define ce_nrf PB12
#define csn_nrf PB13
#define irq_nrf PA0
Enrf24 radio(ce_nrf, csn_nrf, irq_nrf);  // P2.0=CE, P2.1=CSN, P2.2=IRQ
const uint8_t txaddr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 };
void setup() {
  Serial.begin(9600);
  SPI.begin();
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);
  radio.begin();  // Defaults 1Mbps, channel 0, max TX power
  radio.setTXaddress((void*)txaddr);
}

void loop() {
  Serial.print("Sending packet: ");
  radio.print("OONN");
  radio.flush();  // Force transmit (don't wait for any more data)
  delay(1000);
  Serial.print("Sending packet: ");
  radio.print("OOFF");
  radio.flush();
  delay(1000);
}

receive code is:

#include <SPI.h>
#include <Enrf24.h>
#include <nRF24L01.h>
#define ce_nrf PB12
#define csn_nrf PB13
#define irq_nrf PA0
Enrf24 radio(ce_nrf, csn_nrf, irq_nrf);  // P2.0=CE, P2.1=CSN, P2.2=IRQ
const uint8_t rxaddr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 };
const char *str_on = "ON";
const char *str_off = "OFF";
void dump_radio_status_to_serialport(uint8_t);
void setup() {
  Serial.begin(9600);
  SPI.begin();
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);
  radio.begin();  // Defaults 1Mbps, channel 0, max TX power
  radio.setRXaddress((void*)rxaddr);
  radio.enableRX();  // Start listening
}

void loop() {
  char inbuf[33];
  while (!radio.available(true));
  if (radio.read(inbuf)) {
    Serial.print("Received packet: ");
    Serial.println(inbuf);
  }
}

this image can help :


texts: Estimate soc battery and discharge time using Arduino Uno

texts:
I am currently learning to do a project for estimating the soc of LiPo batteries with coulomb counting and calculating discharge time using Arduino Uno to display a warning when the battery runs out.
however, I don't even know where to start. Can anyone help provide a reference for the code and its working steps?
Thank you in advance!


texts: Use Arduino to transmit signal to a vibrating pager

texts: I am an engineer at a machine shop. When a machine stops running, I want to be notified via a vibrating pager (like at restaurants). My plan is to attach the arduino board in the machine and when the machine stops (quits vibrating) I want it to trigger the vibrating pager that I have in my pocket. By what means can the arduino communicate with the vibrating pager to cause it to go off? SMS? Wifi? Bluetooth would likely be out of range. Other options?


texts: Arduino nano ATmega328p with CH341 won't upload

texts:
When I try to upload a sketch to an Arduino Nano, it stays stuck on uploading, and after a time it shows the following error code:

stk500_getsync() attempt 1 of 10: not in sync: resp=0xc2
stk500_getsync() attempt 2 of 10: not in sync: resp=0xc2
stk500_getsync() attempt 3 of 10: not in sync: resp=0xc2
stk500_getsync() attempt 4 of 10: not in sync: resp=0xc2
stk500_getsync() attempt 5 of 10: not in sync: resp=0xc2
stk500_getsync() attempt 6 of 10: not in sync: resp=0xc2
stk500_getsync() attempt 7 of 10: not in sync: resp=0xc2
stk500_getsync() attempt 8 of 10: not in sync: resp=0xc2
stk500_getsync() attempt 9 of 10: not in sync: resp=0xc2
stk500_getsync() attempt 10 of 10: not in sync: resp=0xc2

Sometimes the resp=0xc2 variable changes to another hex code.

The weird thing here is that before this happened everything worked fine. I could upload and the serial communication was fine. But after trying to upload the same sketch with a different variable, this started to happen.

Windows recognizes the COM port, in Arduino the COM port is selected. Sometimes, without doing anything, the Arduino works fine again, I can see the serial communication fine, but after some time the serial communication stops sending and again I can't upload the sketch.

I have 2 Arduino Nanos. Both of them start presenting the same problem. But the other one has the Power, RX, and TX led always on and this one never worked again, like the other one that sometimes can upload the sketch and see the serial communication that the last sketch was sending. I have an Arduino Mega, this one has the ATmega16U2 to communicate to USB and this one works fine. And I also have a NodeMCU Lua, with CH341. But this one works just fine.


texts:
Sorry about a newbie.
1. what mening of:

    if(Xstr[XstrLength-1] != '|'){
      Xstr[XstrLength] = '|';
      Xstr[XstrLength+1] = '\0';

the setup: char Xstr[60]; what means? and then: itoa(Yint,Ystr,10);

Code:

#include <VirtualWire.h>

//gamepad setup
int up_button = 2;
int down_button = 4;
int left_button = 5;
int right_button = 3;
int start_button = 6;
int select_button = 7;
int joystick_button = 8;
int joystick_axis_x = A0;
int joystick_axis_y = A1;
int buttons[] = {up_button, down_button, left_button, right_button, start_button, select_button, joystick_button};

void setup()
{

    //gamepad setup
    for (int i; i < 7; i++)
    {
        pinMode(buttons[i], INPUT);
        digitalWrite(buttons[i], HIGH);
    }

    Serial.begin( 9600 );

    //transmitter setup
    vw_set_tx_pin(12);          // Sets pin D12 as the TX pin
    vw_set_ptt_inverted(true);  // Required for DR3100
    vw_setup(2000);             // Bits per sec
}

int counter = 0;

int Xint;
int Yint;

char Xstr[60];
char Ystr[60];

void loop()
{
    // Read and store Sensor  data
    Xint = analogRead(joystick_axis_x);
    Yint = analogRead(joystick_axis_y);

    // Convert integer data to Char array directly
    itoa(Yint,Ystr,10);
    itoa(Xint,Xstr,10);

    int XstrLength = String(Xstr).length();

    if(Xstr[XstrLength-1] != '|'){
        Xstr[XstrLength] = '|';
        Xstr[XstrLength+1] = '\0';
    }

    char combinedArray[String(Xstr).length() + String(Ystr).length() + 1];
    sprintf(combinedArray, "%s%s", Xstr, Ystr);

    vw_send((uint8_t *)combinedArray, strlen(combinedArray));
    vw_wait_tx(); // Wait until the whole message is gone

    Serial.println(combinedArray);

}


texts:
It seems they stop the production of arduino starter kit (official), it's hard to find it on pro website.
Is there an other very good starter kit to start ? I mean I would like to try everything on small given project before starting my own project.


texts: How to program an Arduino Uno Pro with a makefile?

texts:
I'm using Arduino Makefile to compile sketches for Uno and Mega boards. I'm now trying to compile a sketch for an Arduino Uno Pro, which is an Uno with a replaced chip to give it features more like a Mega.

When writing a makefile to compile for this board, which BOARD_TAG should I use? I don't see this board listed in the official Arduino or Arduino Makefile docs.


texts:
I am a beginner at Arduino. I want to power the Arduino through the USB cable that is usually plugged in the USB of the laptop, but plugged in the wall instead of the laptop.

Here are my questions:

Can I use a phone charger that has a USB (in which the end of the USB
cable will go instead of the USB of the PC)?
What should I look for written on the charger so it is best
compatible?
Is it ok to be done that way?
Will it be the same as means of power like when it is plugged in the
PC (for example when later on I connect LCD display, diodes, etc.)?

I did my research, but it got confusing, so I wanted to ask my own question. Thanks in advance.


texts: Is it possible to simulate PWM using delay() function?

texts:
I was thinking about if it is possible to simulate PWM (AKA pulse width modulation).
Is it possible to reach the speed of the PWM using the delay() function ?.
Note : I am talking about the pins which does not support PWM, Arduino uno Pin 13 for example.


texts:
I have optimised it as much as I feel I can and want to know what suggestions you have that could make it more efficient etc.
Note: I know the array goes on forever :)
volatile uint16_t IRCode[]={340,171,21,21,21,21,21,21,21,64,21,21,21,21,21,21,21,21,21,64,21,21,21,64,21,21,21,64,21,64,21,64,21,64,21,64,21,21,21,21,21,21,21,64,21,21,21,21,21,21,21,21,21,64,21,64,21,64,21,21,21,64,21,64,21,64,21,1556,340,86,21,3654}; // ProntoHex to uint16_t delete first 4 array numbers.
volatile uint16_t MicrosPassed;
volatile uint8_t Array_Seq;
uint8_t State;

void setup() {
  Config(); // Config sketch will set working settings for different microcontrollers.
  SendIRCode();
}

void loop() {

}

void SendIRCode() {
  switch(State) {
    case 1:
      TCCR1A&=63; // Opposite of case 0 -193 = 63
      State=0;
      break;

    case 0:
      TCCR1A|=192;
      State=1;
      break;
  }
}

void Config() {
  DDRB|=10;
  ICR1=416;
  OCR1A=9983;
  TCCR1A=2;
  TCCR1B=24;
  TCCR1B|=1;
  TIMSK1=1;
}

ISR(TIMER1_OVF_vect) {
  MicrosPassed++;
  if(MicrosPassed==IRCode[Array_Seq]) {
    SendIRCode();
    MicrosPassed=0;
    Array_Seq++;
       }
}


texts:
I create applications for a computer that is to be used to control the robot arm. I wanted to make the first attempt to run the application not on the motor, but on the diode and check if it will change its brightness depending on the position of the slider. I wrote an application in Qt that sends thongs to Arduino, and Arduino I read and converts to int. The problem is that although the slider is set to 0, the Arduino does not show it, often the figures do not agree too often (often too small), also when I suddenly move the number slider all the time count towards the front instead of back.

Arduino code:

String br;

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

void loop()
{
   while (Serial.available()>0)
 {
    br = Serial.readString();
    analogWrite(9, br.toInt());
    Serial.println(br.toInt());
 }
}

Qt code:

void MainWindow::on_horizontalSliderGrip_sliderMoved(int position)
{
   this->sendMessageToDevice(QString::number(position) + "n");
   qDebug() << "Grip: " << QString::number(position);
}

void MainWindow::sendMessageToDevice(QString message)
{
   if(this->device->isOpen() && this->device->isWritable())
   {
       //this->addToLogs("Sending information to the device " + message);
       this->device->write(message.toStdString().c_str());
   }
   else
   {
       this->addToLogs("I can not send a message. The port is not open!");
   }
}


texts: Serial Monitor is printing out weird values and skipping strings

texts:
I am currently working on a project with some friends. In short, we want to create a setup where when a button is pressed a thermal printer prints out a random sentence.

I am currently trying to get my code to work and to debug it with the Serial Monitor, but it prints out weird stuff.

The baud rate is the same for the monitor and the Serial.begin().

int checkSum[] = {-1, -1};

String stringPool[] =
                      {
                        "Satz 1", "Satz 2",
                        "Satz 3", "Satz 4",
                        "Satz 5", "Satz 6",
                        "Satz 7", "Satz 8",
                        "Satz 9", "Satz 10",
                        "Satz 11", "Satz 12",
                        "Satz 13", "Satz 14",
                        "Satz 15", "Satz 16",
                        "Satz 17", "Satz 18",
                        "Satz 19", "Satz 20",
                        "Satz 21", "Satz 22"
                      };

String chooseRandom ()
{
  bool isMaybeThreeTimes;
  int randomInt;

  do
  {
      randomInt = random( 0, sizeof( stringPool ) -1 );

      // first and further random number chosen
      if( checkSum[0] == -1 ) { checkSum[0] = randomInt; }
      else
      {
        checkSum[1] = checkSum[0];
        checkSum[0] = randomInt;
      }

      if( randomInt == checkSum[0] && randomInt == checkSum[1] )
      {
        isMaybeThreeTimes = true;
      }
      else
      {
        isMaybeThreeTimes = false;
      }

      Serial.print("Current random value: " + randomInt);
      delay(1000);
      Serial.print("Last random value: " + checkSum[0]);
      delay(1000);
      Serial.print("Last last random value: " + checkSum[1]);
      delay(1000);
      Serial.print("Three times in row?: " + isMaybeThreeTimes);
      delay(1000);

   } while ( isMaybeThreeTimes );

  return stringPool[randomInt];
}

void buttonPressed()
{
  String stringToPrint = chooseRandom();
  // Send the string to the adafruit printer.
  Serial.println(stringToPrint);
}

void setup()
{
    Serial.begin(19200);
    delay(2000);
    Serial.println("Setup finished");
    randomSeed(analogRead(0));

}

void loop()
{
    buttonPressed();
}

Any ideas why this is happening? I switched the baud rates changed delays and changed the places on where and how often and in which frequeny the method buttonPressed() is called.

Here a picture of the output:


texts: Using Arduino Mega with multiple HC05 Modules as masters, communicating to multiple HC05 Modules as slaves, each connected to separate Arduino

texts:
So I have not actually experimented with the HC05 Bluetooth Module yet, but I have read up about it and watched some videos. From what I understand, you cannot use one module (master) to communicate with more than one other module (slaves), or at least its pretty difficult. But, you can use a module hooked up to an arduino to communicate to to another module hooked up to another arduino (I believe pretty simply).

However, I thought it might be possible to use an Arduino Mega (because it has multiple TX/RX pins) with 3 HC05 Bluetooth modules, to each communicate to 3 separate HC05s which would each be hooked up to an arduino nano. I know this might have to do something with running multiple Software Serials (I have no idea what that is to be honest)?

The project involves using the master arduino to "listen" for a button pressed on the slave arduino (across the room without connecting wires), then listening for another button press from one of the other slaves in some sort of sequence and within a certain time frame.

Does anyone have any idea about how this might be done, even if it doesn't use the HC05 Bluetooth Module?

Thanks!


texts: What are some "must-have" sensors or shields for an Arduino robot or motor?

texts: I am starting to learn Arduino and wanna make some projects.which components will  I have to buy?please help me.


texts: Using Arduino project migrated to breadboard with 12 MHz crystal instead of 16 MHz

texts:
I am moving my Arduino Uno project from Uno to Bread and as we know, this requires two 22 pf capacitors and 16 MHz on the breadboard (and the other things too like the power-but my question is about the crystal frequency so I'll focus on that).

If I replace the 16 MHz crystal with a 12 MHz crystal then the project will work as expected on a breadboard-is that correct?

It seems that the fuse setting to use 16 MHz crystal is the same as for the 12 MHz crystal for Arduino Uno-so I guess a change to the fuse setting or bootloader is not required. Am I missing anything?

I guess it's as simple as replacing a 16 MHz crystal by a 12 MHz crystal.


texts: Breaking out of while loop using IR remote input

texts:
I'm trying to control a series of LEDs using an IR remote. I have a problem when I try to play a sequence with the LEDs where they all light up in a line and turn off accordingly. I loop through the sequence and I am trying to make it so the instant I press a button on the remote it breaks out of that sequence. The issue lies in the Flash(); function, I think. What can I do?

#include <boarddefs.h>
#include <IRremote.h>
#include <IRremoteInt.h>
#include <ir_Lego_PF_BitStreamEncoder.h>

int recvPin = 11;
IRrecv irrecv(recvPin);
decode_results results;

#define BUTTON_ON 0xF076C13B    // codes for different buttons on the remote
#define BUTTON_OFF 0xFF9186B7
#define BUTTON_R 0xE5CFBD7F
#define BUTTON_G 0x8C22657B
#define BUTTON_B 0x2A89195F
#define BUTTON_FLASH 0x35A9425F

int rLED = 5;
int gLED = 4;
int bLED = 3;
int stR = LOW;  // intital state of red LED
int stG = LOW;  // intital state of green LED
int stB = LOW;  // initial state of blue LED
int flash = false;

void setup() {
  Serial.begin(9600);   // Status message will be sent to PC at 9600 baud
  pinMode(rLED, OUTPUT);
  pinMode(gLED, OUTPUT);
  pinMode(bLED, OUTPUT);

  irrecv.enableIRIn();
}

void Flash() {    // flashing function
  while (flash == false) {
    digitalWrite(rLED, LOW);
    digitalWrite(gLED, LOW);
    digitalWrite(bLED, LOW);
    digitalWrite(rLED, HIGH);
    delay(75);
    digitalWrite(gLED, HIGH);
    delay(75);
    digitalWrite(bLED, HIGH);
    delay(75);
    digitalWrite(rLED, LOW);
    delay(75);
    digitalWrite(gLED, LOW);
    delay(75);
    digitalWrite(bLED, LOW);
    delay(75);
    stR = LOW;
    stG = LOW;
    stB = LOW;
    if (results.value == BUTTON_OFF)    // attempting to make it so when i press the OFF button on the remote,
    {                                   // the loop breaks/stops and I can go back to pressing any button on
      break;                            // the remote
    }
  }
}

void loop() {
  if (irrecv.decode(&results))
  {
    if (results.value == BUTTON_ON)
    {
      digitalWrite(rLED, HIGH);
      digitalWrite(gLED, HIGH);
      digitalWrite(bLED, HIGH);
      stR = HIGH;
      stG = HIGH;
      stB = HIGH;
    }
    if (results.value == BUTTON_OFF)
    {
      digitalWrite(rLED, LOW);
      digitalWrite(gLED, LOW);
      digitalWrite(bLED, LOW);
      stR = LOW;
      stG = LOW;
      stB = LOW;
    }
    if (results.value == BUTTON_R)
    {
      digitalWrite(rLED, !stR);
      stR = !stR;
    }
    if (results.value == BUTTON_G)
    {
      digitalWrite(gLED, !stG);
      stG = !stG;
    }
    if (results.value == BUTTON_B)
    {
      digitalWrite(bLED, !stB);
      stB = !stB;
    }
    if (results.value == BUTTON_FLASH)
    {
      Flash();    // calling flash func
    }
    irrecv.resume();
  }
}


texts: Problem updating Arduino WiFi Shield's Firmware

texts:
I'm using Arduino Uno R3 and the official Arduino WiFi Shield R3. I'm trying to update the Shield's firmware to 1.1.0 through this guide.

Everything goes fine until Step 9. When I execute the code in Step 10, I get an error (see attachment) as:

AtLibUsbDfu: 3EB 2FF8 no device present

FAIL Could not open USB device.

ISP done.

EDIT: I re-installed the firmware on my shield and now the problem's gone.


texts: Why does a 4 digit 7 segment cathode display wired to an Arduino not need to be connected to ground?

texts: As a circuit neophyte I thought for a circuit to conduct current it had to be grounded.


texts: How do I upload sketches in multiple arduinos from one supervisor Arduino using UART , cd4051 for Rx and TX separately and reset pin low


texts:
Hey all this would be my first encounter needing to burn the Arduino IDE bootloader onto a blank ATMega32u4 that I bought from Digikey.

What all do I need to buy in order to program the bootloader for that chip? In the manual for the 32u4 it says it comes with a bootloader but I'm guessing its not the arduino bootloader?

Is the pinout for the ISP all that I would need in order to upload the Arduino bootloader?

I've seen this post:

but I wont be using the through-hole design.. its going to be the surface mount SMD kind so i wouldn't be able to put that on a breadboard.

So would it be as simple as breaking out the ISP pins on the 32u4 and just hooking those up to a Arduino Duemilanove board even if its not the same ATmega chip (As in copying the atmega32u4 arduino to the Duemilanove and then transferring that to the 32u4?)?


texts: Computer freezes while collecting serial data from Arduino Uno

texts:
I am an arduino noob. I have been searching for some interesting arduino projects recently and making a game controller using Arduino UNO seemed interesting. So I hooked up two dual-axis joystick modules to the arduino board and wrote a program to print something corresponding to the joystic movements. I collected the serial data through USB and passed it on to a python program. The code works fine, mostly. But the problem is, when I hook up the circuit and start using the joysticks, after few minutes my system  is freezing.
Why is my system freezing?
What can I do to avoid the freezing?
My system info:
1.Windows 10 64-bit
2.4GB RAM and 512GB HDD
Here is the code
int SW = 9;    // mouse joystick
int xpin = A0;
int ypin = A1;
int SW1 = 6;  //movement joystick
int xpin1 = A2;
int ypin1 = A3;
void setup()
{
  Serial.begin(9600);
  pinMode(SW, INPUT);
  digitalWrite(SW, HIGH);
  pinMode(SW1, INPUT);
  digitalWrite(SW1,HIGH);

}
int prev_state = 0; // previous state of switch
void loop() {
  int z = 0, xpos = 0, ypos = 0;
  int z1 = 0;char xpos1='0', ypos1='0';
  int x = analogRead(xpin);
  int x1 = analogRead(xpin1);
  int y = analogRead(ypin);
  int y1 = analogRead(ypin1);
  int sensitivity = 15; //mouse sensitivity

  if (x >= 550)                  // when moved up
    xpos = map(x, 550, 1023, 0, sensitivity);
  if (x <= 450)                // when moved down
    xpos = map(x, 450, 0, 0, -sensitivity);
  if (y >= 550)                 // when moved right
    ypos = map(y, 550, 1023, 0, sensitivity);
  if (y <= 450)               // when moved left
    ypos = map(y, 450, 0, 0, -sensitivity);
  int curr_state = digitalRead(SW);
  if (curr_state == 1 && prev_state == 0) // when SW is pressed
    z = 1;
  else
    z = 0;
  int prev_state1 = 0;
  if (x1 >= 550)                  // when pressed d
    xpos1 ='d';
  if (x1 <= 450)                // when pressed a
    xpos1 ='a';
  if (y1 >= 550)                 // when pressed w
    ypos1 ='w';
  if (y1 <= 450)               // when pressed s
    ypos1 ='s';
  int curr_state1 = digitalRead(SW1);
  if (curr_state1 == 1 && prev_state1 == 0) // when SW1 is pressed
    z1 = 1;
  else
    z1 = 0;
  if (xpos != 0 or ypos != 0 or z == 1 or xpos1=='d' or xpos1=='a' or ypos1=='w' or ypos1=='s' or z1 == 1) // prints when the joysticks are moved
  {
    Serial.print(xpos);
    Serial.print(":");
    Serial.print(ypos);
    Serial.print(":");
    Serial.print(z);
    Serial.print(":");
    Serial.print(xpos1);    // prints the data and separating by ":"
    Serial.print(":");
    Serial.print(ypos1);
    Serial.print(":");
    Serial.println(z1);
  }

  prev_state = curr_state;
  prev_state1 = curr_state1;
   delay(10);
}

I am using a python program, in visual studio code, to read the arduino serial data and perform the required operation.
The python code
import mouse, sys
import time
import serial
import keyboard as kb

mouse.FAILSAFE=False
ArduinoSerial=serial.Serial('com3',9600)  #assigning com port
time.sleep(1)

while 1:
      data=str(ArduinoSerial.readline().decode('ascii'))   #read the data
      (x,y,z,x1,y1,z1)=data.split(":")           # assigns to x,y,z,x1,y1,z1
      (X,Y)=mouse.get_position()        #read the current position of mouse cursor
      (x,y)=(int(x),int(y))
      mouse.move(X+x,Y-y)           # move camera/mouse
      # press the desired keys corresponding to joystick movement
      if y1=='w':
         kb.press('w')
         kb.release('w')
      if y1=='s':
         kb.press('s')
         kb.release('s')
      if x1=='a':
         kb.press('a')
         kb.release('a')
      if x1=='d':
         kb.press('d')
         kb.release('d')
      if '1' in z:                        # read the Status of SW
         mouse.click(button="left")    # clicks left button
      if '1' in z1:                    #read SW1
         kb.press('space')             # press space


texts: Can't fetch arduino param on server, Using POST method via arduino wifi shield

texts:
I am creating a slot sensor, using photoresistor.
The goal is to send the photoresistor value, via analog read, pin A0 to my web server, so I can stored it in my database.

void loop() {
  int sensorvalue = analogRead(A0);// LightValue, read from sensor pin A0
  data = "sensorValue=" + (sensorvalue);
  //there is a car parked
  if(sensorvalue >=1000){
    if(flagstatus == false){
            if (client.connect(server, 80)){
              Serial.println("Connected to Host Server");
              client.println("POST /dataPost.php/HTTP/1.1");
              client.print("Host:");
              client.println(server);
              client.println("Content-Type: application/x-www-form-urlencoded");
              client.print("Content-Length: ");
              client.println(data.length());
              client.println();
              client.print(data);

I've been trying to send mock data via postman, and it works like a charm, so I can eliminate my server side from the equation. Been guessing using : or = on sensorvalue=analogread(a0) or sensorvalue:analogread(a0). Or I made mistake on the code? I don't know much in Arduino, and this issue kinda frustrate me.

the Image just for confirmation only, of course I installed the protoboard correctly.

Connect to SSID: Adamar
IP Address: 192.168.1.14
Connect to server...
Connected with network---------
Connected to Host Server
sensorvalue:1007
There is still a car parked
sensorvalue:1007
There is still a car parked
sensorvalue:1008

I manage to get this result from my serial monitor, so I think there is no wrong reading from my setup.


texts:
So I have been diving deep into AVR programming and have seen several different ways of defining constants. I know that some of these methods are from "C" and others are from more modern "C++" methods. So my question here is what is the preferred method?

Method 1:

#define MAX_ARRAY_LEN 3

int my_array[MAX_ARRAY_LEN] = {1, 2, 3};

Method 2:

const int MAX_ARRAY_LEN = 3;

int my_array[MAX_ARRAY_LEN] = {1, 2, 3};

In my searches online I have ran across several pages that mention using PROGMEM in the declarations to load the variable into Flash memory instead of SRAM. The thing I am unclear about using PROGMEM is what should be loaded into Flash and what should be loaded into SRAM? Should I be loading all const into Flash? Are there any performance hits using Flash?

Edit

I guess I was not clear on what I was asking. I understand that #define and PROGMEM are not related. My question is there are a couple of methods that can be used to define constants. One is #define (Method 1) and the other is const (Method 2), with the const type comes the PROGMEM, when using Method 2 there are now 2 areas where you can store variables, Flash and SRAM so when do you want to use PROGMEM and when do you want to just leave it, when using method 2? Is there any performance hits when reading from Flash vs SRAM?

I understand that when using method 2 it is now scoped and typed, but are there any other advantages? Are the programs smaller using one vs the other? Are there times that you would want to use one over the other?


texts:
I have two different programs written for my Arduino. One checks the room temperature every 5 seconds. The other one looks for IR remote signals.

I would love to combine those 2 programs, yet the problem is the delay from the room temperature sketch.

If I would combine them. it means my IR script won't be working for a full 5 seconds (because of the delay of the room temperature script) then it will be able to receive a fraction of a second and then the temperature sketch goes again.

#include <IRremote.h>

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
int led = 12;
const int inPin = 0;

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

void loop() {
  int value = analogRead(inPin);
  float millivolts = (value / 1024.0 ) * 5000;
  float celsius = millivolts / 10;
  Serial.println(celsius, 1);
  delay(5000);
  if(irrecv.decode(&results)) {
    //this checks to see if a code has been received
    if(results.value == 0xFF6897) {
      //if the button press equals the hex value 0xC284
        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
  }
}

Does anyone know how to keep the IR part active and the temperature measure every 5 seconds, and do this simultaneously?

Or do I need another Arduino?


texts: May I use both USB-serial and tx/rx pins at the same time?

texts:
I am building a CNC machine based on GRBL code on a uno. I also have found a script to read data on a N64 controller. I know there is not enough pins available to do both codes running on the same arduino, so I was wondering if I could have my GRBL arduino connected to a computer thru USB, and at the same time, have a second arduino reading data from the n64 joystick, create Gcode accordingly, and feed that Gcode to the GRBL arduino through the tx/rx pins of each of them.
I guess I'll have to put a on-off switch on the tx/rx wife to avoid "noise" when I actually send Gcode to the GRBL arduino from the computer.

Does this all make sense?


texts:
Just, to make sure how it works:

I will connect the module to Arduino
it will create AP to which I can connect and send commands via HTTP

So I do not need any special equipment on PC side right, I can even connect to the ESP's AP with mobile, right?

Is it possible for the ESP to be WIFI client and connect to regular WIFI SSID (the PC will just communicate over regular network)?
Is it possible to communicate bidirectional somehow?


texts:
Ive been working with a motor project for a while and i bought this H-bridge(LMD18200). I dont understand how im supposed to connect it to the arduino.

Here is the datasheet for the lmd18200:


texts: Supply arduino through Vin pin with a battery

texts:
is it dangerous for arduino the below circuit because GND pin is common with -12V battery pole?
is it dangerous for lots of 5v circuit to be grounded on -12v battery pole?
in case i don't connect GND arduino pin with -12v , does arduino works?
in case that 1,2 question is dangerous for arduino,does it safe if a connect a diode at P1 mark?


texts: Arduino program only works when run as root

texts:
Uploading simple sketches seems to work when I run the Arduino program as root (sudo). I would like to run it as a regular user. Has anyone faced the same problem before and fixed it?

Here is what I obtained from lsusb:

$ lsusb
Bus 002 Device 022: ID 2341:0043 Arduino SA Uno R3 (CDC ACM)

And the Arduino program identifies it as /dev/ttyACM0. Here are its permissions:

$ ls -l /dev/ttyACM0
crw-rw---T 1 root dialout 166, 0 Mar 14 22:03 /dev/ttyACM0

Here is the output from id

groups=1000(abhiram),20(dialout),24(cdrom),25(floppy),29(audio),
30(dip),44(video),46(plugdev),105(scanner),110(bluetooth),112(netdev)

When I upload an sketch from the examples, as a regular user, I encounter this error:

avrdude:stk500_recv(): programmer not responding

Any suggestions are welcome.


texts:
I use an Arduino Uno for controlling one DC motor speed with PWM and one dimmer for control heater.
The dimmer and PWM control worked standalone, but when I want them to work together, the dimmer doesn't work.

#include  <TimerOne.h>          /
#include <Wire.h>

 //////////////                    //pin 2 zero kesmesi icin
int isiticiPWM = 9;                //  Opto Triac isitici PWM icin
int fanPWM=11;                     //motor pwm pini

int hiz=0;

volatile int i=0;               // Variable to use as a counter volatile as it is in an interrupt
volatile boolean zero_cross=0;  // Boolean to store a "switch" to tell us if we have crossed zero

char   data ;
int dim = 255;                    // Dimming level (0-128)  0 = on, 128 = 0ff
int inc=5;    // counting up or down, 1=up, -1=down
int freqStep = 75;    // This is the delay-per-brightness step in microseconds.

void zero_cross_detect() {
  zero_cross = true;               // set the boolean to true to tell our dimming function that a zero cross has occured
  i=0;
  digitalWrite(isiticiPWM, LOW);       // turn off TRIAC (and AC)
}

// Turn on the TRIAC at the appropriate time
void dim_check() {
  if(zero_cross == true) {
    if(i>=dim) {
      digitalWrite(isiticiPWM, HIGH); // turn on light
      i=0;  // reset time step counter
      zero_cross = false; //reset zero cross detection
    }
    else {
      i++; // increment time step counter
    }
  }
}
///////////////
void setup() {

  pinMode(fanPWM,OUTPUT);
  pinMode(isiticiPWM, OUTPUT);

    attachInterrupt(0, zero_cross_detect, RISING);    // Attach an Interupt to----------------------------------->  Pin 2 (interupt 0) for Zero Cross Detection <<------------------------------------------------
    Timer1.initialize(freqStep);                      // Initialize TimerOne library for the freq we need
    Timer1.attachInterrupt(dim_check, freqStep);

}

void loop()
{
hiz=450;analogWrite(fanPWM,hiz);

for(int k=0;k<=255;k++)
{dim=k;
}

  }


texts: How to control 2 servos at same time in sync?

texts:
For overcoming torque issues, I have attached 2 identical servos on a certain part of my robot arm and because I saw someone do the same.

Now, while writing code I realize:

#include <Servo.h>
...
...
shoulder1.write(map(analogRead(p1), 0, 1023, 0, 179));
shoulder2.write(map(analogRead(p1), 0, 1023, 0, 179));
...

will turn shoulder1 by 20* and then shoulder2 by another 20*, ie. an overall turn of 40*; that too with too much load on servos, as the other servo would be inactive at the time first is active.

I want to achieve 20* fully-sync.ed turn on both servos, how do I accomplish this? Any arduino libraries or walkthrough?

Can I possibly move them both at the same time - something like multithreading on arduino? Here's what I tried:

void rotateTwoServoInSync(int angle) {
    for(int i = 0; i<angle; i++) {
        shoulder1.attach(9);
        shoulder1.write(i);
        shoulder1.detach();
        shoulder2.attach(10);
        shoulder2.write(i);
        shoulder2.detach();
    }
}

Will it work? Is this approach recommendable?


texts: DHTNEW library not working with ATTiny85 + DHT11

texts:
I tried to make a simple project with Attiny85 chip and DHT11 sensor. After 2 days of struggle, made it finally work, but not quite as expected. TinyDHT library does work, while DHTNEW does not.
I wonder,

what can be changed to make any of the libraries work at lower clock rate?
how to make DHTNew work?

My results so far:
with TinyDHT:

@ 16 MHz works nominally, showing valid T/H values (if I breathe on the sensor, it shows 95-99% humidity)
@ 8 MHz, shows nothing (either nan, or zeros)
@ 1 MHz, shows temp/hum as 5, 5 (or 50, 50, can't tell)

with DHTNEW:

@ 16 MHz returns SENSOR_NOT_READY
@ 16 MHz with mySensor.setDisableIRQ(true); -> WAITING_FOR_READ at first, then nothing (nan or 0)
@ 8 MHz WAITING_FOR_READ at first, then TIMEOUT_C
@ 8 MHz with setDisableIRQ -> always TIMEOUT_C
@ 1 MHz always TIMEOUT_A

Here's the setup on photo and as a scheme. Arduino UNO works as a programmator for Attiny chip, as shown in this tutorial. After I upload the code to Attiny85, the chip starts working normally, and there's no need to disconnect the Arduino board. (For actual work, I disconnect it, connect 5V power, and it works the same way.)
Settings in the IDE:

Board: Attiny25/45/85
Processor: Attiny85
Clock: Internal from 1 to 16 MHz
Programmer: Arduino as ISP

How I test this:

change clock frequency
run Tools -> Burn bootloader
run Sketch -> Upload
wait till upload ends (RX/TX diodes stop blinking)
the LED on breadboard blinks me the numbers

Code for TinyDHT
Code for DHTNEW


texts: Multiple power supply for arduino controlled dc motor

texts:
I’m working on a project where I want to control a motorized fader with an arduino.  I have a dual H-Bridge board to control the motor, but the thing is that it is a 10V motor.  I’m thinking of using a secondary power supply on the H-Bridge to power the motor with a proper voltage.
So here is where my lack of electrical knowledge comes into play.  My H-Bridge has the following connections: a set of +/- poles to provide the power to the motors, 4 motor control pins (2 per motor to control their direction) and 4 motor power pins (2 per motor).

If I was using the Arduino as the power source for the DC motor, I would connect the +5v rail to the + terminal ot the H-Bridge and the Gnd rail to the - terminal, which would, in turn act as the ground return for the control pins.

If I am to use an external power supply, how do I wire it properly so I don’t blowup the arduino or the h-bridge?  I’m guessing that my secondary power supply will be connected to the +/- poles of the H-Bridge and the the - pole will also get connected to the Gnd rail of the arduino?

Is that correct?


texts: Controlling a capacitive touch screen that doesn't have I2C/SPI

texts:
I have been searching for cheap slim 3" 16:9 capacitive touch screens for a while now. But I couldn't find any that had an I2C or SPI interface. The cheap displays always have these ribbon cables with a ton or pins and it's really hard to find a way to control them from an Arduino (or ESP-32 or ESP-8266).

I recently found this one, but how do you access such a touch screen that doesn't have an I2C or SPI interface?
Do I need some sort of driver board? What exactly would I be look for?


texts: Using more than one Ping Ultrasonic Range Finder

texts:
I have done various applications with the Ultrasonic example project but it is always using one pinger. I'd like to make a scanner resting on a servo sweep but to reduce sweep time use more than one censor.

the documentation is rather basic ping sonic that states the signal 40khz is used.

Down to the question now. Is there a means to tell one pinger to use 40Khz and another say  45Khz.

This would allow me to scan two areas (different directions) per cycle, reducing the time frame to complete area scan by half.


texts:
I am working on a project, where i need to control the flow of a liquid made from food.

For example: making chicken curry, I will separate all the liquid from the meat, and run that tough a pipe, where this control pipe is on.

But I have been unable to find a subtle valve for this, as the liquid on all of them will flow tough the mechanics of the valve, and this would not be optimal as it would make it impossible to clean, and it would diffidently get stuck.

Can one of you suggest a valve that would work for this case?


texts:
I would like to ask you some helpful informations.

Recently I bought an OV7670 Camera Module.
Unfortunately, this item is not compatible with any tutorial I found in dozens and dozens of sites.

It has 18 pins with these signs:

3.3v   GND
SCL    SDA
VS     HS
PCLK   MCLK
D7     D6
D5     D4
D3     D2
D1     D0
RESET  PWDN

I aint noticed these pins on any OV7670 Camera in any site of tutorial, like youtube or arduino.cc or many others at google searching.
The most comon OV7670 Cameras I found in tutorials have SIOC SIOD instead of SCL SDA, HREF instead of HS and XCLK instead of MCLK.
Did I bought a fake or what do you think?
Please, if any of you, knows how to make it conect or have any useful link, I will apreciate to inform me.
Thank you all for your time.


texts: handling array from post data on espwebserver

texts:
I think I have a supplement question. If irrelevant , then sorry in advance.

I have nested array in post like:  from apache web server page index.php

$_POST['colorsarray'][0] = '#ff0000';
$_POST['colorsarray'][1] = '#2d67ea';
$_POST['colorsarray'][3] = '#7cf325';
$_POST['mode'] = 'none';
$_POST['singlecolour'] = '#ff0000';

Can you suggest me how to assign this array (coloursarray) directly to another array in espwebserver. In other use cases , only the list (length) of array will increase and is not know until the variable arrives from client.

Thanks in advance.


texts: I'm trying to make an opening and closing little door that should open or close every 12 hours. I was wondering if I could just make a small looping script with a delay() for 12 hours, delay(43 200 000 000); I guess? However, I have no idea if that's possible and/or recommendable. Some feedback/alternatives(if needed) would be nice :)


texts: Passing arguments to LCD.print through another function

texts:
I'd like to write a function like this:

void lcdPositionPrint(int row, int col,  content) {
    lcdPosition(row, col);
    LCD.print(content);
}

but I'm not certain how to declare "content", because it might be a string, or an int, or who knows what, just as it is for the "Serial.print" function or the LCD.print() function. Is there an easy way to do this?


texts:
I am trying to use both an SRAM (23LC1024) and SD card reader on an SPI bus.

My connections (for SPI):

Arduino pin 11 (MOSI) -> SRAM pin 5 (SI/SIO0)
Arduino pin 12 (MISO) -> SRAM pin 2 (SO/SIO1)
Arduino pin 13 (SCK ) -> SRAM pin 6 (SCK)
Arduino pin 10        -> SRAM pin 1 (CS )

In this way, I can read data from the SRAM.

To connect the SD I connected:

SRAM pin 2 (SO/SIO1) -> SD MISO
SRAM pin 5 (SI/SIO0) -> SD MOSI
SRAM pin 6 (SCK    ) -> SD SCK
Arduino pin 9        -> SD CS

Currently the SD card works, but read-byte commands to the SRAM always gives the same (wrong) value.

If I remove the wire between SRAM pin 2 and SD MISO the SRAM gives correct values, but the SD card does not have a MISO connection and seems to always return the same data (but still functions).

I also tried to first make the connections from the Arduino to the SD and than to the SRAM (but same result, not working).

What am I doing wrong?

Update: The problem is solved, however I do not understand why. I reconnected all pins, removed the shield to access the SRAM directly which worked. Than I put the shield back on (and moving the pins back) ... maybe it was something stupid that one pin did not have good contact. I'm sorry for the inconvenience.

New question (related):

Now it works with the Data logger shield, but not with the (cheap) SD reader breakout cards.

However, my eventual solution needs more proto space than is available on the Data logger shield.... do I really need to use a complete shield (and later the Arduino Mega), and a Mega proto shield ... that will be a big box.
While for the data logger, I don't need the RTC neither.


texts: Transmit datastring using SIM7600 4G hat

texts:
I've been using Adafruit Fona with SIM800 chip to transmit data through the phoneline. SIM800 is a 2G chip but this network is closed in Norway so now I bought a Waveshare SIM7600 hat for Arduino instead. When using Fona I set up the call with this command: "ATDphonenumber" and when the connection was established I got this message: "CONNECT 9600". Then Fona went into data mode and I could send and receive datastrings before returning to command mode using +++. On the SIM7600 I need to write the call-command this way: "ATDphonenumber;" and the respond is "BEGIN: VOICE CALL" when connection is established. The problem is I can't get into datamode. The manual says use this AT command: "ATO" but that gives me "NO CARRIER" in return.
Now I wonder how I can make a call to another device and be able to send datastrings just like using Fona.


texts: Diffrence between running once and infinite

texts:
const int ledPin = 12;

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

void loop(){
    if (Serial.available()) {
        light(Serial.read() – '0');
    }
    delay(500);
}

void light(int n){
    for (int i = 0; i < n; i++) {
        digitalWrite(ledPin, HIGH);
        delay(100);
        digitalWrite(ledPin, LOW);
        delay(100);
    }
}

by Oscar Liang

awesome little piece of code which taught me how to setup connection by serial. yet one part I don't understand fully. Why does this line:

  light(Serial.read() – '0');

make the code run once,
and this line an infinite times.

  light(Serial.read());

has this something to do with binary? I don't get why subtracting the string 0 would run the code once.

Thanks in Advance!


texts: Servo MG996R - what is the maximum load for very long time?

texts:
I am working on a device which will have to periodically switch positions and keep the position for very long time, as accurate as possible, under tension.

Never worked with servo motors before, but I found MG996R interesting. It has a stall torque of approx 12kg*cm (@6V).

My question is:

To what maximum safe continuous load I could subject the motor if I need to keep it in position for 24h+ (it may switch position occasionally, but worst scenario would be like 24h-48h continuous locking in same position) ?


texts: Transistor slows motor instead of turning it off

texts:
I'm new to electrical engineering and I am currently trying to make a motor turn on for one second, turn off for one second, and repeat.

I'm using an Arduino Uno's digitalWrite() feature to activate a transistor, allowing the external 9V battery to turn on the motor.

Although everything is responding, instead of the motor turning on and off like I want it to, it spins fast for a second, then spins slower for a second. I would like the motor to stop completely, but cannot figure out how to do that.

Here's the schematic of my circuit:

simulate this circuit – Schematic created using CircuitLab

Code:

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

void loop(){
  digitalWrite(9, HIGH);
  delay(1000);
  digitalWrite(9, LOW);
  delay(1000);
}

Why isn't the motor completely turning off?


texts: How do I statements for the various conditions of this function?

texts:
I am still new to Aduino and I am trying to use a library's example sketch but I don't understand the following part of the code. I want to trigger an led when the "Pressed" condition is fulfilled. Pardon my ignorance.

if (b != ClickEncoder::Open) {
Serial.print("Button: ");
#define VERBOSECASE(label) case label: Serial.println(#label); break;
switch (b) {
  VERBOSECASE(ClickEncoder::Pressed);
  VERBOSECASE(ClickEncoder::Held)
  VERBOSECASE(ClickEncoder::Released)
  VERBOSECASE(ClickEncoder::Clicked)

  case ClickEncoder::DoubleClicked:
      Serial.println("ClickEncoder::DoubleClicked");
      encoder->setAccelerationEnabled(!encoder->getAccelerationEnabled());
      Serial.print("  Acceleration is ");
      Serial.println((encoder->getAccelerationEnabled()) ? "enabled" : "disabled");
      setMode = true;
       value = 0;
    break;
}

}


texts:
I want to create a structure like this:

 struct commands
{
  int   cmd;
  char  descr[25];
};

commands cmds[] =
{
  {16, "Hammond Organ"},
  {17, "Percussive Organ"},
  {18, "Rock Organ"},
  { 0, "" }                   // end of list marker
};

The compiler doesn't protest, but in a simulator the values of cmds[i].descr are all zeros.

And the line

Serial.write(cmds[1].descr);

prints nothing.

Please recommend how to rewrite the code.

Thanks.

EDIT

Thanks for your answer. It helped me a lot.

There is something wrong with the simulator (Simulator for Arduino - version 1.11E Designed by Virtronics). In the meantime I received the Mega 2560 board and the code works well with the board.


texts: Determine whether a variable is of an arithmetic type

texts:
Is there a way to determine whether a variable is of an arithmetic type or not?

arithmetic: integer, floating point numbers, boolean values
not arithmetic: pointers, references; e.g. strings, and probably all other implementation- and user-defined types. However if someone for some reason defines typedef int myInt myInt should be considered arithmetic as well (because it is!)

In a normal C++ program I could use std::is_arithmetic<T>::value, where T is the type I need to check, but this doesn't seem to work in the Arduino environment. (Am I wrong? If it works, could someone please tell me how to use it?)

I imagine I could make a list of allowed types, e.g. as described in this answer to a similar question (I'm referring to the second option, the Alternative). But given that I don't need to exactly know the type of T I was wondering whether there is a more elegant and flexible solution...


texts:
I would like to know if it's possible to power up arduino by VIN pin (say 9v) and use 5v output pin to connect to a sensor.

Many thanks


texts: Is it safe to power an MQ-7 gas sensor with a 9V D.C supply?

texts: I'm looking for a portable power source for an MQ-7 gas sensor. According to my research - it needs 5V D.C power with at least 0.3A of current. I'm not really good with electronics so I need to know if I can use a 9V battery instead which produces 0.5A. Will the cell damage my sensor and if it does may you please recommend me something else.


texts:
I am a high school student and I need to build a remote controlled car for a  school project and I have to use arduino. I am fairly new to arduino, but I understand the basics. Also I'm kind of desperate so please read until the end.

The part I am using is the NRF24L01 transceiver and to learn how it works, I copied a bare-minimum code from https://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-ExampleSketches#bm1. When I started the code, the "RF24/Simple Transmit data Test" and "Questions: terry@yourduino.com" showed up as black diamonds with question marks inside in both the Transmitter and Receiver serial monitors.

The transmitter kept showing these question marks with random letters through out the entire code.

The receiver showed (like it was supposed to) "Data received = ", but the number it equaled was not correct. Here is a picture

I looked at the code for a difference between the part that worked and the parts that didn't and found that the Serial.print (F())'s didn't work and the Serial.print() did. I don't know what the F does except that it send flash data and I don't know what that means. I got rid of all the F's and transmitters Serial monitor looks perfect, but the Receiver only shows that beginning text and doesn't receive and numbers. I put a Serial.print in the if to see if it gets in, but it doesn't.

I've had this problem for a couple of days and need to get it fixed otherwise I can't finish the rest of the car! I need to bring it to class on Monday.


texts: Cannot open file with underscores using the SD library

texts:
So I'm trying to create a new file that has underscores in its name. However, when I try this, no file is created.

This works

String fileName = "NMEA.txt";
mySensorData = SD.open(fileName.c_str(), FILE_WRITE);

This does not work

String fileName = "NMEA__23_33_3__16_7_29.txt";
mySensorData = SD.open(fileName.c_str(), FILE_WRITE);

Does anyone know why?


texts: DS18B20 - Thermometer and Sensor discrepancy (varying)

texts:
This is a follow-up question from this other question

I followed of the user Jot (get the sensor away from the sun and use a delay in arduino program)

But the results are still varying.

I recorded the temperature measured in the sensor, the temperature measured using a mercury thermometer and calculated the difference. The data was collected within 8 days

Here's the data (sorted):

SENSOR  THERM   DIFF
32.69   31.25   1.44
32.00   30.25   1.75
31.94   30.50   1.44
31.87   30.50   1.37
31.44   29.50   1.94
31.00   29.00   2.00
30.75   29.00   1.75
30.50   29.00   1.50
30.44   28.80   1.64
30.31   28.90   1.41
30.25   28.75   1.50
29.87   28.00   1.87
29.81   28.00   1.81
29.81   28.00   1.81
29.81   28.25   1.56
29.75   28.20   1.55
29.69   28.00   1.69
29.56   27.00   2.56
28.75   27.25   1.50
28.69   27.00   1.69
28.56   27.00   1.56
28.44   27.00   1.44
28.25   26.80   1.45
28.00   26.50   1.50
28.00   25.50   2.50
28.00   25.00   3.00
27.75   25.50   2.25

The average difference is around +1.76°C but that's not linear, and as you can see there are fluctuation in the same sensor value, 28.00 has three associated temperatures(25.0, 25.5, 26.5).

I'm not sure what to do, if the difference was regular I could simply subtract that from the sensor readings, but it seems that it varies a lot(Min: 1.37°C, Max: 3.00°C)

Any ideas?


texts: How to set Inquire Access Code (IAC) via AT commands on HC-05?

texts:
I am trying to set IAC of HC05 via AT Commands, but for some reason, the result is not as desired.

I need to set the IAC as '1234', for which I enter the command:

AT+IAC=1234

The module responds OK, but when I ask AT+IAC?, it replies '01234'.

Now, it has been troubling me for the past few days. I've also tried adding '\r\n' to the end of command, but it sets the IAC as '1234444'

I would be thankful if you could help me with this! I tried searching the net but to no avail.


texts: Radio receiver: deep sleep when no byte arrives, and wake up when a byte arrives?

texts:
This code works to listen for bytes via radio (with a 433 Mhz receiver module) with the Manchester library and Manchester code, and do an action when certain bytes are received:

#include "Manchester.h"

void setup() {
  pinMode(3, INPUT);
  man.setupReceive(3, MAN_1200);
  man.beginReceive();
}

void loop() {
  if (man.receiveComplete()) {
    uint16_t m = man.getMessage();
    man.beginReceive();   // start listening for next message
    // do something with m
  }
}

But it requires to have the Arduino / ATtiny / ATmega / MCU constantly running.

Question: is there a way to put the ATtiny on deep sleep mode (to get < 1 uA consumption) and wake-up only when a byte arrives via radio?

I know how to do this with an interrupt or "pin change interrupt", but here with radio library Manchester, it's probably more complicated. How to do it?

In this case it's probably going to be more complicated than just:

sleep_enable();
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_cpu();


texts:
I want to make a USB gamepad, and I've heard that an Arduino would be great for this kind of project. But before I start to work on it, I want to make sure I understand some things. Here are my basic diagrams of what the project will look like during prototyping and after prototyping:

Do the diagrams look right? Am I understanding the process correctly? For me to properly build a final circuit, I would have to emulate all the necessary (the most important one being the USB) circuitry that an Arduino has around it's microprocessor.

And my final question is, how would I load my program on to the microprocessor (with and without the "Arduino-like" USB circuitry)?


texts: How do I update the serial monitor without printing a new line each time?

texts:
I'm testing out an accelerometer and I want to know if there's a way to make it so that the serial monitor will update the values without printing a new line. Ideally the serial monitor would say something like:

Accelerometer X: $xval
Accelerometer y: $yval

and then instead of printing two new lines each time, it just updates the values. Is there anyway to do that in Arduino? Thanks.


texts: NodeMCU ESP8266 on Arduino IDE doesn't detect Wifi

texts:
I am using a NodeMCU 1.0 v3 and I am trying the example sketch (wifiscan) but it just doesn't pick up any AP in the house. My phone and laptops etc are able to pick up the APs though.

Other sketches upload and work fine but the wifi aspect of it doesn't work. I even got an LCD sketch to work properly but it isn't able to find any access points or even join any access points. I have been trying to get it to work for hours now.

I first tried using the latest Arduino IDE (1.6.12), then I uninstalled and tried using 1.6.1 but no luck. My upload settings are NodeMCU 1.0 (ESP-12E module), 80Mhz, 115200, 4M (3M SPIFFS).


texts: Arduino Mega 2650 + Matlab/Simulink - Serial decimation

texts:
I am performing a control analysis on an Arduino board.
As such, I want to minimize the board cycle duration.
(Faster board = faster controller).

Introduction:

I use Mathworks Matlab/Simulink to program the board.
I created a model in Simulink,
and embedded this model into my Arduino Mega 2650.

The model includes an Arduino Serial Transmit block.
I am therefore able to use Matlab software on my PC to request
serial transmission from the Arduino board to Matlab.

The Arduino Mega 2650 has the following serial constraints:

Maximum output buffer: 64 [byte]
Maximum baud frequency: ~115,000 [bit/s]

Problem:

To perform my control analysis,
I want to minimize the board cycle duration, and
I want to read several signals simultaneously.

The time it takes to read all signals sent
(as dictated by the baud rate)
is the primary obstacle in reducing my board cycle duration.

Requested Information:

Is it possible to reduce the board cycle duration
without reducing the duration in which
the serial transmission must be completed.

For example,
what if I run my board at 0.001 [s],
but I can only send all of my signals in 0.010 [s],
what will happen during my reads?

If I read every 0.001 [s], obviously I will not receive all of the data,
as this is not feasible in the time that I am allotting.
My concern is regarding what will happen if I read every 0.010 [s]:

Will the passing of several board cycles before the read completes affect the read?
Is there a method to lock the serial output buffer while reading
(such that the data does not change midread)?
How long does it typically take to refill the serial output buffer with the next set of data?

Conclusion:

Ultimately, I would like to run the board as fast as possible,
since I believe that this could significantly improve my controller's performance,
despite not being able to read these additional cycles.


texts: Linking Arduino Nano with ESP8266 Wifi module

texts:
I recently started playing around with Arduinos to connect a few sensors up. I used an Arduino Nano to measure temperature, humidity, air pressure and light level.

To store the data in a database, I used another Arduino that I connected to a Raspberry Pi, and let the two Arduinos talk wirelessly to each other via 433 MHz.

That all works pretty well, but the 433 MHz communication is not exactly the most reliable (I often miss a transmission). When I stumbled upon the ESP8266 module, it seemed like the optimal solution for communication. How cool would it be if I could just pull out the information via an HTTP call from the Raspberry Pi?

After toying around for many hours, uploading many different firmwares, getting more and more frustrated because I could not get it to do anything, I finally have it working through an FTDI module connected up like this:

I use an MB102 power module to provide the 3.3v required by the ESP8266. I turns out you need to connect the ground from the MB102 to the ground of the FTDI module to get any proper response. After doing that I was able to send AT commands and get the proper responses. I could even connect it to my home Wifi.

The next thing I want to do is connect it to the Arduino. I found a very simple schema for that (http://blog.huntgang.com/2015/01/20/arduino-esp8266-tutorial-web-server-monitor-example/), where you connect RX to TX and TX to RX. Using the MB102 I connected it like this:

Apparently I should now be able to upload a blank sketch to the Arduino, and then use the serial monitor again to sens AT command, exactly the same way I did it when using the FTDI module.

The problem is that I get nothing at all this way. I don't even see my own AT commands in the console. I do see the ESP8266 flashing every time I send a command (I even see it it still connected to my router, probably it remembered the info I send through the FTDI...?)

The question is, what am I going wrong? I read some posts about the TX from the Arduino also being 5v and that you need to do something to bring it back to 3.3v, but there are also many tutorials that say it's not required.


texts: Interrupts aren't working unless Serial.flush() is called first. Why?

texts:
I have a robot that has encoders attached to the motors, and I use interrupts to detect pin changes and count the number of pulses (ticks) from the encoder. I have the robot run the motors until a certain number of pulses is counted. However, I was having issues with the robot never stopping (I assume, based on various tests, that it is because the interrupts were not working to count the pulses). When I was trying to debug, I added Serial.print() statements, and it suddenly worked. I tried Serial.println() and Serial.flush(), and these all caused the code to work. I cannot figure out why this is. While the code works, it's really been bugging me. Please help.
Some other notes:

This problem only arises when dir != forward, which honestly confuses me even more)
All the stuff with distance, precision, etc. is just to convert the units. Since I send single bytes over the Serial, I equate the byte value to a certain number of centimeters (or degrees if turning) to allow for a larger range of values
updateDir() and respondToCurrDir() essentially just set the motor pins to HIGH or LOW to change directions (forward, left, or right)

int go_distance(byte unitDistance, Directions dir) {
  byte distance = (dir == forward) ? unitDistance * precision : unitDistance * units2deg;
  bool obstacle = false;
  unsigned int tick_target = (dir == forward) ? distance * cm2ticks : distance * deg2ticks;
  // Turn on the interrupt to detect encoder ticks
  attachInterrupt(digitalPinToInterrupt(LeftEncoder_pin), tickLeft, CHANGE);
  distanceTicks = 0;
  updateDir(dir);
  respondToCurrDir();

  while (distanceTicks < tick_target) {
    Serial.flush();
    // Keeps going forward until distance is reached or ultrasonic sensor detects obstacle
    if (dir == forward && isDanger()) {
      obstacle = true;
      break;
    }

    // break if the distanceTicks stops updating (this means something is wrong)
  }

  updateDir(halt);
  respondToCurrDir();
...


texts: Using a MOSFET module to control DC LED PWM

texts:
I've seen some similar questions here for using MOSFET to control 12V LEDs
But apparently the only MOSFET currently available to us is a 2-MOSFET high power trigger module, details in the link below.

https://www.elecrow.com/high-power-mosfet-trigger-switch-drive-module.html

How do we connect this to the Arduino to send the PWM trigger (I get confused by the three holes) and how do we connect the DC power to this??? I get confused with the power connections.


texts: Getting garbage values on serial communication between Arduino Uno and ESP8266 NodeMCU

texts:
I have created a weather station on ESP8266 NodeMCU which has a web interface with logs. I've connected DHT22 on ESP8266 NodeMCU and a BMP180 on an Arduino Uno. Arduino Uno sends pressure to the ESP8266 NodeMCU via serial communication and ESP8266 logs all data it has received from Arduino Uno. The problem is that when I access the logs sometimes I get good output such as 1022.23 hPa, but sometimes the browser asks me to download the logs  and when i open it I get garbage output like LLÉ‚Ň˘˘rš‚Ň’ŞŇŠĘŇŠŠrŞÂŇŠ‚’šr’˘ţ. This is the code of serial communication:
#include <SoftwareSerial.h>
#include <ESP8266WebServer.h>

ESP8266WebServer server(80);
SoftwareSerial s(D6, D5);

String logs = "";

void logFunc(String logstring) {
  logs += logstring + "\n";
}

void setup() {
s.begin(9600);
server.on("/logs", handleLogs);
}

void loop(){
if (s.available() > 0)
  {
    serial = s.readString();
    logFunc(serial); //function for logging
  }
}
void handleLogs() {
  server.send(200, "text/plain", logs);
}

What could be the cause and how can I fix it?


texts: How does an OLED screen module control the pixels?

texts:
I'm not asking that how does an Arduino send the data to the OLED screen, but how does the module control the actual screen that displays the image ? I couldn't find any IC on the module, just a few capacitors and resistors on the back. The chip that "understands" the signals sent by the Arduino and controls the pixels is under or in the screen, or where is it ?
Yes, I've looked up on Google, but I couldn't find any answer.