texts: Weird effect of AVR C on USB-serial communication

texts:
I recently decided to learn direct port manipulation instead of builtin arduino routines.
First I tried this piece of code
void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
Serial.println("on");
delay(500);
digitalWrite(LED_BUILTIN, LOW);
Serial.println("off");
delay(500);
}

This program on running instantly established connection with the serial monitor on my arduino IDE.
But when I try this code
int main(void)
{
Serial.begin(9600);
DDRB = B11111111;
while(1)
{
PORTB = PORTB | 0x20;
Serial.println("off");
_delay_ms(500);
PORTB = PORTB & 0xDF;
Serial.println("on");
_delay_ms(500);
}
}

But this program is taking some time, about 5-10 seconds to establish serial connection. Also delay() is not working too. When I use delay() instead of _delay_ms(), the entire arduino board freezes like a computer and stops blinking the LED instead LED is fully ON.
I tried is on several programs, while "setup-loop" program connects instantly, AVR C programs does not.
why does it happen?


texts: Serial communication between PC and Arduino via RS232 using C++

texts:
I am trying to communicate with my Arduino Duemilanove via an RS232 cord. I simply want to be able to send a byte (or char) to my Arduino from a desktop application.  The Arduino is plugging into USB COM5 on my computer.  I have the RS232 plugged into COM1, and then I have pins 2, 3 and 5 on the other end of the RS232 connected to Arduino pins TX, RX, and GND, respectively.

I found a serial comm class for C++ at the following link: Arduino and C++ (for Windows)

I have added the .h and .cpp files from the above example as Serial.h and Serial.cpp (I think the example uses SerialClass.h and SerialClass.cpp, I just changes the names).

On my Arduino, I have the following code running:

// ARDUINO
char incomingByte = 0;

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

void loop() {

        // send data only when you receive data:
        if (Serial.available() > 0) {
                // read the incoming byte:
                incomingByte = Serial.read();

                // say what you got:
                Serial.print("I received: ");
                Serial.println(incomingByte, HEX);
        }
}

And my C++ program is the following:

// C++
#include <iostream>
#include <Windows.h>
#include "Serial.h"

using namespace std;

int main(void)
{
    Serial port("COM1");

    char* msg = "Hello Arduino!";
    int msgLen = strlen(msg);
    bool writeSuccess = port.WriteData(msg, msgLen);

    cout << "\n\n";
    system("PAUSE");
}

When I use the Arduino's serial port viewer to see what is bring printed, I'm getting very strange values that don't match what I'm sending (as far as I can tell).

When I send "Hello Arduino!", the arduino prints the following:

I received: FFFFFFAB
I received: 3A
I received: 3A
I received: A
I received: FFFFFFFA
I received: FFFFFFEB
I received: 6D
I received: 37
I received: 15
I received: 2D
I received: 23
I received: 21
I received: FFFFFFBD
I received: 0

This does not appear to be the correct hex for "Hello Arduino!", but I have no idea why it's not correct.  Does anyone have any clue what I'm doing wrong?


texts: Is Arduino Ethernet shield compatible with arduino due?

texts: Arduino Due's operating voltage is 3.3 volt and Ethernet shield operates on 5 volt supply. So my question is that this Ethernet shield will work on an Arduino Due and also if it will not harm the Arduino Due board due exceeding the operating voltage?


texts: Help using an Arduino as as an FTDI with a ESP8266 carrier shield to see an AT response

texts:
I have a Duinopeak shield that lets you plug on an ESP-01 and provides a 5V-3.3V regulator and level shifting for the Tx and Rx pins. I cannot get it to work with a setup that has worked with every ESP-01 or Wifi Shield I have used before.
Between the Arduino and the shield I connect Tx/Tx and Rx/Rx. I either load a blank sketch or jumper RST to ground on the Arduino. I use pins 0 and 1 through the shield. When I plug in the USB cable and type AT and "send". Nothing. No light blinks on the ESP sitting on the board. This is the board:
https://alexnld.com/product/duinopeak-esp8266-esp-01-wifi-expansion-board-shield-without-esp8266-module-for-arduino/
I know the ESP and the board works, because if I connect it to a Mega and use Seria1 instead of the main serial(0), rewire Tx/Rx and Rx/Tx, and upload a sketch to echo the USB Serial to Serial1 and back, using Serial Monitor, I can send AT commands and see responses. But when connected to pins 0 and 1, it acts like it isn't connected.
What I have tried:

Tried an Uno and Mega
Tried removing the plastic jumpers and running wires from the rows of Rx and Tx pins to the header directly
Tried different pins on the row (there are 8 Tx pins and 8 Rx pins so you can jumper to D0-D7)
Tested the continuity of each pin with a meter

I thought it must be the level shifter, but then why would it work when using Serial1? I thought the pins might have a cold solder joint, but then I used jumper wires from the pins in both tests and the same pins work (in reverse) when I connect them to Serial1 on the Mega. I thought it might be because of the 2 resistors on the USB path to pins 0 and 1 on an Arduino, but they prefer the pins over the USB. And why would another very similar board work? Tracing and finding an identical looking board shows this schematic. Odd thing is this is identical to a different board that works
:


texts:
I am using OpenWrt in Arduino Yun.
I want to save some sensors data into MySQL Server which is installed in OpenWrt localhost.

But it gives an error when I try to login MySQL after reboot the system.

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld.sock' (2)

if i reinstall it start working but this error came after each reboot.

opkg update
opkg install mysql-server

sed -i 's,^datadir.*,datadir         = "/srv/mysql",g' /etc/my.cnf
sed -i 's,^tmpdir.*,tmpdir          = "/tmp",g' /etc/my.cnf

mkdir -p /srv/mysql
mysql_install_db --force
/etc/init.d/mysqld start
/etc/init.d/mysqld enable

please help me to resolve this issue so MySQL works every time after reboot also.


texts:
i am using Arduino Mega.. ANd this is the code:

void bump(void);

void setup()
{
    pinMode(19,INPUT);
    attachInterrupt(4,bump,HIGH);
    pinMode(13,OUTPUT);
}

void loop()
{

}

void bump()
{
   for(float i = 0; i < 90000; i++){
   digitalWrite(13,HIGH);
   }
   for(float i = 0; i < 10000; i++){
   digitalWrite(13,LOW);
   }

}

Although i give +5 V to it once, the LED will blink twice...!
What is the solution?


texts: Can the ESP-1 use SPI to communicate with sensors?

texts:
I wonder if I can use SPI to communicate between ESP-1  ESP8266 module and SPI sensors and other slaves.

If so, do I need to install a library?


texts:
I am working on ws2815 led strip with the esp8266 on arduino 1.6.6 fast led library.Using CD40109B level shifter to convert 3.3V of esp output to 12V .It's working fine upto 31 leds according to the program pattern if i increase the led count it's giving random pattern .What can be the issue.
This is the code that i am using

#include <FastLED.h>
#define LED_PIN     5
#define NUM_LEDS    50

CRGB leds[NUM_LEDS];

void setup() {
  FastLED.addLeds<WS2813, LED_PIN, GRB>(leds, NUM_LEDS);
}

void loop() {
  for (int i = 0; i <=NUM_LEDS ; i++) {
    leds[i] = CRGB (255,0 , 0);
    FastLED.show();
    delay(40);
  }
  for (int i = NUM_LEDS; i >= 0; i--) {
    leds[i] = CRGB ( 0, 255, 0);
    FastLED.show();
    delay(40);
  }
}

EDIT
We checked in oscilloscope and we observed that after internal signal reshaping of the ws2815 IC ,the RGB values are not as intended.This is also seen on the led strip with changing colour of the leds.
We are trying to generate a single colour on the strip so this colour changing is quite clear.

The current rating of the power supply I am using is 12.5A, which is enough to drive the LEDs, and the voltage is also 12V at the 32nd LED.


texts: How do I control a conveyor to start and stop in same location using optical rotary encoder

texts:
I am a complete novice at arduino. I just want to know if this is possible before I start investing in components. I need to start and stop a chain drive conveyor {can't slip} powered by a 12 volt motor in the exact same place each time I manually start the cycle. I want it to stop automatically. The controller would have to power a relay to power the motor due to high amp draw of motor. This is on a piece of equipment without access to any other power supply but a 12 volt battery. I am looking at an optical rotary encoder to count the revolutions of the shaft. I would count the revolutions the shaft makes between my start and stop point and I assume enter that in the program. Is this possible?
Thanks


texts: Communication between Arduino and Can Bus

texts:
Function mcp2515_get_message appears the following instruction:

 uint32_t i1 = (uint32_t) spi_putc(0xff),
          i2 = (uint32_t) spi_putc(0xff),
          i3 = (uint32_t) spi_putc(0xff),
          i4 = (uint32_t) spi_putc(0xff);

This instruction is used to fetch data used for determining the message id. Supposing the 32 bit source data contains
Hex 0xAA3A6060, which values will appear in i1, i2, i3, i4?

Any help will be much appreciated.


texts: Trying to run two simultaneous loops that do the same task with different delay cycles

texts:
I'm trying to control a pellet stove auger motor in such a way that I can use a toggle switch to do High/Low (H/L) - so the way that I have it now is:

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

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

Which is just LED on/off but it also controls another relay that controls the blower motor - what I'm trying to set up is a H setting that would be the 2850 delay-ON - and then have say: pin 11 have a delay-OFF of 7000, and have pin 13 still resetting to the delay-ON of 2850.

What I mean is:

loop A: pin12 on -delay 2850 pin12 off -delay 11250
loop B: pin13 on -delay 2850 pin13 off -delay 7000

I saw and tried the code for 'multi-blink' - as the one I use is pretty much modified 'blink'.

Any assistance would be awesome - I run the one I show above now, on my pellet stove and it was recently -31.4 and worked like a charm, but I'd like to be able to have a high/low option.

PS: I also have a coffee roaster control project as well... help on that one is always appreciated as well.


texts:
I would like to establish a communication between my C# program and my Arduino Duemilanove. I tried lot of different tutorials, but none of them were the same, and I'm a little bit confused.

Actually my code is:

C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace InterfaceArduinoWindowsFOrm {
  public partial class Form1 : Form {
    public Form1() {
      InitializeComponent();
      serialPort1.PortName = "COM3";
      serialPort1.BaudRate = 9600;
      serialPort1.Open();
    }

    private void pictureBox1_Click(object sender, EventArgs e) {
    }

    private void tabPage2_Click(object sender, EventArgs e) {
    }

    private void listBox1_SelectedIndexChanged(object sender, EventArgs e) {
    }

    private void toolTip1_Popup(object sender, PopupEventArgs e) {
    }

    private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) {
      Console.WriteLine("test");
    }

    private void button1_Click_1(object sender, EventArgs e) {
      serialPort1.Write("5");
      Console.WriteLine(serialPort1.IsOpen);
    }
  }
}

Arduino:

/* Sweep
  by BARRAGAN <http://barraganstudio.com>
  This example code is in the public domain.
  modified 8 Nov 2013
  by Scott Fitzgerald
  http://arduino.cc/en/Tutorial/Sweep
*/

#include <Servo.h>

Servo myservo;  // Create servo object to control a servo.
// Twelve servo objects can be created on most boards.
int pos = 0;
int message = 0; // This will hold one byte of the serial message
                 // variable to store the servo position.

void setup() {
  Serial.begin(9600);
  myservo.attach(9);  // Attaches the servo on pin 9 to the servo object
}

void loop() {
  if (Serial.available()) {

    // Check to see if there is a new message
    message = Serial.read();

    // Put the serial input into the message
    Serial.print(message);

    if (message == '5') {
      Serial.print("test");
      for(pos = 0; pos <= 180; pos += 1) {
        // Goes from 0 degrees to 180 degrees
        // in steps of 1 degree

        myservo.write(pos);
        // Tell servo to go to position in variable 'pos'

        delay(15);
        // Waits 15 ms for the servo to reach the position
      }

      for(pos = 180; pos>=0; pos-=1) {
        // Goes from 180 degrees to 0 degrees

        myservo.write(pos);
        // Tell servo to go to position in variable 'pos'

        delay(15);
        // Waits 15 ms for the servo to reach the position
      }
    }
  }
}

The problem is, when I click my button, nothing happens, but obviously if I remove the if statement, the servo motor code works.


texts: Point-to-point Communication of Arduinos with RFM LoRa Shield

texts:
In this tutorial, it sends a string from a node to the other node. But if I want to send an integer instead of a string, how should I change the code?

Serial.println("Sending to rf95_server");
// Send a message to rf95_server

String radiopacket = "Hello World #";
radiopacket += String(packetnum++);
radiopacket += " from ";
radiopacket += node_id;

Serial.print("Sending "); Serial.println(radiopacket); delay(10);
rf95.send((uint8_t*)radiopacket.c_str(), radiopacket.length()+1);

Serial.println("Waiting for packet to complete..."); delay(10);
rf95.waitPacketSent();


texts: Getting FFT arduino code to run over 9+ hours, utilizing micros()

texts:
I am a beginner in Arduino, coding, and electrical engineering (learning on my own time) and am working on creating an EEG. I've got the hardware down and have managed to get numerical data output from the analog (A0) of Arduino. The next step is transforming these numbers to outputting dominant frequency and I have managed to find a code that uses FFT to find the dominant frequency from the input of A0. The following is the code:

#include "arduinoFFT.h"

#define SAMPLES 128             //Must be a power of 2
#define SAMPLING_FREQUENCY 1000 //Hz, must be less than 10000 due to ADC

arduinoFFT FFT = arduinoFFT();

unsigned int sampling_period_us;
unsigned long microseconds;

double vReal[SAMPLES];
double vImag[SAMPLES];

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

sampling_period_us = round(1000000*(1.0/SAMPLING_FREQUENCY));
}

void loop() {

/*SAMPLING*/
for(int i=0; i<SAMPLES; i++)
{
    microseconds = micros();    //Overflows after around 70 minutes!

    vReal[i] = analogRead(0);
    vImag[i] = 0;

    while(micros() < (microseconds + sampling_period_us)){
    }
}

/*FFT*/
FFT.Windowing(vReal, SAMPLES, FFT_WIN_TYP_HAMMING, FFT_FORWARD);
FFT.Compute(vReal, vImag, SAMPLES, FFT_FORWARD);
FFT.ComplexToMagnitude(vReal, vImag, SAMPLES);
double peak = FFT.MajorPeak(vReal, SAMPLES, SAMPLING_FREQUENCY);

/*PRINT RESULTS*/
Serial.println(peak);     //Print out what frequency is the most dominant.

for(int i=0; i<(SAMPLES/2); i++)
{
    /*View all these three lines in serial terminal to see which frequencies has which amplitudes*/

    //Serial.print((i * 1.0 * SAMPLING_FREQUENCY) / SAMPLES, 1);
    //Serial.print(" ");
    //Serial.println(vReal[i], 1);    //View only this line in serial plotter to visualize the bins
}

delay(1000);  //Repeat the process every second OR:
//while(1);       //Run code once

}

The problem I have is with the line microseconds = micros(). The comment state that this will overflow after 70 minutes and after some days of research, I sorta understand what is meant by this. However, I need this program to run over 9 hours, so I can log the dominant frequency of the brainwave throughout the night. Is that possible?


texts: Modbus TCP/IP using Arduino uno and ENC28J60 module

texts:
I have this project where I need a modbus tcp server that will host a series of sensor data for other modbus client devices to read. I use this Library by Andresoarmento
This is the code i am using from the library example:
#include <EtherCard.h>
#include <Modbus.h>
#include <ModbusIP_ENC28J60.h>

//Modbus Registers Offsets (0-9999)
const int SENSOR_IREG = 100;
//Used Pins
//const int sensorPin = A0;

//ModbusIP object
ModbusIP mb;

long ts;

void setup() {
    // The media access control (ethernet hardware) address for the shield
    byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
    // The IP address for the shield
    byte ip[] = { 192, 168, 1, 120 };
    //Config Modbus IP
    mb.config(mac, ip);

    // Add SENSOR_IREG register - Use addIreg() for analog Inputs
    int i = 2200;
    mb.addIreg(SENSOR_IREG,i);

    ts = millis();
}

void loop() {
   //Call once inside loop() - all magic here
   mb.task();

   //Read each two seconds
   if (millis() > ts + 2000) {
       ts = millis();
       //Setting raw value (0-1024)
       int i = 0;
       i++;
       mb.Ireg(SENSOR_IREG, i);
   }

The enj28j60 module is working as i tested it. So, I used a modbus scanner(CAS SCANNER) which was unable to detect it. Can anyone tell me how to get this all working and test it?
Thank you in advance.


texts:
I'm looking to have a button that, when pressed down, will mean that the script loaded on the Arduino doesn't run. So far I have:

void setup() {
  pinMode(3, INPUT_PULLUP);
  if (digitalRead(3) == LOW) {
    while(1);
  }
  // Beginning the Keyboard stream
  Keyboard.begin();
  // then the rest of the code.

I have a push button soldered to the ground and 3 pin. Could you see what is wrong with the code?


texts: Arduino clone woks only with USB - NOT with external power

texts:
I have an Arduino UNO ch430 clone. It works with USB power supply, I can upload a Sketch and it works just fine. With external power supply, doesn't work. What do I mean? No LED lights up, high pins output  ~ 0V. I'm using that barrel jack plug with 9V (6 x 1,5V batteries). Input voltage is measured OK. The AMS1117 regulator has Vin pin = Vout pin; i mean it gets no input Voltage. On the other hand, the M7F rectifier diode that comes between the jack and the regulator takes all voltage. I don't understan why, given that the anode is at higher voltage than the cathode (+9V). It shouldn't block current flow.
I tried jumping the rectifier and getting the jack +pin directly to the Vin at the regulator: current starts to flow, but apparently so much that the ams1117 heats a lot and really fast. Well i don't know why it suddendly gets so much current, I have absolutely nothing pluged to the board and I couldn't find any stain or damaged spot on it.

I can't figure out what is happening. I hope you can help me, and thanks in advance.

This is an exact (i'm pretty sure) schematic of my board.
Link


texts:
Current I use my ArduiMU V3+ with a Bluetooth Mate (from Sparkfun) but I've got a lot of connection problems with it.

I'm looking for a better solution involving WLAN and am wondering whether there are compatible modules?


texts: Need a simple accelerometer visualization example!

texts:
I'm doing a project using the ADXL335 accelerometer from SparkFun. The actual project I'm using P5 and it's working great. I'm running workshops in parallel and want to demo the chip in real-time but am currently out of time to build something from scratch. I'm desperate for a simple processing (or something else) sketch that takes my x, y, z values being printed to the serial port from Arduino and visualizes them in some way. Can anyone point me to anything that won't need a lot of coding time and effort just now?

Thank you!
Claudia


texts: Why can this color sensor not recognize green?

texts:
I got this color sensor last week, I've been able to get the sensor to recognize blue and red, but not green. still working on this.
I use the code in the product page.

so anybody have any idea about this issue? Pretty thanks.


texts: Accelerometer Z Value off a significant amount, all other values reasonable

texts:
I'm using the MPU9255 Accelerometer to measure acceleration in the X,Y, and Z directions.  As per the datasheet, I've applied a scaling to the raw digital values based off of whether I specified +- 2G, +- 4G, +- 8G etc.  This scaling works fantastically, but there is consistent noise on the Z axis, far greater than that of gravity's 1G of force.  Here is a sample output

ACCELEROMETER-X
0.7226562500
ACCELEROMETER-Y
0.1523437500
ACCELEROMETER-Z
7.9707031250

ACCELEROMETER-X
0.7460937500
ACCELEROMETER-Y
0.1875000000
ACCELEROMETER-Z
8.0468750000

As you can see, there is about 7G of noise on the Z axis. I calculated the scaling with this code:

//Get accelerometer scaling based off of how many G's per of variation the system was tuned to handle
int16_t getAccScalar(int16_t system_scale){
  int16_t acc_scalar = 16384;
  short scalar = 1;
  if(system_scale == ACC_FULL_SCALE_4_G){
    scalar = 2;
  }
  else if(system_scale == ACC_FULL_SCALE_8_G){
    scalar = 4;
  }
  else{
    scalar = 8;
  }
  acc_scalar /= scalar;
  return acc_scalar;
}

And then in configuration I use a register writing function with this header:

void I2CwriteByte(uint8_t Address, uint8_t Register, uint8_t Data)

and call it with these values

I2CwriteByte(MPU9250_ADDRESS,28,ACC_FULL_SCALE_2_G);

Anyone know why this is happening? Thanks and have a squanchy day.


texts: Read both battery voltage and analog sensor value with NodeMCU ESP8266

texts:
I have a soil sensor that reports value once every 5 minutes, deepsleep in between.
Is there a way to also report battery voltage (with ESP.getVcc())?

To get the battery voltage reading to work I need to set ADC_MODE(ADC_VCC); but that disables the reading of the sensor.


texts: Is it possible to upload previously compiled binary?

texts:
I have a number of sketches that I keep wanting to load into the Arduino but I don't necessarily need to recompile them because I haven't changed anything since the last compile. Since the compile takes a minute or 2 each time, this would save me some waiting.

I can see that the IDE has the option to "Export Compiled Binary", but doesn't seem to have the converse option of Uploading a previously compiled binary. Is there any way to do this?


texts: Error uploading Arduino Micro Sketch using Kubuntu

texts:
I have an arduino micro which I want to program from my Kubuntu 15.10 system. I installed the arduino software using apt-get, but when I try to upload the program (for test purpose I use the Basics\BareMinimum sketch) I get the following error:

Found programmer: Id = "0.00 V1"; type =
    Software Version = 0..; Hardware Version = 0.0
avrdude: error: buffered memory access not supported. Maybe it isn't
a butterfly/AVR109 but a AVR910 device?

The proper device "Arduino Micro" is selected and also the proper port "/tty/ACM0". I found people on the internet which have the same error and could solve it by using another USB port or cable. But I tried it with two different cables and different ports and didn't manage to get it working. I even tried it on my Laptop running an older version of Kubuntu which produced the same error.

Therefore I tried the newest version of the Arduino software from the arduino homepage. With this I get a different error:

avrdude: ser_open(): can't open device "/dev/ttyACM0": Device or resource busy
avrdude: ser_send(): write error: Bad file descriptor

My user is added to the dialout group, so I should have access to the port. It is also the right port as the port disappears from the arduino menu when I unplug the board.

The arduino itself shouldn't be the problem, as I can upload the sketch from another windows laptop without problems.

EDIT: when I plug in the arduino, the following is added to the dmesg output:

[ 8390.293960] usb 1-2: new full-speed USB device number 6 using xhci_hcd
[ 8390.424861] usb 1-2: New USB device found, idVendor=2341, idProduct=8037
[ 8390.424863] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 8390.424864] usb 1-2: Product: Arduino Micro
[ 8390.424865] usb 1-2: Manufacturer: Arduino LLC
[ 8390.425283] cdc_acm 1-2:1.0: ttyACM0: USB ACM device
[ 8390.426815] input: Arduino LLC Arduino Micro as /devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.2/0003:2341:8037.0007/input/input21
[ 8390.482163] hid-generic 0003:2341:8037.0007: input,hidraw4: USB HID v1.01 Mouse [Arduino LLC Arduino Micro] on usb-0000:00:14.0-2/input2


texts: How to enable interrupt again after disabling it?

texts:
I am not quite experienced with Arduino and Interrupts. Below I am trying to disable interrupt once it got detected and enable it again when I start loop again. But in below code I am not able to enable it.

int L = 2;
volatile int done0=0;
volatile unsigned long leftT=0;

void recordL()
{
  if(done0 == 0)
  {
      leftT=micros();
  }
  done0 = 1;
  detachInterrupt(0);
}

void setup() {
  // put your setup code here, to run once:
  pinMode(L,INPUT);
  Serial.begin(9600);
  Serial.println("Start..");
}

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

  attachInterrupt(0,recordL,RISING);
  done0 = 0;

  while(!done0)
  {

  }

  Serial.println("Sound..");
  Serial.println(leftT);
  delay(1000);
  Serial.println("After Delay");
}

but I made small change in code. I shifted 'done0=0' above attachInterrupt() then it is working. Why is that happening? One more issue that I am facing here is when I enable it again one more saved value is coming. Does it store value when I have disabled it?

int L = 2;
volatile int done0=0;
volatile unsigned long leftT=0;

void recordL()
{
    if(done0 == 0)
    {
        leftT=micros();
    }
  done0 = 1;
  detachInterrupt(0);
}

void setup() {
  // put your setup code here, to run once:
  pinMode(L,INPUT);
  Serial.begin(9600);
  Serial.println("Start..");
}

void loop() {
  // put your main code here, to run repeatedly:
  done0 = 0;
  attachInterrupt(0,recordL,RISING);

  while(!done0)
  {

  }

  Serial.println("Sound..");
  Serial.println(leftT);
  delay(1000);
  Serial.println("After Delay");
}

Output for 2nd case (Sound is coming only once but I am getting sound after delay also):

   Start..
   Sound..
   2873000
   After Delay
   Sound..
   3873528
   After Delay


texts: Actuating a Hobbywing Skywalker 50A-UBEC ESC with Arduino CNC Shield

texts:
I need to control a brushless motor that came connected to this ESC using the Arduino CNC Shield V3.00 and Grbl 0.9j.

I connected the ESC's black wire to a GND from the shield and the ESC's white wire to the shield's Z+ limit (end stop).

I then tested by connecting everything but leaving the ESC unpowered, sending several M3 S*commands, where 0 <= * <= 1000, then powering the ESC, but nothing happened.


texts: How can I use an arduino as an intermediary step between my PC and a LED strip?

texts:
Goal
My end goal is to have a NeoPixel LED Strip that I can control via software on my PC, with various automatic modes and manual control. Right now all I have is the idea and some research done, because I don't want to order parts if I can't get this working. That means no arduino, no leds, no power supply, and no experience with any of them.
What I know so far
I know enough Java to set up the software that would output some array of colors, including manual control and automatic modes like flashing/fading/etc.
From the research I've done, I'll need a microcontroller to make sure I output exactly the right signal(?) for my LED strip. Adafruit recommends an Arduino one or Arduino mega, which meet the timing requirements and have libraries available for use with NeoPixel products. Physically connecting the Arduino to the LED seems fairly easy.
What I don't know
Hardware and software wise, how can I transfer an array of color values from a java program to the Arduino?
This involves getting the data to a port on my PC, getting that to the Arduino via some wire/s, and making sure it's readable. I'd imagine sending an entire array to whatever input the arduino has would be difficult. Perhaps I could send a single color at a time together with an index, but that would probably add delay to the system.
On the software side, how do I set up the arduino to "forward" the input from my PC to the LED strip?
I'm not very comfortable with C, so this could be tough. How will I receive the data input? How easy and fast is it to turn that into output for the LED strip? What if I don't convert and output an update before I receive another one?
EDIT: It seems there are libraries available to deal with the actual data transfer, and encoding/decoding shouldn't be too hard after some thought. I think I'm going to use usb4java for communication between my PC and an Arduino, and roll my own mini "protocol" to convert. Then I'll use the NeoPixel libraries for the Arduino.


texts: Project organization and Arduino board for bee-hives monitoring

texts:
I'm new about Arduino and also about the electronic world... I'm a software developer.
I need to put in place a project to monitor my bee hives.
I have multiple hives in two different places (one with a distance like 2km and the second with 0.5km distance from my house).
In these places there is no energy power and wifi connection.
To solve the first problem my idea is to use a solar panel + a battery (optimizing the times for the measuring... for example switch on the module for 10minutes for each hour)
To solve the second problem my idea is to use LORA sensors on the module and to use a receiver in my house (where I have Internet with a possibility to upload the measurements on a server for post-processing).
For the first version, the three most important parameters that I would like to monitoring are:

Temperature (inside the hive);
Humidity (inside the hive);
Weight of the hive;

For example,  in one of my places I have 8 hives. So, I need:
8 temperature and humidity sensors, 8 cells for scales and the LORA sender chip.
As I said, I'm not an electronic expert and this is the first 'serius' project with Arduino.
I have the first base but important question: from your point of view, can I use only one board for each place? Is it enough to connect all sensors (in terms of pins).
My theoretical goal is to use only one Arduino board for each place because, in this way:

I will be able to reduce the effort in terms of money (to purchase Arduino's boards as also LORA sensors, etc..)
I will be able to reduce the used energy instead of using a dedicated battery + solar panel + chip about the charge of the battery...  for each board.

The second most important question (but probably related to the previous one) is: what'is the type of Arduino board would you recommend?
Is this choice related to the number of pins that I will need?
I have an additional question also related to the solar panel but probably it's better to clarify the previous aspects, understand the power absorption to define the size of solar panel, of the battery and the intervals (switch on/off of the board).
Feel free to criticize/suggest also my project choices... I'm not an expert so I need only to study for this.
Thank you


texts: Linker error when trying to use functions in separate header and source files

texts:
It is my first day of working with Arduino (it is a Due). I want to read from TMP102 through I2C. I wrote some code and it works just fine. But now I want to separate the TMP102 code from the main source code. But I get linker error:

  sketch_jun15a.ino.cpp.o: In function setup':
  C:\Users\Saeid\Desktop\sketch_jun15a/sketch_jun15a.ino:62: undefined
  reference totmp102_allocate(int)' collect2.exe: error: ld returned 1
  exit status

My code is at the moment consist of 3 files:

tmp102.h

#ifndef TMP102_H
#define TMP102_H

//TP102 sensor struct
typedef struct TMP102 {
  int   address;
  float celsius;
  float fahrenheit;
} tmp102_t;

tmp102_t* tmp102_allocate(int address);

void tmp102_init_struct(tmp102_t * t, int address);

#endif

tmp102.c

#include "tmp102.h"

tmp102_t* tmp102_allocate(int address) {
  tmp102_t* t = (tmp102_t*) malloc(sizeof(tmp102_t));
  if(t) { //allocation success
    tmp102_init_struct(t, address);
    return t;
  } else {
    return 0; //null pointer
  }
}

void tmp102_init_struct(tmp102_t* t, int address) {
  t->address = address;
  t->celsius = 0.0;
  t->fahrenheit = 0.0;
}

and here is the setup function of the sketch:

#include "tmp102.h"
void setup(){

  //setup TP102 sensors
  tp_1 = tmp102_allocate(72); //error is here
  tempSensors[0] = tp_1;

  //rest of stuff...

}

I think there is no mistake in the code. There is also no option in the Arduino IDE so that I can meddle with the compiler/linker options.

All the files are inside the sketch folder. I created these files using the drop down button in the IDE...


texts: Is it possible to connect NRF24L01 to localhost in laptop without wifi router?

texts:
I want to send data from arduino to my localhost port:8080(with ipython notebook) via modul NRF24L01 without WiFi router. Is it possible? If it possible, how to do that?
Thank  you...


texts: Read Multiple Sensors Data from a text file located in SD Card in Arduino/ESP32

texts:
I am working on a small home project 'glucose meter' via non invasive techniques. I am using four sensors like RGB color sensor, two multi-wavelength photo diodes (A & B) and temperature sensor (K-Type Thermocouple). I am using Multi Regression algorithm to estimate Glucose level in human body by calculate all four readings from sensors.

I am using ESP32 and I am saving all my sensors data in a CSV file (or text) after taking more than 20 calibration data from my family and friends. I can read this file after writing but I am facing a problem in reading all calibration data from this text/CSV file in the following particular manner.

Y,Sensor1,Sensor2,Sensor3,Sensor4
92,103,25,65,9875
91,104,26,62,9805
105,92,30,66,9600
150,60,40,75,9233
...,...,...,.....

Above pattern indicates 'Y' values (Blood Sugar value mg/dl) and corresponding sensors value on that time.
I am facing problem in reading these object like:

Y1 = 92, S1 = 103, S2 = 25, S3 = 65, S4 = 9875
Y2 = 91, S1 = 104, S2 = 26, S3 = 62, S4 = 9805
....................AND so forth..............
Y1000 = XX, S1 = XX, S2 = XX, S3 = XX, S4 = XX

Can any one help me how would I read and categorize each sensor values from the text/CSV File?

Thanks.


texts: I need to generate a programmable pulse inside an ISR

texts:
I have an application that requires that I generate an output pulse whose width is calculated in the main loop. The pulse has to be triggered by an interrupt and I understand that "delay" won't work inside the ISR. I can't use a polling technique because of the requirement to use serial writes in the main loop.

Any ideas or suggestions will be most appreciated.
Thx


texts: declared variable inside void setup is forgotten in void loop

texts:
if i declare a var in void setup() and try to do something with it in void loop(), it just says that the variable is undeclared. here is the code:

#include "Servo.h"

void setup() {
    Servo servo1;
    int x_key = A0;
    servo1.attach(2);
    pinMode(A0, INPUT);
    pinMode(2, OUTPUT);

    int x_position = 90;
}

void loop() {
    if (analogRead(A0) < 512) {
        x_position++;
        servo1.write(x_position);
    }
}


texts:
It is possible to split the project into server files. However, it looks like they all must be in the same folder with the.ino file.

Is it possible to split project into several folders? I’ve got several git repositories which I want to use in the same project and I can’t use them as libraries. Each repository must have its own folder…


texts: Implementing sending from N and recieving from N with FreeRtos and RF24 radio module

texts:
I'm trying to make my first chip send data through a nrf24 radio pipe and the other listen to it. After the first data is received it should switch to transmit mode and itself transmit new data. The main goal of all of this is to implement the raft protocol with at least 3 chips participating. So the requirements would be to have each chip listening all the time and to have it stop listening at random intervals to send a broadcast message to all other chips. Basically the communication is never between just two chips but always one to many. I've come across tutorials such as http://forum.arduino.cc/index.php?topic=421081 but it always comes down to a stable Master vs Slaves state while my situation is more dynamic.
This is my current task. The listener works perfectly until the first received message when it opens a writing pipe. It then does not write and does not go back to listening.

void test_Task(void *pvParameters){

    printf("some init\n");
    bool hastoSend = false;

    radio.openReadingPipe(1, address);
    while(1){

        radio.startListening();
        if (radio.available()) {
            radio.read(&rx_data, sizeof(rx_data));

                if (rx_data[1] == 101){
                    printf("Received message: %d\n", rx_data[1]);
                    hastoSend = true;
                    printf("%d\n",rx_data[0]);
                    //int someint = *((int*)pvParameters);

                    // turn on led1
                    write_byte_pcf(led1);
                    vTaskDelay(pdMS_TO_TICKS(200));
                    write_byte_pcf(0xff);
                }

        }else{
                if (hastoSend){

                    printf("I need to send a message!\n");
                    printf("sending a message\n");
                    radio.openWritingPipe(address2);
                    radio.stopListening();
                    transmit_nrf24();
                    radio.printDetails();
                    hastoSend = false;
                    radio.openReadingPipe(1, address);

                }
        }

    }

}

This is my radio setup:

static inline void setup_nrf() {

    uart_set_baud(0, 115200);
    gpio_enable(SCL, GPIO_OUTPUT);
    gpio_enable(CS_NRF, GPIO_OUTPUT);

    // radio configuration
    radio.begin();
    radio.setChannel(channel);
    radio.setAutoAck(false);

}

For testing purposes the messages being transmitted come from my other device which is just a manual transmitter. What would solve my problem is a way to completely reset the radio when the first message is received so that the pipes do not bother each other and the device could then be re-initialised as a transmitter.

Cheers!


texts:
I have a GP2Y0A21YK0F Sharp IR Analog Distance Sensor 10-80cm + Cable, Arduino Compatible and its is connected to my Arduino. All works well and I can read the analog data with the following code:

#include <SoftwareSerial.h>
#define RX 2 // receive
#define TX 3 // transmit
#define SEN1 4
SoftwareSerial mySerial =  SoftwareSerial(RX, TX);

void setup()
{

  mySerial.begin(4800);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{

   int reading = analogRead(SEN1);
   mySerial.println(reading);
   delay(500);
}

When the code runs on the Attiny with the GP2Y0A21YK0F IR Sensor connected, the Attiny84 resets over and over. The Attiny84 and GP2Y0A21YK0F are part of the same circuit e.g. Attiny and GP2Y0A21YK0F share the power and ground rail.

When I disconnect the GP2Y0A21YK0F, the program runs and stops resetting. I was able to reproduce this on an Attiny85 and ATMega328.

The strange thing is, it works fine on the Arduino. Any help is greatly appreciated.


texts:
I just started working on a project involving bluno beetle ble. For now, i'm sending the data from beetle to a android app i made.

But, for a fail safe mechanism in case the mobile is not in range or has disconnected from the device, i want to add a SD card reader to the device so i can save the data.

Is it really possible to add SD card reader to beetle ble? If yes, can someone provide any hint on what connections need to be made?

Thanks


texts: Dust sensor for Arduino in open and windy environment

texts:
I intend to create a DIY dust sensor, specifically Particulate Matter up to 10 micrometer in size (PM10) using Arduino UNO for the region surrounding a building which is located next to a factory that produces wood-based products. Is there any specific sensor that should suit my need, that is to collect and measure dust particles in an open environment and possibly a windy condition?
Any implementation ideas are also welcome.


texts:
Are there any best practices regarding password safety?  The following is taken from a wifi tutorial sketch.

#include <SPI.h>
#include <WiFi.h>

char ssid[] = "yourNetwork";      // your network SSID (name)
char pass[] = "secretPassword";   // your network password
int keyIndex = 0;                 // your network key Index number (needed only for WEP)

While I accept that the tutorial is there for learning how to use the shield, I would assume hard coding the password into the sketch leaves this open to attackers.  Is this actually the case?  If so, are there any strategies to harden the sketch, for example with encrypted storage?

I am a relative newbie with physical computing and Arduino, so sorry if I am overlooking something obvious.


texts: How to Connect ESP8266 with ultrasonic sensor and dht11 without breadboard?

texts: I want to connect the sensors in Esp8266 after I code those using arduino uno r3. The problem is that I don't have the idea on connecting those sensors without breadboard. Thank you


texts: What board to use to send a text message via an arduino board

texts: I am fairly new to arduino boards and I was wondering which board to use. I was looking into the edison board because it has built in wifi and bluetooth.


texts: Which side should I connect the resistor on?

texts:
I understand that when connecting an LED and a resistor in series; the resistor can be placed on any side of the LED as the current will remain same in a series connection. Please correct me if I'm wrong, but I was under the impression that conventionally the electrons flow from positive to negative. So shouldn't the resistor be placed before an LED to limit the flow of charge.

In this scenario the negative is connected ground and the positive to a power source. So I don't understand the chain Link analogy as well. Where the whole chain moves as a whole because here the flow ends with the GND right ?


texts: How to prevent Arduino compiler from merging changing of port pin outputs into a single operation

texts:
I want to set one pin's output value, and then set a different pin's output value so that the two pins change value one after the other.
However, the compiler optimises the two calls to change both pins in one go.

PORTD |= _BV(0);    //set pd0 to high
PORTD |= _BV(1);    //set pd1 to high
PORTD &= ~(_BV(1)); //set pd1 to low

The two pins go high simultaneously. I tried inserting a NOP between these but it doesn't change behaviour.

(I originally intended to include an oscilloscope screengrab to show what was happening - that's how I knew (or got the wrong impression) that the two pins were changing at the same time. But the photo wasn't shifting from my Nexus 7 for me to access it from my laptop.)


texts: Cheap weatherproof ultrasonic range sensor?

texts:
What's an inexpensive ultrasonic range sensor that's reasonable waterproof or weatherproof that also interfaces easily with an Arduino?

I've used these kinds of ultrasonic range sensors, which are cheap and trivial to wire to an Arduino, but they're not very robust and are easily damaged since you can't cover them without that covering obstructing the soundwave.

Maxbotix sells a "Weather-Resistant" ultrasonic range sensor, but it's around $100, which is a little out of my price range.

I've researched those "parking sensors" used on cars, but I haven't seen anyone successfully interface them with an Arduino. It's also hard to tell how they're controlled. Some sites sell batches of the sensor for $3/each, but I don't think this includes the control electronics. Ebay listings that include what appears to be a bulky controller board seem to go for around $50-$100, which makes them a little pricey.


texts:
I would like to connect my SIM900 to a PBX (phone switchboard). Is this possible either analogic or digital way?
Many thanks


texts:
At this moment I am using oversampling to increase my analogread resolution.
This in combination with increasing the frequency of the ADC.
Is someone able to take a look at it?

#define FASTADC 1
// defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

int value[100];   // variable to store the value coming from the sensor
int i=0;

void setup()
{
  Serial.begin(9600) ;
 int start ;
 int i ;

#if FASTADC
 // set prescale to 16 (1MHz)
 sbi(ADCSRA,ADPS2) ;
 cbi(ADCSRA,ADPS1) ;
 cbi(ADCSRA,ADPS0) ;
#endif
}

void loop()
  {
  for (i=0;i<100;i++)
  {
   value[i]=Read12bit(0);
  }
  for (i=0;i<100;i++)
  {
   Serial.println(value[i]);
  }
  Serial.println();//Some blanks between values
  Serial.println();
  delay(5000);

}

int Read12bit(uint8_t pin){
      int Result = 0;
      analogRead(pin);                      //Switch ADC
      for(int i = 0;i < 16; i++) {          //Read 16 times
        Result = Result + analogRead(pin);  //Sum results
      }
      Result = (int)Result/4;               //Divide by 4 for 12 bit value
      return(Result);
    }

At this moment the resolution of this oversampled analogread is 12-bits. With a little calculation the time to read will take 0,208milliseconds. If I want to increase my resolution more i.e. 13-bit. This will take the measurement 0,832 milliseconds. This seems rather big, so my question is can I do this in another way?

EDIT
Why?
I am trying to position multiple linear actuator using multiple arduino's connected via CAN-bus (the arduino's will not communicate with eachother unless an error occures) THe positioning has to be precise (<0.1mm on a 30 cm rod).

Why is 12 or 13 bit accuracy and/or resolution needed?

12 is probably enough. But I just like to find out the boundaries of the equipment :)

What real world processes are being monitored that 0.012% perbit step sizes are not swallowed in the noise of reality?

Probably none 13-bit resolution is probably too high for my application anyways.

Other reason why I like a higher resolution
First couple of voltages I cannot use. My sensor gives a 4 to 20mA signal which i convert with resistor to ground.


texts: Creating an array of structures which store bitmaps to work with u8glib

texts:
I've tried reading the documentations and I'm getting desperate because I can't find anything.

I need to create an array of structures, which contains a bitmap stored in PROGMEM space (because of issues with memory usage).

The bitmaps are created as follows:

const uint8_t pat[] PROGMEM = {
...
};

Then I need to create a structure like this:

typedef struct{
    uint8_t bitmap[8];
} chars;

chars allChars[1];

but the compiler doesn't like that for some reason and spit out a bunch on invalid conversion from const to char so it was clear I couldn't use that!
My next attempt was to create a pointer to the pattern like so:

typedef struct{
    const uint8_t *bitmap[8];
} chars;

chars allChars[1];

This time it again gave warnings about invalid conversion but at least compiled!
I then tried to write the entire code and run it:

#include "U8glib.h"
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE|U8G_I2C_OPT_DEV_0);

typedef struct{
    const uint8_t *bitmap[8];
} chars;

chars allChars[1];

const uint8_t pat[] PROGMEM = {
  0xff,
  0x00,
  0xff,
  0x00,
  0xff,
  0x00,
  0xff,
  0x66
};

void draw(void) {
  u8g.drawBitmapP( 37, 28, 1, 8, pat);
  u8g.drawBitmapP( 74, 28, 1, 8, (char*) allChars[0].bitmap);
}

void setup(void) {
  allChars[0]= (chars) {*pat};
}

void loop(void) {
  draw();
  while(true);
}

the first line where I have used the pattern directly in the draw function, works perfectly fine, but the second line which retrieves the value from the pointer draws some weird noise shape (I'm guessing memory dump of an address or something)!

Is it even possible to create a struct with one of the variables being just a pointer to the constants that I have defined earlier? I'm pretty sure I'm doing something very wrong as I'm not familiar with using pointers and addresses and whatnot, so it would be great if someone could help with these issues!


texts: My arrays are possibly causing the program to not enter loop?

texts:
I'm working on a project to make a digital clock with an 8x32 ws2812 LED grid, arduino uno, and a RTC module.

Everything works great separately, but when I integrate it all together the code never seems to reach the loop function. I have print statements in the setup and start of the loop, and the setup statement triggers but the first print in the loop does not. Nothing in the loop seems to occur. Commenting out line by line I've identified that the problem somehow is caused by my arrays of neopixel locations. When I comment out lines that refer to certain arrays, the code works, all print statements are called and every other functionality works fine. When I restore the lines that call the problematic arrays and remove some of the values, it will eventually start working when I remove so many values from the end. Weird.

Array examples:

int left_min_zero[] = {145,146,147,148,149,150,153,166,169,170,171,172,173,174,161,158};
int left_min_one[] = {158,157,156,155,154,153};
int left_min_two[] = {145,158,161,174,173,172,171,164,155,148,149,150,153,166,169};

The full code is here: https://github.com/SupaTreadz/Pixel-Clock/blob/master/PixelClock.ino

The offending lines are related to the following arrays:

"left_min_four", "left_min_five", and all of the "right_min_" arrays (possibly, I only checked the first three)

ALL of the other arrays work fine. WHAT THE HECK IS GOING ON HERE???

Just to reiterate, those arrays worked perfectly before adding the clock stuff. So right now all of the hour digits function perfectly, the first digit of minutes work except for 4 and 5, and none of the right minute digits work.

Any insight into this problem that is driving me crazy would be much appreciated.


texts: Interfacing TTP229 touch sensor with arduino and gsm module

texts:
I have been working on an Arduino based call and message project which I am following from this link https://circuitdigest.com/microcontroller-projects/call-and-message-using-arduino-sim900-gsm.
This project uses a membrane keypad for inputting the phone number and etc., but I intend to use a TTP229 16 channel Touch sensor module.

I need help in taking input from the touchpad rather than the keypad. As I need to submit the project within a month it is my humble request if someone can help.
Thanks for replying!


texts:
I'm working on a project that involves a device called the plduino (aka Open Source PLC). This is the website for the device:

https://www.digital-loggers.com/plc.html

and the GitHub:

https://github.com/digitalloggers/PLDuino

Using the examples on the GitHub, I've been able to figure out other parts- storing on the SD card, the GUI, digital IO, etc. But I haven't been able to figure out the WiFi module (which seems to be through a ESP8266 device). I looked through the libraries directory on the GitHub link, but didn't find anything that looked like it connected to the internet or could send or receive data. The documentation says the device can connect to wifi, but is otherwise very little help.

Has anyone used this before? How do I make this device connect to wifi?


texts: Make a PC graphical interface for Arduino - Any easy software?

texts:
What's the best/easiest software to make a PC-Arduino interface? Ideally, I need to create a .exe that shows up a simple graphic interface, where the user can display data acquired from sensors connected to the Arduino (eg. Voltage, current etc.) and from there he should be able to control Arduino outputs through graphical buttons/switches.

To say that I am not a programmer, so if there's some sort of 'graphical coding' or 'non coding' software to make such things it'd be great!

Thanks for your help!!!

UPDATE:

Image of how the user interface should look like:


texts: ESP32 WiFiClient request missing response

texts:
I am facing problem with ESP32. I use basic example for WiFiClient and making request to my server. The problem is that the response should be 15000 bytes long, but very often I got only 2750 or less.

char buffer[15000];
while (client.available()) {
  char c = client.read();
  buffer[i++] = c;
}
Serial.println(i);


texts: HC-SR04 ultrasonic sensor: How to check voltage on the ECHO pin

texts:
I'm using and ESP8266 with HC-SR04 ultrasonic sensor. The sensor requires 5v input and will also output to the GPIO pins at 5V.

ESP8266 has a strong recommendation to use 3.3V into the GPIO pins. I've found some setups online with people using voltage dividers to bring the ECHO pin voltage down.

Example on a PI: https://tutorials-raspberrypi.com/raspberry-pi-ultrasonic-sensor-hc-sr04/

I'm using a basic multimeter that i've found to be pretty accurate. When I put the BLACK cord on the ECHO and RED on the GROUND (of sensor pins), I get variable voltage readings. I'm trying to ensure a 3.3V coming from the ECHO into my ESP.
Questions:

Am I putting the black and red cords on the appropriate areas?
If yes to question 1, then why am i get such a variable of readings?
How can I test to ensure only 3.3V coming out of ECHO?


texts:
I'm trying to use the popular SN74HC595 Shift Register, but I think something isn't right because when the bits are submitted to the register it comes out with something similar but not the same.

#define Latch 9
#define CLK 10
#define DATA 8

byte led = B10110111;

void setup()
{
  pinMode(Latch, OUTPUT);
  pinMode(CLK, OUTPUT);
  pinMode(DATA, OUTPUT);

  digitalWrite(Latch, LOW);
  shiftOut(DATA, CLK, MSBFIRST, led);
  digitalWrite(Latch, HIGH);
}

void loop()
{
  //LOOP
}

After this completes I receive an output of 10110101 instead of 10110111. Has anybody had the same area? Any fixes? Could my chip be faulty inside?

Schematic:


texts:
So basically I've been wanting to get into working with Arduino boards and such for a while (I actually have a couple of microcontrollers that support micro-python, a subset of my favorite programming language, python, that I've unfortunately never used yet)
So I came up with an idea, A simple soda-counter that gets mounted on my fridge via a magnet because it's practical and a very simple 'hello-world' style project
I'm thinking of using E-paper as the display (for power consumption reasons)
And a small replaceable watch battery to power it
Alongside 3 buttons

Increment Display number
Decrement display number
reset display number to 0

The purpose of this project is simple, to force me to stop grabbing soda mindlessly and be aware of how much soda I drink (and if I've already had a few, force me to consider if I really want another one) Alongside being a gentle introduction to building my own practical devices.
With that said, I have close to 0 experience with this stuff (Although I am very comfortable writing code)
I did look into building my own devices in the past, but I didn't apply the knowledge so most of the info is lost.
My questions are:

What hardware would an expert/enthusiast advise me to use? (bonus points for 'why') (I'm also comfortable writing C code for this project)
What are some common gotcha's I may face with this project? (bonus points for solutions)
What are some 'must read' resources/concepts/ect I should study up on before attempting the project?

I may also decide I want to keep a log of the time I grabbed a new soda, along with analytics that parses the log file and determines relevant info (IE: sodas per day on average) and possibly expose that over the network, but that's all stuff that I can work on later after I have a better feel for working with this kind of stuff.


texts:
I see many ESP8266HTTPClient examples, pasting in a fingerprint from an outside website, but I want to host an html page from the ESP8266 in AP mode using HTTPS.

Judging by the lack of examples, and the lack of a domain for a cert in AP mode, I'm thinking this is impossible, but would like confirmation before I give up.

Is it impossible to get the browser's green padlock on an AP-served web page?


texts: Arduino - Turn on LED when Potentionmeter is used

texts:
I'm very new to the Arduino/Microcontroller-world, so please be patient :)

I have 4 potentiometers and I want my LED to blink up, when one of these is beeing used.

So far., so good.. the potentiometers are sending singnals to my inputs A0-A3. In the code I read and buffer the values of send to the inputs, so when a new value is recieved (potentiometer is beeing used), the funcion blinkLED() is beeing triggered:

int ledPin = 13;

int pin[] =             {A0, A1, A2, A3};
int cc[] =              {20, 21, 22, 23};
int potiValues[] =      {0,  0, 0, 0};
int potiValuesTmp[] = {0, 0, 0, 0};

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

void loop() {
    // READ EVERY PIN
    for(int i=0; i<=3; i++){
        potiValues[i] = map(analogRead(pin[i]), 0, 1023, 0, 127);
        if(potiValues[i] != potiValuesTmp[i]) {
            // NEW VALUE RECIEVED - MAKE OUTPUT
            Serial.println("Pin ");
            Serial.print(pin[i]);
            Serial.print(" - ");
            Serial.print("Value: ");
            Serial.print(potiValues[i]);
            blinkLED();
        }
        potiValuesTmp[i] = potiValues[i];
    }
}

void blinkLED() {
    digitalWrite(ledPin, HIGH);
    delay(1000);
    digitalWrite(ledPin, LOW);
}

It somehow works on the emulator circuits.io, but I'm not sure if I did it right(?) Maybe someone could have a look and tell me, what to improve?

But my main question is:
When the function blinkLED() is triggered, there is this delay,.. does the whole loop()-function wait, too?


texts: Why is my Adafruit motor shield not spinning my motors?

texts:
I'm using the Adafruit Motor Shield v2.3. I'm powering the Arduino with a USB cable and I'm powering the motor shield with a 9 volt battery.

I removed the vin pin, and I'm using this tutorial/code to make the DC motor spin.

I've tried 3 different kinds of DC motors, but none of them will do anything. The Arduino works for normal sketches, like lighting up LEDs, but I can't get the motors to work.

Any ideas?

Edit: I'm using Adafruit's "Motor Test" code from the Motor Shield v2 library, as shown below. The motor is on port 1.

// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!

#include <AFMotor.h>

AF_DCMotor motor(4);

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

  // turn on motor
  motor.setSpeed(200);

  motor.run(RELEASE);
}

void loop() {
  uint8_t i;

  Serial.print("tick");

  motor.run(FORWARD);
  for (i=0; i<255; i++) {
    motor.setSpeed(i);
    delay(10);
 }

  for (i=255; i!=0; i--) {
    motor.setSpeed(i);
    delay(10);
 }

  Serial.print("tock");

  motor.run(BACKWARD);
  for (i=0; i<255; i++) {
    motor.setSpeed(i);
    delay(10);
 }

  for (i=255; i!=0; i--) {
    motor.setSpeed(i);
    delay(10);
 }

  Serial.print("tech");
  motor.run(RELEASE);
  delay(1000);
}


texts:
research would show that there are numerous ways for two arduinos to talk to one another. But i was looking for a 'basic robust protocol' (..it doesn't sound basic ....I know!), to allow for two arduinos to talk to one another. The idea is , Arduino One(slave), is linked to a sensor and it reads data from the sensor and sends the data  to Arduino Two on 'request' of the data by Arduino Two(master). Arduino Two would have to 'request' for the data from Arduino One, before it can read the data, if its available. A popular method on most sites (e.g https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing/shaking-hands-part-1) is the use of the method below. I added a comment in search of clarity.

              void establishContact()
                     {  //This while loop does baffle me as it suggests that
                        //while there is nothing in serial, send A???
                        while (Serial.available() <= 0)
                       {
                         Serial.println("A");   // send a capital A
                         delay(300);
                       }
                     }

Now this method was used in handshaking between Arduino and processing. This method was called on the Arduino sketch. On the processing sketch, a method there just checks to see if 'A' was received. If it is, it reads in the data from serial, clears the serial buffer and  writes 'A' back to Serial. I tried using this method on both of my arduinos as i felt it was 'basic' enough, but it didn't work at all. Does anyone has a better idea on how my arduinos could handshake?.


texts: Getting an error while uploading code to Arduino when ESP8266 is attached

texts:
I am trying to use an ESP8266 and an Arduino to access the Arduino from the network. I tried to do something but I'm facing some challenges. I hope I am using the correct board "Generic ESP8266 Module".

#include <SoftwareSerial.h>

const byte rxPin = 2; // Wire this to Tx Pin of ESP8266
const byte txPin = 3; // Wire this to Rx Pin of ESP8266

// We'll use a software serial interface to connect to ESP8266
SoftwareSerial esp8266(rxPin,txPin);

void setup() {
  Serial.begin(9600);
  esp8266.begin(9600);
  delay(1000);
}

void loop() {
  Serial.println("Sending an AT commands");
  esp8266.println("AT");
  delay(30);
  while(esp8266.available()) {
    String data = esp8266.readStringUntil('\n');
    Serial.println("Got response from esp8266: " + data);
  }
}

Error

Archiving built core (caching) in: C:\Users\XYZ~1\AppData\Local\Temp\arduino_cache_322251\core\core_esp8266_esp8266_generic_CpuFrequency_80,FlashFreq_40,FlashMode_dio,UploadSpeed_115200,FlashSize_512K64,ResetMethod_ck,Debug_Disabled,DebugLevel_None_____feb0d75f3cf4e05271af4f91549cd009.a
Sketch uses 226657 bytes (52%) of program storage space. Maximum is 434160 bytes.
Global variables use 32464 bytes (39%) of dynamic memory, leaving 49456 bytes for local variables. Maximum is 81920 bytes.
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed


texts:
I want to program a temperature sensor with a LED using Arduino.
the goal is to make a sensor, when the temperature is over than Temperature max, the LED turns off and when the temperature is small than temperature max we turn on the LED.

my problem is when I programed the void setup() as followed, the LED doesn't work, and when I comment Serial.begin (9600) the LED work but I cannot diplay the value of the temperature.

void setup() {
   Serial.begin(9600);
   pinMode(tempPin, INPUT);
   pinMode(led, OUTPUT);
}

here you find my complet code:

    int tempPin = A0;   // the output pin of LM35
float Max_temp = 24.0;
int led = 1;

float  temp, cel;
void setup() {
   Serial.begin(9600);
   pinMode(tempPin, INPUT);
   pinMode(led, OUTPUT);
}
void loop() {
      cel = readTemp();
  if(cel< Max_temp) {        // if temp is higher than tempMax
      digitalWrite(led, HIGH);  // turn on led
      delay(300);
     }
     else {                    // else turn of led
       digitalWrite(led, LOW);  // turn on led
      delay(100);
  }
   Serial.print("TEMP: ");
   Serial.print(cel);      // display the temperature
   Serial.print("C ");
   Serial.println();
   delay(300);
}

float readTemp() {  // get the temperature and convert it to celsius
  temp = analogRead(tempPin);
  return temp * 0.48828125;
}

thank you very much in advance


texts: What are the SVG pins for on the SainSmart Uno clone?

texts:
I bought a SainSmart clone board which is compatible with the Arduino Uno R3. Alongside each of the standard IO pins, there is a row of 3 additional pins (male). They are arranged in columns, marked S, V, and G.

They can be seen on this image:

Most of them are immediately above the SainSmart and UNO logos. The SVG pins corresponding to the analog pins can be seen immediately below the microprocessor.

What are these pins for? Is this a standard format for some applications, or is it something unique to the SainSmart?


texts: Will a 12 VDC 1A Power Supply Adapter supply too much power and damage an Arduino Mega 2560?

texts:
The specs shown here:

show that it has 54 digital pins with each outputting a DC current of 20mA which makes it 54 * 20 = 1080 mA

Plus the DC current of the 3.3V Pin of 30mA we get a total of 1110mA.

Is this how one should go about doing the computations?

If the adapter is insufficient will a 12 VDC 2A Power Supply Adapter be appropriate or excessive?

Any links to read up on will be greatly appreciated as well.

Links for this question:

https://store.arduino.cc/mega-2560-r3

https://store.nerokas.co.ke/index.php?route=product/product&product_id=567

PS: All I'm planning to connect to the board is: 'a PIR sensor (the first version not Rev B)', a '5V relay' and possibly a 'ESP8266 ESP-01S Relay Module'


texts: Waking Arduino from sleep with an ultrasonic sensor

texts:
I have a parking guide using an ultrasonic sensor (HC-SR04), based on the instructions here. I'm trying to modify the code so that the Arduino goes to sleep after a certain period of inactivity (say, 30 seconds), and wake again when the sensor 'sees' a car drive into the garage. The code here shows how to wake it with a solar panel.

However, the way I understand it, the solar panel is able to wake the Arduino because it doesn't need external power to work (because it's a solar panel). Would it be possible to do the same with an ultrasonic sensor (HC-SR04), which does need power?

It'll be running off mains power, but I don't want it to be drawing power when it's not needed.


texts: Can I power arduino uno R3 with 9v battery through Vin?

texts: I want to power up arduino through Vin port , what should be the input voltage ?


texts: I am now constructing something with 30 servos (each one will control an individual joint separately, so I guess I can't get away from this), how can I determine how much current do I need, I have a 5V 6A power supply, will that be working just fine? Many thanks in advance!


texts:
I am looking for a way to protect my Arduino's digital outputs from unwanted, outside voltages. My project uses about 20 different outputs, each connected to a wire (run) that can range from 20 to 100 feet (I used cat5 cable, with each inner wire (randomly chosen) dedicated to a single digital in, out, +5, +9 or ground.)  There is a good change that outside voltages could impact these digital outs (or any other pin or power wire.)

I have a good resource on protecting digital in's but I ma not sure how to protect the digital outs.  Each needs to be able to both pull a connect component to ground, and push it up to 5 volts (am I saying this correctly?)

This should be able to protect the digital outs from shorts or 12v spikes.

How can I build this circuit?

Edit: it is difficult for me to describe this problem without mentioning the danger to all components.

Note that ways of protecting digital inputs is HERE.


texts:
I run my Arduino Nano IOT 33 after double clicking the reset button and it works fine. However, as soon as I upload code to it, I cannot open the serial, see the port, or connect my blynk app to it.
Sorry for not explaining it well the first time. As for the code I do not have specific code that is causing an error.  I even uploaded a hello world sketch and it did not work.
my pinout is the following
3.3V -> V(external analog sensor)
3.3V -> V(external analog sensor)
A0 -> pinIn
A1 -> pinIn
Gnd - gnd
Gnd - gnd


texts: Correct use of interrupt vs monitoring switch

texts:
Background:
I have a uni assignment which requires an autonomous robot to do a number of tasks and then finish in a set spot after being triggered to start by an outside physical interaction. I've set up a light limit switch to detect this interaction.

My approach would normaly be to look for the switch in the loop to go high and then run through my code and put a really long delay at the end.
e.g.

switchState = digitalRead(switch);
 if (switchState == HIGH){
 //do my routine which is a function defined outside of the loop
}

Would this be an appropriate use for an interupt instead of the method above. I'm still trying to understand the best practice usage.


texts: Do I need 3 full-size arduinos to control this LED setup?

texts:
I'm sourcing the parts now for an LED persistence of vision setup on a bicycle.  Two wheels with anywhere between 16-32 LED's per wheel, as well as 24 LED's mounted on the frame of the bike itself

Since the Arduinos have to be mounted into the wheels to drive the POV displays - do I need a total of 3 arduinos?

Driven by 2x [Nano 3.0 Atmel Atmega328P Mini-USB Board][1] + an Arduino Uno from the frame?
So far I think I'll pick up 2 x [433Mhz RF Transmitter Module + Receiver Module Link Kit][2] for wireless control, [Reed Switch Magnetic Detection Sensor Module][3] for calculating velocity from a small magnet mounted somewhere on one of the forks. 4 x [WS2811 RGB 8-LED Light Strip Module][4] as the POV LED's, or maybe some of the [DotStar Digital LED][5]
and miscellaneously perhaps are some of these required/ useful? maybe instead of the 4x8 I could go 4x [SSC Seoul P4][6], or from [SparkFun][7],  following pieces of [this guide][8]

DIY AT89S52 Microcontroller Development Board Set
[KT0026 Electronic Parts Pack][9]
[Square Prototyping Plate][10]
[ZnDiy-BRY Z-069 MB102 Breadboard + Power Supply Module][11]

My main concern is refresh rates....getting everything controlled...and making sure I have enough I/O. Any help would be greatly appreciated.  (URL's available on request :P)


texts:
I am using Digispark ATTiny85 and i need to send and receive data through the serial port of my computer.
Does anyone have an idea as to how do i proceed with sending STRINGS and NUMBERS through the serial port ??

I have read that the ATTINY 85 does not have a serial port.
If that is the case is there any alternative ??


texts: Cannot get any readings from DHT22 Sensor connected to Arduino M0 Pro

texts:
I have directly connected a DHT22 to my Arduino M0 Pro. I have put a 10k Resistor across the Data & V+ of the sensor pinout. The data is connected to pin 5 and I have it connected to 3.3V output of Arduino.

I am just trying to see some readings from the sensor via the SerialUSB console. I have downloaded and unpacked the DHT libraries that I got on the Adafruit website/GitHub. As far as I know I have these libraries in the right directory - C:\Program Files (x86)\Arduino\libraries\DHT...
I also have installed the Adafruit Unified Sensor library on the IDE.

I am trying to use the Tester program that is provided, this compiles ok but the SerialUSB printout prints:

Failed to read from DHT sensor!
Failed to read from DHT sensor!
Failed to read from DHT sensor!

And so on...

I have tried another DHT22 sensor to no avail.

The only part of the code I have changed is the pin number and changed from Serial to SerialUSB.

Not sure if I have to change anything else? Or am I doing something really silly!

Here is the code:

// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain

#include "DHT.h"

#define DHTPIN 5     // what digital pin we're connected to

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11   // DHT 11
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

// Initialize DHT sensor.
// Note that older versions of this library took an optional third parameter to
// tweak the timings for faster processors.  This parameter is no longer needed
// as the current DHT reading algorithm adjusts itself to work on faster procs.
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  SerialUSB.begin(9600);
  SerialUSB.println("DHTxx test!");

  dht.begin();
}

void loop() {
  // Wait a few seconds between measurements.
  delay(2000);

  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  float f = dht.readTemperature(true);

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    SerialUSB.println("Failed to read from DHT sensor!");
    return;
  }

  // Compute heat index in Fahrenheit (the default)
  float hif = dht.computeHeatIndex(f, h);
  // Compute heat index in Celsius (isFahreheit = false)
  float hic = dht.computeHeatIndex(t, h, false);

  SerialUSB.print("Humidity: ");
  SerialUSB.print(h);
  SerialUSB.print(" %\t");
  SerialUSB.print("Temperature: ");
  SerialUSB.print(t);
  SerialUSB.print(" *C ");
  SerialUSB.print(f);
  SerialUSB.print(" *F\t");
  SerialUSB.print("Heat index: ");
  SerialUSB.print(hic);
  SerialUSB.print(" *C ");
  SerialUSB.print(hif);
  SerialUSB.println(" *F");
}


texts:
When trying to compile

#include <list>
std::list<byte> l = { 7, 5, 16, 8 };

in the Arduino IDE (with ATtinyCore for ATtiny4313), I get this message:

  error: list: No such file or directory
    #include <list>

How to use the standard C++ std::list with Arduino/ATtiny?


texts:
Picked up a YS-IRTM IR Transmitter/Receiver module to do some testing for a project. There's not a lot of details on it but eventually came across two very important sources:

Translated Module Datasheet: https://docplayer.net/101050357-Nec-infrared-codec-module-ver1-0-ys-irtm.html

Examples: https://forum.arduino.cc/index.php?topic=359707.msg2861077#msg2861077

I've been trying to get this working for a few days and so far haven't gotten anything. Need to reach out before I pull out whatever hair I have left.

BTW, new to this and may have easily missed something.

Wiring Diagram

Arduino Uno    YS-IRTM
5v          -> 5v
GND         -> GND
0 RX        -> TXD
1 TX        -> RXD

Code

int icb = 0;
SoftwareSerial ir_mod(0, 1);

void setup(){
  Serial.begin(115200);
  while(!Serial){}
  Serial.println("Setup IR Serial");
  ir_mod.begin(9600);
  while(!ir_mod){}
  Serial.println("IR Serial Ready");
}

void loop(){
  if(ir_mod.available() > 0){
    icb = ir_mod.read();
    Serial.print(" 0x");
    Serial.println(icb, HEX);
  }
}

Current Output

Setup IR Serial
IR Serial Ready

Nothing will happen if I try to interact with the Receiver with any IR Transmitter (like a TV/AC Remote) but if I disconnect and reconnect the power, I get " 0xFFFFFFFF". Then nothing.


texts: How to code 4 relays to go off in intervals and not in sequence?

texts:
Code :

//FOR AEROPONIC SYSTEM WITH ROOM TEMPERATURE AND HUMIDITY SENSOR
//AND 4 GROW CHAMBERS WITH DIFFERENT SPRAYING TIME

// RELAY CONTROL
#define RELAY1_PIN 2
#define RELAY2_PIN 3
#define RELAY3_PIN 4
#define RELAY4_PIN 5

//Libraries
#include <DHT.h>;

//Constants
#define DHTPIN 6
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

//Variables
int chk;
float hum;
float temp;

void setup()
{
    Serial.begin(9600);
    Serial.println("SENSOR RUNNING");
    dht.begin();

    pinMode(RELAY1_PIN, OUTPUT);
    pinMode(RELAY2_PIN, OUTPUT);
    pinMode(RELAY3_PIN, OUTPUT);
    pinMode(RELAY4_PIN, OUTPUT);
}

void loop()
{
    delay(2000);
    float h = dht.readHumidity();
    float t = dht.readTemperature();
    if (isnan(h) || isnan(t))
    {
        Serial.println("CONNECTION ERROR");
        return;
    }
    Serial.print("Humidity: ");
    Serial.print(h);
    Serial.print(" %\t");
    Serial.print("Temperature: ");
    Serial.print(t);
    Serial.print(" *C ");
    Serial.println(" ");
    delay(2*1000);
    {
        // FOR RELAY
        digitalWrite(RELAY1_PIN, HIGH);
        delay(2*1000); // wait for 2 second ON
        digitalWrite(RELAY2_PIN, HIGH);
        delay(3*1000); // wait for 3 second ON
        digitalWrite(RELAY3_PIN, HIGH);
        delay(4*1000); // wait for 4 second ON
        digitalWrite(RELAY4_PIN, HIGH);
        delay(5*1000); // wait for 5 second ON

        digitalWrite(RELAY1_PIN, LOW);
        digitalWrite(RELAY2_PIN, LOW);
        digitalWrite(RELAY3_PIN, LOW);
        digitalWrite(RELAY4_PIN, LOW);
        delay(5*60*1000);
    }
}

This code doesn't do what I want. How do I make them independent?


texts:
Update:

Here is my first try based on the code I found and it did not work.
The first time I uploaded it, it move to the "current positional value". But did not do the void loop part. Just holds the positions.

Thanks.

    //Includes
    #include <Servo.h>

    //Defines
    #define LINEAR_1_100PIN 11        //Linear Actuator Digital Pin
    #define LINEAR_2_100PIN 6      //Linear Actuator Digital Pin

    String msg;

    //max/min pulse values in microseconds for the linear actuators
    #define LINEAR_1_100_MIN      1050  //
    #define LINEAR_1_100_MAX      2000 //
    #define LINEAR_2_100_MIN  1050     //
    #define LINEAR_2_100_MAX  2000    //

    Servo LINEAR_1_100, LINEAR_2_100;  // create servo objects to control the linear actuators
    //int knobValue, sliderValue;  //variables to hold the last reading from the analog pins

    int linear100Value_1 = 1051;   //current positional value being sent to the linear actuator.
    int linear100Value_2 = 1051;  //current positional value being sent to the linear actuator.

    int speed = 10;

    void setup()
    {
      //initialize servos
      LINEAR_1_100.attach(LINEAR_1_100PIN, LINEAR_1_100_MIN, LINEAR_1_100_MAX);      // attaches/activates the linear actuator as a servo object
      LINEAR_2_100.attach(LINEAR_2_100PIN, LINEAR_2_100_MIN, LINEAR_2_100_MAX);  // attaches/activates the linear actuator as a servo object

      //Analog pins do not need to be initialized

      //use the writeMicroseconds to set the linear actuators to their default positions
      LINEAR_1_100.writeMicroseconds(linear100Value_1);
      LINEAR_2_100.writeMicroseconds(linear100Value_2);
    }

    void loop()
    {
   LINEAR_1_100.write(90);
   delay(1000);
   LINEAR_1_100.write(0);
   delay(1000);
   LINEAR_2_100.write(90);
   delay(1000);
   LINEAR_2_100.write(0);
   delay(1000);
    }

Old Question:

I am trying to make the code described in this tutorial:

http://learn.robotgeek.com/demo-code/118-arduino-linear-actuator-tutorial-analog-direct-control-of-small-linear-actuator.html

https://github.com/robotgeek/firgelliDirectControl/blob/master/firgelliDirectControl/firgelliDirectControl.ino

work with PWM from an Arduino, without the additional board.

So far the Arduino Examples>Servo>Sweep works as I would like to achieve it (delay changed to 30 ms) but very slowly and it does not seem to just go 180 steps out wait 30 ms and 180 steps in again. It sometimes moves twice in one direction. If I change the steps from 1 to 5 the servo does not move anymore (I expected it to go faster).

With the code above I understand I can control the servo with a Knob or Slider, but I would like to understand how I can control this Linear Actuator Servo with PWM from an Arduino PMW Pin (e.g. 11) and change the speed. Finally I would like to make the Servo consistently go x amount of steps out, wait for x ms and the same amount back in again.

Most importantly I would like to make sure it always ends at position 0, and that it does not accumulate errors.

Thank you for any help.


texts: Unexpected output for simple code involving calculating a time interval of 10ms

texts:
I had written some code that involved doing something after 10 milliseconds had elapsed, however it was performing unexpectedly. Upon debugging, I think I have identified the error, and I wrote some code with just that block:
unsigned long int newtime=0;
unsigned long int prevtime=0;
int time;
void setup()
{
  Serial.begin(9600);
}

void loop()
{
newtime=millis();
time=newtime-prevtime;
if(time==10){
  Serial.println(prevtime);
  prevtime+=10;
}

}

The serial monitor "freezes on 150. it shows the values 0,10,20...as expected but it freezes on 150...and then nothing happens.
What exactly is causing this?


texts:
My son just did the Love-o-meter project in the Arduino Start Kit. However, the sensor readings of the LM35 temperature control vary widely. Below is a sample. What could be wrong?

Sensor Value: 217, Volts: 1.06, degrees C: 105.96
Sensor Value: 587, Volts: 2.87, degrees C: 286.62
Sensor Value: 125, Volts: 0.61, degrees C: 61.04
Sensor Value: 320, Volts: 1.56, degrees C: 156.25
Sensor Value: 445, Volts: 2.17, degrees C: 217.29
Sensor Value: 141, Volts: 0.69, degrees C: 68.85
Sensor Value: 510, Volts: 2.49, degrees C: 249.02
Sensor Value: 247, Volts: 1.21, degrees C: 120.61
Sensor Value: 168, Volts: 0.82, degrees C: 82.03
Sensor Value: 595, Volts: 2.91, degrees C: 290.53
Sensor Value: 125, Volts: 0.61, degrees C: 61.04
Sensor Value: 206, Volts: 1.01, degrees C: 100.59
Sensor Value: 606, Volts: 2.96, degrees C: 295.90
Sensor Value: 125, Volts: 0.61, degrees C: 61.04
Sensor Value: 290, Volts: 1.42, degrees C: 141.60
Sensor Value: 487, Volts: 2.38, degrees C: 237.79

Here's the code:

const int sensorPin = A0;
const float baselineTemp = 25.0;

void setup(){
  Serial.begin(9600); // open a serial port
  for(int pinNumber = 2; pinNumber<5; pinNumber++){
    pinMode(pinNumber,OUTPUT);
    digitalWrite(pinNumber, LOW);
  }
}

void loop(){
  int sensorVal = analogRead(sensorPin);
  Serial.print("Sensor Value: ");
  Serial.print(sensorVal);
  // convert the ADC reading to voltage
  float voltage = (sensorVal/1024.0) * 5.0;
  Serial.print(", Volts: ");
  Serial.print(voltage);
  Serial.print(", degrees C: ");
  // convert the voltage to temperature in degrees
  float temperature = (voltage) * 100;
  Serial.println(temperature);

  if(temperature < baselineTemp){
    digitalWrite(1, LOW);
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
  }else if(temperature >= baselineTemp+2 &&
    temperature < baselineTemp+4){
    digitalWrite(1, HIGH);
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
  }else if(temperature >= baselineTemp+4 &&
    temperature < baselineTemp+6){
    digitalWrite(1, HIGH);
    digitalWrite(2, HIGH);
    digitalWrite(3, LOW);
  }else if(temperature >= baselineTemp+6){
    digitalWrite(1, HIGH);
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
  }
  delay(1);
}

The GND is connected to the left most connector in the LM35, the A0 to the middle, and the power to the right most connector.


texts: Is it safe to connect VCC to a data pin on Attiny chips?

texts: I'm trying to make a compact prototype with Attiny2313A, and want to connect VCC to pin 18 with a push button as in the picture. Is it safe? Or do I need a resistor there?


texts: I have been using my arduino uno for many months and it worked very well even till today morning but an hour ago I tried to upload a sketch and arduino IDE showed my this "avrdude: stk500_getsysc(): not in sync: resp =0x00" , at first I thought maybe I burned my atmega32 chip but I bypassed reset and gnd with a jumper wire and opened serial monitor and my atmega32 still printing serial data,so problem must be something else,and also my led13 isn't blinking.Is it problem with bootloader?if so how can I reload bootloader in my board without using another arduino?


texts:
the function write in nrf24LO1 (without antenna) works perfectly
but in nrf24LO1 (with antenna) not works. why?!
the code

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <printf.h>

 RF24 radio(7,8);
 const byte address[6] = "00001";
void setup() {
  radio.begin();
  radio.setDataRate(RF24_250KBPS);
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_HIGH);
  radio.setCRCLength(RF24_CRC_8);
  radio.stopListening();
  Serial.begin(9600);
}

void loop() {
  const char text[] = "example";
  if(radio.write(&text,sizeof(text))) //<==problem here
    Serial.println("ok");
  Serial.println(text);
  delay(1000);
}

nrf24l01 with antenna :

nrf24l01 without antenna :


texts:
I am trying to run this code:
https://github.com/miguelbalboa/rfid/blob/master/examples/ReadNUID/ReadNUID.ino

Using an ESP8266 based D1 board and an RFID-RC522.

I am not able to get it to detect the rfid tags ...
the serial monitor just shows:

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

wdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v00000000
~ld

The "Typical pin layout used" section of the above document does not mention any connections on the 3.3V & GND pins of the RFID-RC522 card.

Does this mean that I do not need to connect them?
Or is is just so obvious that I should connect them that they did not bother to write it in that section?


texts:
I have two Lidar Lites, connected to one APM. I have no issue with getting data from one of them, i use the code below

#include <I2C.h>
#define    LIDARLite_ADDRESS   0x62          // Default I2C Address of LIDAR-Lite.
#define    RegisterMeasure     0x00          // Register to write to initiate ranging.
#define    MeasureValue        0x04          // Value to initiate ranging.
#define    RegisterHighLowB    0x8f          // Register to get both High and Low bytes in 1 call.

void setup(){
  Serial.begin(9600); //Opens serial connection at 9600bps.
  I2c.begin(); // Opens & joins the irc bus as master
  delay(100); // Waits to make sure everything is powered up before    sending or receiving data
  I2c.timeOut(50); // Sets a timeout to ensure no locking up of sketch if I2C communication fails
}

void loop(){
 // Write 0x04 to register 0x00
  uint8_t nackack = 100; // Setup variable to hold ACK/NACK resopnses
  while (nackack != 0){ // While NACK keep going (i.e. continue     polling until sucess message (ACK) is received )
    nackack = I2c.write(LIDARLite_ADDRESS,RegisterMeasure, MeasureValue); // Write 0x04 to 0x00
    delay(1); // Wait 1 ms to prevent overpolling
  }

  byte distanceArray[2]; // array to store distance bytes from read function

  // Read 2byte distance from register 0x8f
  nackack = 100; // Setup variable to hold ACK/NACK resopnses
  while (nackack != 0){ // While NACK keep going (i.e. continue polling until sucess message (ACK) is received )
    nackack = I2c.read(LIDARLite_ADDRESS,RegisterHighLowB, 2, distanceArray); // Read 2 Bytes from LIDAR-Lite Address and store in    array
   delay(1); // Wait 1 ms to prevent overpolling
  }
  int distance = (distanceArray[0] << 8) + distanceArray[1];  // Shift high byte [0] 8 to the left and add low byte [1] to create 16-bit int

  // Print Distance
  Serial.println(distance);
}

i can get the distance fine, now have two connected, as follows

So my noob question is how to i get data from the 2, my guess is the wiring is ok.

I am using the code from https://github.com/PulsedLight3D/LIDARLite_v2_Arduino_Library

any help would be appreciated. thanks.


texts:
Greetings dear reader!

I have some trouble storing my IMEI code inside a variable. It always returns an error: "void value not ignored as it ought to be".

Since then I tried to write it to the serial line by just running the gsm.SimpleWriteln("AT+GSN"); AT command, but I am stuck at storing this displayed value inside a variable. Does anyone here know a way to store a serial value into a variable? I just want to send the IMEI code as an identifier to the cloud application...

Thanks in advance, your response is really appreciated.

The code:

#include "SIM900.h"
#include <SoftwareSerial.h>
//#include "inetGSM.h"
//#include "sms.h"
//#include "call.h"

//To change pins for Software Serial, use the two lines in GSM.cpp.

//GSM Shield for Arduino
//www.open-electronics.org
//this code is based on the example of Arduino Labs.

//Simple sketch to communicate with SIM900 through AT commands.

//InetGSM inet;
//CallGSM call;
//SMSGSM sms;

int numdata;
char inSerial[40];
int i=0;
boolean startUp = false;

void setup() {
  Serial.begin(9600);
  Serial.println("GSM Shield testing.");

  //Start configuration of shield with baudrate.
  //For http uses it is recommended to use 4800 or slower.
  if (gsm.begin(9600)) {
    Serial.println("\nstatus=READY");
    getIMEI();
  } else Serial.println("\nstatus=IDLE");
};

void loop() {
  //Read for new byte on serial hardware,
  //and write them on NewSoftSerial.
  serialhwread();
  //Read for new byte on NewSoftSerial.
  serialswread();
};

void serialhwread() {
  i=0;
  if (Serial.available() > 0) {
    while (Serial.available() > 0) {
      inSerial[i]=(Serial.read());
      delay(10);
      i++;
    }
    inSerial[i]='\0';
    if(!strcmp(inSerial,"/END")) {
      Serial.println("_");
      inSerial[0]=0x1a;
      inSerial[1]='\0';
      gsm.SimpleWriteln(inSerial);
    }
    //Send a saved AT command using serial port.
    if(!strcmp(inSerial,"TEST")) {
      Serial.println("SIGNAL QUALITY");
      gsm.SimpleWriteln("AT+CSQ");
    } else {
      Serial.println(inSerial);
      gsm.SimpleWriteln(inSerial);
    }
    inSerial[0]='\0';
  }
}

void serialswread() {
  gsm.SimpleRead();
}

void getIMEI() {
  long IMEI = gsm.SimpleWriteln("AT+GSN"); // IMEI code
  Serial.println(IMEI);
  return IMEI
}


texts: References (e.g, libraries and tutorials) for connecting the 24-bit ADS1256 ADC to arduino

texts:
The ADS1256 chip is a high precision 24bit, 8 channel, analog digital converter based on SPI communication that is suitable for biomedical applications and perfect for sensing ECG and EEG signals. I want to hook it up to an arduino, e.g., an arduino mega or an arduino due.

Similar ADCs from analog devices are: ADS1248, ADS1251, ADS1252, ADS1252U, ADS1253, ADS1255, ADS1259, ADS1278, ADS1298, ADS1299, etc.

It’s nice that there are [tiny, coin sized breakout boards]  available for the ADS1256 that include basic components like an 8mhz quartz crystal and cost only around 25 USD.

Several people have in the past struggled to get ADC readings using Arduino. Working only with the data sheet it took them several days or even weeks. I have a logic analyzer, multi channel oscilloscope and bus pirate ready, but I still would prefer adapting an existing library or working with a good tutorial as a starting point.

I searched for code and tutorial not only for the ADS1256 but also for similar analog devices ADC chips.

Here are the tutorials, libraries and information I found so far:

Main Links (working solution):

-- ADS1213 Arduino library (seems to be working!!!)

--  ADS1213 Arduino tutorial (includes above library)

Further Information:

Arduino due ADS129X tools(ADS1299, ADS1298, ADS1294, ADS1296)
ADS1252 Arduino Tutorial
ADS1252 Troubleshooting information
ADS1255 Troubleshooting information
ADS 1298 Troubleshooting information
ADS 1248 and arduino (german)

Q:
Is there a working library for the ADS1256 (or similar chip) and is there a current, up-to-date tutorial available for arduino?

(Update with my notes.)

Next steps (to get a working library that should be put on github):

Search for more relevant Information online (existing libraries, etc.)
Ask in AVR specific forum, if question is unanswered here. Possibly contact people via e-mail that could know more
Get familiar with Chip and Datasheet
Decide on available codebase as the starting point
Define the minimalistic testcase (This would check that some for of communication works with the chip, i.e., write register that changes the logic level of a bin of the ADC chip)
Implement the minimalistic testcase (i.e., possibly use different codebase as starting point if it fails to implement)
Expand and test the code to get a full implementation

Risks: Eittle experience with electronic design the microcontroller at hand, might miss important details that costs a lot of time. Can't be sure that my chip/PCB actually works, can be faulty hardware.

Time Estimate: 3 days of work doing 8 hours a day (total 24 hours). Exremly high variance (could be a matter of a few hours in the best case to a few weeks worst case).


texts: Disassembling a RC car for a Arduino Robot

texts: I am looking at making an Arduino robot car. I have a RC car( photos below). I was wondering if I could take the chassis of the car and modify it to make it Arduino controlled, if so how could I do that?(I have an Arduino UNO R3). I would like to make it into a wall avoiding robot. I have never soldered a thing in my life, and I don't own a soldering iron.


texts: How to create a heart rate detection system that uses a chest strap?

texts:
I want to create a system that uses a chest strap from available Bluetooth-based heart rate monitoring systems. The straps seem very convenient compared to available Arduino pulse detection systems that use electrode pads (which must be placed individually and that wear out), or infrared sensors, which are cumbersome.

I find the Bluetooth systems not super reliable and would like to use the strap with a wired Arduino based system. Is it possible and if so how?


texts: WiFiClient.connect() does fail all the time (ESP8266 Core for Arduino)

texts:
I have one ESP(1) opening an AP and running a server on it. The other ESP(2) is running a client on it and is connecting to the AP and after that trying to connect to the host server. The connection to the AP does succeed but the connection to the host always fails and I cannot figure out what the problem is here. Testing the server via netcat and packetsender works fine. Connecting to it via telnet fails because the connections gets closed by the "foreign host".

Server Sketch

#include <ESP8266WiFi.h>

const char* ssid = "artex11";
const char* pw = "getmenow11";
WiFiServer server(80);
WiFiClient client;

void setup() {
  Serial.begin(115200);
  //setup AP
  WiFi.softAP(ssid, pw);
  Serial.println("AP started at: ");
  Serial.print(WiFi.softAPIP());
  server.begin();
  Serial.println("Server started...");
}

void loop() {
  client = server.available();

  if(client){
    Serial.println("Client connected!");
    Serial.print("HasClient: ");
    Serial.println(server.hasClient());
    char message = client.read();
    Serial.printf("Message: %c\n", message);
  }
}

Client Sketch

#include <ESP8266WiFi.h>

const char* ssid = "artex11";
const char* pw = "getmenow11";
const char* host = "192.168.4.1";
const int port = 80;

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, pw);
  Serial.println("Connecting to AP");
  while(WiFi.status() != WL_CONNECTED){
    delay(500);
    Serial.print(".");
   }
  Serial.println(" connected");
}

void loop() {
  WiFiClient client;
  Serial.println("Connecting to host");
  if(!client.connect(host, port)){
    Serial.println("...connection failed!");
    Serial.println("Retrying in 5 seconds...");
    delay(5000);
    return;
  }
  client.print("A");
  Serial.println("...TCP message fired!");
  delay(2000);
}


texts: Using servos in voltage sensitive circuit

texts:
I'm currently using a breadboard Arduino Uno clone.  Basically a Atmega328p powered using an L7805 linear regulator with a 10uF capacitor on both the input and output.  The Atmega328p is connected with a 433Mhz receiver (WL101-541) and two SG90 servos (PWM pins).  Basically the signal from the receiver is used to control the servos. The servos need to be driven by 5V(4.8V) as well so their power and ground come from the L7805 as well.

I have encountered a situation where the receiver stops functioning when the servos are under load. I suspect that it is very sensitive to the input voltage and the additional load on the L7805 from the servos causes a slight drop in the voltage.

I have temporarily worked around this by adding a second L7805 and attached the servo power to it.  Both L7805 are attached to the same battery.  So input voltage will start around 9V then drop to maybe 6.5 or 7 over time.

The circuit power will be a standard 9V battery (perhaps a lithium) as I have weight considerations and am only aiming for around 1.5 hr of runtime.

1) I am looking for information on why one L7805 does not cut it as I believe it is rated for providing up to 1 amp, and the entire circuit appears to be drawing around 0.2A at the time the servos are under load and the receiver is not functioning.

2) Am I missing something, can the circuit be improved? Perhaps through changing capacitors or their placement.


texts:
I just started using elegoo UNO R3 and I have the problem displaying different numbers on the segment display using the 74Hc595. I have no problem with the uploads and the circuits are working fine. However, the segment  doesn't display any numbers besides 8. Is there a problem with the code or the wiring? any suggestion?

byte seven_seg_digits[10] = { B11111100,  // = 0
                          B01100000,  // = 1
                          B11011010,  // = 2
                          B11110010,  // = 3
                          B01100110,  // = 4
                          B10110110,  // = 5
                          B10111110,  // = 6
                          B11100000,  // = 7
                          B11111110,  // = 8
                          B11100110   // = 9
                         };
// connect to the ST_CP of 74HC595 (pin 3,latch pin)
int latchPin = 3;
// connect to the SH_CP of 74HC595 (pin 4, clock pin)
int clockPin = 4;
// connect to the DS of 74HC595 (pin 2)
int dataPin = 2;

 void setup() {
  // Set latchPin, clockPin, dataPin as output
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}

// display a number on the digital segment display
void sevenSegWrite(byte digit) {
  // set the latchPin to low potential, before sending data
  digitalWrite(latchPin, LOW);

  // the original data (bit pattern)
  shiftOut(dataPin, clockPin, LSBFIRST, seven_seg_digits[digit]);

  // set the latchPin to high potential, after sending data
  digitalWrite(latchPin, HIGH);
}
   }

void loop() {
  // count from 9 to 0
  for (byte digit = 10; digit > 0; --digit) {
    delay(0);
    sevenSegWrite(digit - 1);
  }

  // suspend 4 seconds
  delay(0);
}

here is my circuit and the tutorial diagram:


texts: Whatever components we connect to the Arduino, their grounds and 5v pin connection must be the same?

texts: I am trying to connect different types of sensors & motors to the Arduino should I make their grounds and 5v pins on the same connection.