texts: Why I am connecting positive wire in the circuit?

texts: I have constructed a simple fade in and fade out circuit similar to given on this website https://roboindia.com/tutorials/arduino-analog-output-led-fade Now I am connecting a wire from 5V power pins to +ve side line, but i don't know why I am doing this because when I remove this wire or connect it to 3.5V pin the led is still running fine. Also as side lines are connected horizontally there is no other further connection given to the +ve wire. Can you tell me why I am joining the wire?


texts:
I want to build a program which identifies logic gates connected to Arduino, by testing the output with changing the input voltage...

Here is the code:

int output1 = 0;   //Change output pins HERE
int output2 = 1;   //and HERE
int input = 2;     //Change the input pin HERE, where we will read the data (0 or 1)

void setup() {
  pinMode(output1, OUTPUT);
  pinMode(output2, OUTPUT);
  pinMode(input, INPUT);
  Serial.begin(9600);  // Start serial communication at 9600 bps
}

void loop() {
  int result[12];
  for(int i = 0; i < 2; i++) // For failure test, it runs 3 times
  {
    digitalWrite(output1, LOW);
    digitalWrite(output2, LOW);
    delay(1000);             //Wait for 1sec
    result[i * 4] = digitalRead(input);
    digitalWrite(output1, LOW);
    digitalWrite(output2, HIGH);
    delay(1000);             //Wait for 1sec
    result[i * 4 + 1] = digitalRead(input);
    digitalWrite(output1, HIGH);
    digitalWrite(output2, LOW);
    delay(1000);             //Wait for 1sec
    result[i * 4 + 2] = digitalRead(input);
    digitalWrite(output1, HIGH);
    digitalWrite(output2, HIGH);
    delay(1000);             //Wait for 1sec
    result[i * 4 + 3] = digitalRead(input);
  }
  if(result[0] != result[4] && result[0] != result[8] && result[1] != result[5] && result[1] != result[9] && result[2] != result[6] && result[2] != result[10] && result[3] != result[7] && result[3] != result[11]) // See if the results don't matches...
  {
    Serial.println("Input read error, please try again!");
  }
  if(result[0] == 0 && result[1] == 0 && result[2] == 0 && result[3] == 1) // AND gate
  {
    Serial.println("This is an AND gate");
  }
  else if(result[0] == 0 && result[1] == 1 && result[2] == 1 && result[3] == 1) // OR gate
  {
    Serial.println("This is an OR gate");
  }
  else if(result[0] == 1 && result[1] == 1 && result[2] == 1 && result[3] == 0) // NAND gate
  {
    Serial.println("This is a NAND gate");
  }
   else if(result[0] == 1 && result[1] == 0 && result[2] == 0 && result[3] == 0) // NOR gate
  {
    Serial.println("This is an NOR gate");
  }
  else if(result[0] == 0 && result[1] == 1 && result[2] == 1 && result[3] == 0) // EXOR gate
  {
    Serial.println("This is an EXOR gate");
  }
  else if(result[0] == 1 && result[1] == 0 && result[2] == 0 && result[3] == 1) // EXNOR gate
  {
    Serial.println("This is an EXNOR gate");
  }
  else // If there is no match...
  {
    Serial.println("This is not even a gate");
  }
}

It always gives back 1s... I have tested with leds, it works perfectly by changing the input, but as soon as serial.begin is declared in setup, it fails to work, the just stays on and I said, the program just gives back 1s.

What I'm missing?

Thanks!


texts: Why am I only receiving the first address byte? (I2C Protocol)

texts:
Expecting the slave to ACKnowledge and return data, but it does not. This is my protocol. This is my Datasheet.

Also FYI I'm on an Arduino Fio but I am not inheriting the Arduino library.

#include <avr/io.h>
#include <util/delay.h>
#include <stdlib.h>
#include <uart.h>
#include <i2c_master.h>

#define LED PB5

#define I2C_READ 0x5A

char buffer[1];

//char data[9];
uint16_t val = 0;
uint8_t status = 0;

void getVal()
{
  if(i2c_start(I2C_READ))
    {
        uart_puts("Start ");

        val = ((uint8_t)i2c_read_ack())<<8;
        val |= i2c_read_ack();

    status = ((uint8_t)i2c_read_nack());

      i2c_stop();

    } else
  {
        uart_puts("Error");

        i2c_stop();
    }
}

int main(void)
{
  init_uart(57600);
  i2c_init();

  DDRB = _BV(5);

    for(;;)
    {

      getVal();

            itoa(status, buffer, 10); //convert decimal to string base 10
            uart_puts(buffer);

      PORTB = 0xFF;
      _delay_ms(500);
      PORTB = 0x00;
      _delay_ms(500);
    }
    return 0;   /* never reached */
}


texts: Can I use arduino to generate 8mhz frequency ultrasonic pulses in piezo discs?

texts:
void setup()
{
    pinMode(freqOutputPin, OUTPUT);
    Serial.begin(9600);

    // Set Timer 2 CTC mode with no prescaling.  OC2A toggles on compare match
    //
    // WGM22:0 = 010: CTC Mode, toggle OC
    // WGM2 bits 1 and 0 are in TCCR2A,
    // WGM2 bit 2 is in TCCR2B
    // COM2A0 sets OC2A (arduino pin 11 on Uno or Duemilanove) to toggle on compare match
    //
    TCCR2A = ((1 << WGM21) | (1 << COM2A0));

    // Set Timer 2  No prescaling  (i.e. prescale division = 1)
    //
    // CS22:0 = 001: Use CPU clock with no prescaling
    // CS2 bits 2:0 are all in TCCR2B
    TCCR2B = (1 << CS20);

    // Make sure Compare-match register A interrupt for timer2 is disabled
    TIMSK2 = 0;
    // This value determines the output frequency
    OCR2A = ocr2aval;

    Serial.print("Period    = ");
    Serial.print(period);
    Serial.println(" microseconds");
    Serial.print("Frequency = ");
    Serial.print(freq);
    Serial.println(" Hz");
}

void loop(){}

I am working on a project where i need an ultrasonic pulse of 8Mhz every one second and emitter is piezo disc. Please help me with the code.


texts:
I have a Arduino Uno and a CC3000 shield. When I run the example code for Webclient from Adafruits libary it works perfect.

When I switch out address for reading a corresponding text file from my own server the code completes sporadically. The output in the serial window stops at differens places every time.

Does anyone have any idea how I can fix this?

The Adafruit points to this URL: http://www.adafruit.com/testwifi/index.html
While mine points to this URL: http://a.sjsd.li/test/test.html


texts: Arduino Standalone - photo shows incorrect pin wired to MOSI

texts:
I have been building a standalone Arduino on a breadboard following the guide, Building an Arduino on a Breadboard. The guide is generally very good, however, I have yet to get the Arduino working, for a number of various reasons, be it misinterpreted, or misread instructions (the reset pull-up resistor connected to GND instead of Vcc, Tx to Tx, instead of Tx to Rx (and vice versa), to name but a few issues that I have had to resolve).  However, I am sure that the following issue is not down to my careless interpretation or lack of attention.

Look at the photo taken from the webpage, Building an Arduino on a Breadboard, on the Arduino website, showing the Sparkfun AVR programming adapter connected to the ATmega IC.

The MOSI on the adapter is shown to be connected, via a dark green wire, to pin 16 on the ATmega chip, whereas the instructions say:

  Be sure to refer to the Arduino pin mapping for help wiring this up.

  The MISO pin of your adapter will go to pin 18 or Arduino digital pin    12 of your Atmega chip.
  The SCK pin of your adapter will go to pin 19 or Arduino digital pin    13 of your Atmega chip.
  The RESET pin of your adapter will go to pin 1 of your Atmega chip.
  The MOSI pin of your adapter will go to pin 17 or Arduino digital pin    11 of your Atmega chip.

According to the pinout below, Pin 16 is SS and pin 17 is indeed MOSI.

So, to my mind, the photo is definitely wrong. Indeed I was getting avrdude errors when trying to use a USBasp to load a bootloader, when using the wiring as shown in the photo. When I correctly wired MOSI, from the adapter, to pin 17, the avrdude errors disappeared.

Am I correct in my thinking? Has anyone else attempted to build this circuit, following the instructions on the Arduino website, and come across this issue?

I am just looking for confirmation that I am right, before I contact the owner of the web page.


texts:
I'm quite new to Arduino. I have build a number of projects successfully, like potentiometers, serial communication, DAC, sensors, motors etc.

I use a laptop to power my Arduino project and Atmel Studio to program and upload to the Arduino. I have created a project with 2 motors and I have successfully used a separate power supply (a transformer) to power the motors.

Now I want to continue my experiments but I'm afraid of the possibility to cause any problem to my laptop.

When I made the circuit with the 2 power sources (laptop for the Arduino, transformer for the motors) I had to connect the 2 grounds together.

So my question is that:

Can someone explain me or point me to some information about power electronics so to be absolutely sure that I won't cause any problem to the laptop?

Should I use optocouplers, or diodes etc? Is there a way to avoid the 2 grounds connection? What is the reason to connect both grounds (of the 2 power supplies) in the first place?


texts: Digispark / Digikeyboard code doesn't execute inside setup{}

texts:
Here's sample code to demonstrate my problem:

#include <DigiKeyboard.h>

void setup() {
  // put your setup code here, to run once:
  delay(5000);
  DigiKeyboard.print("TESTING TESTING");
  pinMode(1,OUTPUT);
  digitalWrite(1,HIGH);
}

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

My problem is that I can't get Digikeyboard.print() or other Digikeyboard commands (e.g. sendKeyStroke()) to do anything while they are located inside the setup function. The led command after the print command executes properly.

The print command will work if I place it inside the loop function. However, I want to only execute this code once.

Any assistance would be appreciated, and I would be happy to provide more information if necessary.

EDIT: I worked around this by using a if-expression inside the loop function to only run the code once. However, I am still interested in learning why my original code doesn't work.


texts: How can I use GPIO pins on an esp12e UART?

texts:
I've bought an esp12e UART that unfortunately had some issues, but I was able to fix them.

This is how I connected it to the arduino. With this setup, I was able to host a simple web server and it worked, the code uploaded and everything worked fine as it should. However, then I tried to make it light the led up by declaring it as on pin 13, but it didn't work, so I don't really know how should I declare my pins for the code to work as it should. By the way, the board is selected as nodemcu 1.0 (esp-12e module) in the arduino IDE if that helps. Thank you in advance


texts: Problems with transmission between ATtiny85 and Arduino Uno with 433MHz RF modules and Manchester

texts:
I am trying to transmit from an ATtiny85 running at 16MHz internal clock to an Arduino Uno with the Manchester Library.

The problem is that the Arduino is not receiving any data.

I have hooked an oscilloscope to the ATAD/DATA pin of the transmitter, and I can see data being transmitted. I have also done the same thing on the DATA pin of the receiver, and it shows data being received. But the Arduino Uno is not detecting anything.

I have tried having an Arduino Uno sending data to itself, which does work, but the data gets dropped very often.

Here is the source code of the transmitter:

#include <Manchester.h>

#define TX_PIN 3  //pin where your transmitter is connected

uint16_t transmit_data = 2761;

void setup() {
  pinMode(1,OUTPUT);
 man.setupTransmit(TX_PIN, MAN_1200);
}

void loop() {
  digitalWrite(1,HIGH);
  man.transmit(transmit_data);
  delay(200);
  digitalWrite(1,LOW);
  delay(200);
}

And this is the code on the receiver:

#include "Manchester.h"

#define RX_PIN 4
#define BUFFER_SIZE 22

uint8_t buffer[BUFFER_SIZE];

void setup() {
  Serial.begin(9600);
  man.setupReceive(RX_PIN, MAN_1200);
  man.beginReceiveArray(BUFFER_SIZE, buffer);
}

void loop() {
  if (man.receiveComplete()) {
    uint8_t receivedSize = 0;
    // do something with the data in 'buffer' here before you start receiving to the same buffer again
    receivedSize = buffer[0];
    for(uint8_t i=1; i<receivedSize; i++)
      Serial.write(buffer[i]);
    Serial.println();
    man.beginReceiveArray(BUFFER_SIZE, buffer);
  }
}

This is the code I used to test with only the Arduino Uno:

#include <Manchester.h>

#define RX_PIN 7
#define TX_PIN 8  //pin where your transmitter is connected

uint16_t transmit_data = 2761;
int lastTransmit = 0;

void setup() {
  Serial.begin(9600);
  man.setupReceive(RX_PIN, MAN_1200);
  man.setupTransmit(TX_PIN, MAN_1200);
  man.beginReceive();
}

void loop() {
  if (millis() - lastTransmit > 200) {
    man.transmit(transmit_data);
    lastTransmit = millis();
  }

  if (man.receiveComplete()) {
    uint16_t m = man.getMessage();
    Serial.println(m);
    man.beginReceive();
    //start listening for next message right after you retrieve the message
  }
}


texts:
I believe PROGMEM is used to store large data (e.g. strings) that don't change. So it frees up the SRAM.

in the Ardunio Reference it is mentioned that.

"Using PROGMEM is also a two-step procedure. After getting the data into Flash memory, it requires special methods (functions), also defined in the pgmspace.h library, to read the data from program memory back into SRAM, so we can do something useful with it."

If I have to load the data into SRAM before using it then how is it efficient than directly stroing into SRAM by defining vaiable normally


texts:
I'm looking for the Library of the ADC MCP33121 for Arduino UNO or functional code, I don't have enough tools for testing so I'd like to get some code already tested.
I appreciate any help.
Thanks... Josh


texts: Get data from website with ESP8266 AT commands

texts:
I have a big problem.
When I use the following code, at the time of reply (+IPD) I do not receive the full answer along with the text in the file or text in echo (php file) or text in json file.
How can I solve my problem?

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX,TX

#define DEBUG true

String mySSID = "*****";  // WiFi SSID
String myPWD = "*******"; // WiFi Password
String myHOST = "iothomeviewer.ir";
String myPORT = "80";

void setup()
{
  Serial.begin(115200); // communication with the host computer
  mySerial.begin(115200);
  Serial.println("");
  Serial.println("Remember to to set Both NL & CR in the serial monitor.");
  Serial.println("Ready");
  Serial.println("");

  espData("AT+RST", 1000, DEBUG);      // Reset the ESP8266 module
  espData("AT+CWMODE=1", 1000, DEBUG); // Set the ESP mode as station mode
  espData("AT+CWJAP=\"" + mySSID + "\",\"" + myPWD + "\"", 1000,
          DEBUG); // Connect to WiFi network

  delay(1000);
}

void loop()
{

  String sendData
      = "GET /ali.txt HTTP/1.1\r\nHost: iothomeviewer.ir\r\nContent-Type: "
        "text/html\r\nConnection: close\r\n\r\n";

  // OR     String sendData ="GET /light.json HTTP/1.1\r\nHost:
  // iothomeviewer.ir\r\nContent-Type: text/html\r\nConnection: close\r\n\r\n";

  espData("AT+CIPMUX=1", 1000, DEBUG); // Allow multiple connections
  espData("AT+CIPSTART=4,\"TCP\",\"" + myHOST + "\"," + myPORT, 1000, DEBUG);
  espData("AT+CIPSEND=4," + String(sendData.length() + 4), 1000, DEBUG);
  espData(sendData, 7000, DEBUG);

  while (!mySerial.readStringUntil("IPD")) {
    delay(500);
  }
  delay(1000);

  while (mySerial.available()) {
    String c = mySerial.readString();
    Serial.println(c);
  }
  delay(1000);

  espData("AT+CIPCLOSE=4", 1000, DEBUG);
  delay(12000);
}

String espData(String command, const int timeout, boolean debug)
{
  Serial.println("     ");
  Serial.print("AT Command ==> ");
  Serial.print(command);
  Serial.println("     ");

  String response = "";
  mySerial.println(command);

  long int time = millis();

  while ((time + timeout) > millis()) {
    while (mySerial.available()) {
      char c = mySerial.read();
      response += c;
    }
  }

  if (debug) {
    Serial.print(response);
  }

  return response;
}


texts: 3.95 MCU Friend Arduino TFT LCD flickering

texts:
I got the 3.95" LCD from aliexpress which uses IL9488. I used the MCUFRIEND_kbv library. I am using an Arduino Mega as I need other GPIO to be used for other purposes. I can't use the Uno because of this limitation.

I have other modules like the DS3231, and ESP8266 connected to the Mega and this 3.95" LCD connected as well. ESP8266 is powered separately using a 12-5V converted supply. The Mega is powered using another source. The normal graphics test is working in the LCD. I am able to make it work with the Nano, Uno and Mega. Even for the Mega I am able to write customized messages.

What I intend to do is to update the time in the LCD which is received from the DS3231. It updates the LCD but I see a flickering issue here.

Every update (LCD display function is from the loop which sets the text when there is a second/time/hour difference in the time) seems like it draining more current as the one of the LED connected to Mega dims, the Rx/Tx LEDs also dim.

I am able to get the LCD refreshed but it shows a flickering. I powered the LCD 3.3V and 5V using another separate source but still the small flickering continues.

Moreover all these time I was connected to the Mega through the USB from the laptop. Once I unplug the USB, LCD starts and shows some update and again become white. This continues and an not able to see anything on LCD there after.

I am not sure why only when the Mega is connected to USB this LCD works and that too flickering but once the USB is removed the LCD is not working at all.

Can someone please do help me in this ?


texts:
Hi I am trying to send numbers to my arduino car to make it drive.
But if I send it a value I get some hex value back I believe.

If I send empty text via CoolTerm i get " m j " back to my terminal

#include <SoftwareSerial.h>

char t;

#define ENA 5
#define ENB 6
#define IN1 7
#define IN2 8
#define IN3 9
#define IN4 11

void setup() {
  Serial.begin(38400);
  delay(2000);
  pinMode(IN1,OUTPUT);//before useing io pin, pin mode must be set first
  pinMode(IN2,OUTPUT);
  pinMode(IN3,OUTPUT);
  pinMode(IN4,OUTPUT);
  pinMode(ENA,OUTPUT);
  pinMode(ENB,OUTPUT);
  Serial.println("Forward");//send message to serial monitor

}

void loop() {
if(Serial.available()){
  t = Serial.read();
  Serial.println(t);
}

if(t == '1'){            //move forward(all motors rotate in forward direction)
  digitalWrite(ENA,HIGH); //enable L298n A channel
  digitalWrite(ENB,HIGH); //enable L298n B channel
  digitalWrite(IN1,HIGH); //set IN1 hight level
  digitalWrite(IN2,LOW);  //set IN2 low level
  digitalWrite(IN3,LOW);  //set IN3 low level
  digitalWrite(IN4,HIGH); //set IN4 hight level
}

else if(t == '2'){      //move reverse (all motors rotate in reverse direction)
  digitalWrite(ENA,HIGH);
  digitalWrite(ENB,HIGH);
  digitalWrite(IN1,LOW);
  digitalWrite(IN2,HIGH);
  digitalWrite(IN3,HIGH);
  digitalWrite(IN4,LOW);
  Serial.println("Back");
}

else if(t == '3'){      //turn right (left side motors rotate in forward direction, right side motors doesn't rotate)
  digitalWrite(ENA,HIGH);
  digitalWrite(ENB,HIGH);
  digitalWrite(IN1,HIGH);
  digitalWrite(IN2,LOW);
  digitalWrite(IN3,HIGH);
  digitalWrite(IN4,LOW);
  Serial.println("Right");
}

else if(t == '4'){      //turn left (right side motors rotate in forward direction, left side motors doesn't rotate)
 digitalWrite(ENA,HIGH);
  digitalWrite(ENB,HIGH);
  digitalWrite(IN1,LOW);
  digitalWrite(IN2,HIGH);
  digitalWrite(IN3,LOW);
  digitalWrite(IN4,HIGH);
  Serial.println("Left");
}

delay(100);
}


texts: using seek() in Arduino to go to the end of a variable-sized file

texts:
Anyone know how to use the seek() function of Arduino SD Library to position pointer at the end of a file?

If programming in Windows do something like:

void fileInsert(char *file, void *data, size_t len) {

    FILE *filePtr;

    if ((filePtr = fopen(file, "rb+")) == NULL) {
        printf("Arquivo %s não pode ser aberto.", file);
        exit(EPERM);

    } else {

        fseek(filePtr, 0L, SEEK_END);
        fwrite(data, len, 1, filePtr);
        fclose(filePtr);
    }
}

But the Arduino does not have the SEEK_END


texts: How to ensure electronic components make good connection with breadboard

texts:
I just began following the projects in the Arduino Projects Book included in the Arduino Starter Kit.

While using LEDs, as in the first few examples of the book, I am having a difficult time keeping them in contact with the breadboard. I can usually move the LED around until it turns on, but even a push of a button can make it lose contact with the board. I haven't used much more than switches, jumpers, LEDs and resistors, so I don't know if any of the other components behave the same. For the more complex projects, it seems like it would be hard to tell if you have it setup properly if you can't be sure the components are making a connection with the breadboard.

Is there a particular way to get all the components to sit nicely in the breadboard, or to modify them to do so?


texts: Arduino error in code Stack smashing protect failure!

texts:
I get the error when I compiled my code below. I am making an application to read temperature on board ttgo esp32 oled lora

stack smashing protect failure!

abort() was called at PC 0x400da3e8 on core 1

Backtrace: 0x4008b8f4:0x3ffb1ec0 0x4008bb21:0x3ffb1ee0 0x400da3e8:0x3ffb1f00 0x400d0f69:0x3ffb1f20 0x400d0f73:0x3ffb1f50 0x400d366e:0x3ffb1f70 0x400d12f7:0x3ffb1f90 0x400d68a9:0x3ffb1fb0 0x40087a71:0x3ffb1fd0

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1100
load:0x40078000,len:9344
load:0x40080400,len:6348
entry 0x400806a8
Node v0.2
Trigger Temps
Read Temps = 25.50
Read Temps = 25.50
Send Temp: 25.50
Packet queued
238190: EV_TXCOMPLETE (includes waiting for RX windows)

Code is in => https://github.com/Mangulomx/ds18b20_lora1/blob/master/ds18b20_1_lora.ino


texts: atmega328: external crystal oscillator and uart

texts:
I need an clearity about external crystal oscilator. I got communication between esp32 and atmega8/88/328 processor, I use atmega wih internal oscillator and looks like it have problem with serial communication (some time it lose data, or replace it with nonsences).

So i have read that should use extercal crystal oscillator to achieve stable uart communication.

Question is that, what frequency to choose, and how that gonna effect uart, and atmega processor lifetime. I know if choose 16mhz processor gonna run faster, but assume it life time will decrease compated with 1mhz or 8mhz.
What about uart, which one of those frequences are best for it, or it make no difference?


texts: Use chars in quotes in const char* as name of function

texts:
I have been trying for a long time how to use a word declared as const string* word = "xxx" as name of void function declared somewhere below in my code.
Here is example with ssid:
const char* ssid = "name_of_ssid";

void (*name of ssid*) () {

⠀//some code

}

I want to use word declared in const char* in quotation marks as name of function.
It can not be written just void ssid().
Yes, I can set a name of void function manually, when const char* ssid = "CoffeeWifi" I can type void CaffeeWifi() but I want to do that by this way because my code is specific for this option and explaining this code here would be very difficult. When I change array of const char* word from "xxx" to "yyy" I want to  change the name of void from void xxx() to void yyy() as well.
How to do that? What function should I use?
Thank you!


texts:
I have an application where I need 4 serial ports - 3 will be sending and receiving.  The packet size will be up to 255 bytes on these 3 "main" ports.  The 4th port will be receive only, and its packet size will be 6 bytes. There is no flow control. The data rate on all ports is 115,200 baud. The 3 main ports will send or receive data packets approximately once per second. Most data will be half-duplex, although occasionally it will be necessary to send and receive simultaneously from a port . The 4th port (the one that handles 6 bytes), will get packets at an approx 50 packets/second rate.

The TEENSY will have to calculate CRCs on all ports, and will have to do a small amount of data manipulation as well.

I was planning to use the hardware serial ports for the 3 main ports, and software serial for the port that has to deal with only 6 bytes.  It is important that the 3 main ports be able to not miss any incoming data.  The 4th port is less important and can "miss" a packet now and then with no ill effects.

Will a TEENSY 3.2 running 90MHz be able to keep up?


texts: Current Sensor ACS712 not changing its value even when connected bulb is lit

texts:
My task is to find the amount of current a light bulb uses, with that motive I used ACS712 current sensor of 30A connected all the connections properly as shown in the circuit diagram below

I tried all different codes available to calculate current...
Arduino Code :
void setup(){
    Serial.begin(9600);
}

void loop(){
  int rVal = 0;
  int sampleDuration = 100;       // 100ms
  int sampleCount = 0;
  unsigned long rSquaredSum = 0;
  int rZero = 511;                // For illustrative purposes only - should be measured to calibrate sensor.

  uint32_t startTime = millis();  // take samples for 100ms
  while((millis()-startTime) < sampleDuration)
  {
    rVal = analogRead(A0) - rZero;
    rSquaredSum += rVal * rVal;
    sampleCount++;
  }

  double voltRMS = 5.0 * sqrt(rSquaredSum / sampleCount) / 1024.0;

  // x 1000 to convert volts to millivolts
  // divide by the number of millivolts per amp to determine amps measured
  // the 20A module 100 mv/A (so in this case ampsRMS = 10 * voltRMS
  double ampsRMS = voltRMS * 10.0;
  Serial.println(ampsRMS);
  Serial.println(analogRead(A0));
}

Output

The output remains the same, even when the bulb is still lighting up.
Thank You in advance :)


texts: Testing Conditions on Port Bytes - ignoring certain bits?

texts:
Being new to testing byte and bit conditions, I feel like there has to be a better way to test for conditions/values on a byte (read from a port).

For example, I'm reading 8 bits from PORTK. I need to test for a pattern of high bits. (Say, byte value of 207 - bits 7, 6, 3, 2, 1, 0 all high.) Bits 4 and 5 I don't care about. They CAN be high, or can be low. (Using datasheet terminology, they're "X - Don't Care".)

I could do an if, and test if the value equals 207, 223, 239, or 255, but that seems messy and like there would be an easier (and cleaner to read) way.

Edit to add: I've looked at Bit Operators, and .. something is telling me I should/could be using one of those. But I'm having a difficult time walking through which one would help me.

Thanks!
-Mike


texts: Is it possible to print client IP or MAC address from Arduino WiFi web server?

texts:
For a school project I want to make a little project with the Arduino Uno. I want to make a project that does something when a client connects to the WiFi shield.

My first thought was to print out the IP address or MAC address of the client but I can't find the codes for it. It is possible for me to print out the host IP? I have searched on the web for some time but only the ethernet shield will appear. Is my question even possible with an WiFi shield or do I have to get an ethernet shield?

Kind regards.


texts: Who makes this cool Arduino display shield, and what model is it?

texts:
Anyone recognize Mfgr/model of this display that reads: "Wireless Internet Of Things".  The Arduino board is a WIOT.

I've been looking and looking for a source for Arduino display like this, but cannot find.


texts:
I want my Arduino to drive a LED strip.
The LED strip in particular is the 3528 non-waterproof type.
To power this up, I need a 12V power supply.
My LED strip is going to be 5 meters.

Now my questions are:

Is it important on how many amps, my powers supply will feed? One guy did it with 12V, 5A power supply. Considering the length (5m), is a particular amperage value necessary?
Can I power up the Arduino Nano with the power from the power supply? Voltage wise, I am clear, since the nano can handle 12 volts... What I am scared of is the amperage... Considering that I need a particular value of amps to power up my LED strip, can the nano handle this many amps? Is there a limit to how many amps the power supply line that I will feed my Arduino has to be?


texts:
I posted this on the main Arduino forum, but no one has responded in 24 hours.

I'm trying to use the WaveHC library from Adafruit with a custom PCB. I am having trouble getting the SPI com to work for some reason, I modified the ArduinoPins.h, SS_PIN, from pin 10 to 8.

Using the Arduino SD library, I can see all the files no problem.

In the WaveHC library, all of the examples freeze after card.init(), I traced it to the spiSend(uint8_t b) in SdReader.cpp. It seems to get stuck in while(!(SPSR & (1 << SPIF)). This looks like the SPDR register (the SPI data register) is never loaded properly.

Does anyone know what is going on?

Adafruit library : https://github.com/adafruit/WaveHC

Edit :
This is the output from the SDReadTest example (Arduino SD Library)

Initializing SD card...Wiring is correct and a card is present.

Card type: SD2

Volume type is FAT32

Volume size (bytes): 1973350400
Volume size (Kbytes): 1927100
Volume size (Mbytes): 1881

Files found on the card (name, date and size in bytes):
SYSTEM~1/     2016-11-07 14:11:06
  INDEXE~1      2016-11-07 14:11:06 76
0.WAV         2016-11-07 11:44:14 22124
1.WAV         2016-11-07 11:44:14 18604
2.WAV         2016-11-07 11:44:14 19244
3.WAV         2016-11-07 11:44:14 19884
4.WAV         2016-11-07 11:44:14 21164
5.WAV         2016-11-07 11:44:14 23084
6.WAV         2016-11-07 11:44:14 21484
7.WAV         2016-11-07 11:44:14 29484
8.WAV         2016-11-07 11:44:14 20844
9.WAV         2016-11-07 11:44:14 25004
P.WAV         2016-11-07 11:44:14 21804

Notes :

I am using an Atmega328P @ 8MHz with the pro mini bootloader (this may be the issue)
SPI_DEFAULT_HALF_SPEED is set to true
SPI_INIT_SLOW is set to 1


texts:
I want to transmit I2C data, using a Digispark ATTiny85 board:

http://digistump.com/products/1
http://digistump.com/wiki/digispark/tutorials/connecting

I've found the following I2C libraries. Which one is more lightweight, stable, bug-free, efficient, powerful, and easy to use?

Adafruit's TinyWireM has not been updated in 2 years.
felias-fogg's SoftI2CMaster has been updated within days of this post.
lucullusTheOnly's TinyWire represents some years of improvements, "based on the TinyWireM and TinyWireS libraries". This version is recommended by BroHogan, co-creator of TinyWireM:
https://playground.arduino.cc/Code/USIi2c

Wire seems under-featured:

  "the default Arduino Wire() library does not support changes in bus
  speed or feature proper clock stretching support. This makes the
  default library only marginally functional"
  https://www.maxbotix.com/articles/095.htm

What other I2C libs are available for ATTiny? In the IDE i see Digispark SoftSerial, OneWire, and VirtualWire.

How do they all compare?

Note, these other answers do not seem relevant to my question:

What's the difference between all the Software Serial Libraries? Which one is Arduino Nano compatible?
Alternatives to Wire library for I2C


texts:
I have a HC-SR04 sensor mounted on a stepper motor, mounted on a car.
The idea is this:

The car moves forward with the ultrasonic sensor facing the front
If the sensor reads a small distance the car do the following:

Stop
Turn the sensor to the left and get a new distance
Turn the sensor to the Right and get a new distance
Drive slightly backward
The car turns the to direction the distance was the highest
Drive forward again

I think I must have wrongly understood how the echo/ultrasonic sensor works. Because when I read values to the left and right, it will always return zero, but reading values when driving forward works very well.

Below is the relevant code

//Trigger
void triggerEcho(){
  digitalWrite(echoTrigPin,LOW);
  delayMicroseconds(5);
  digitalWrite(echoTrigPin,HIGH);
  delayMicroseconds(10);
  digitalWrite(echoTrigPin,LOW);
}

//Trigger, receive and calculate distance (cm)
long getEchoDistance(){
  triggerEcho();
  pinMode(echoRecPin, INPUT);
  long echoDuration = pulseIn(echoRecPin, HIGH);

  return echoDuration / 58;
}

void loop(){

  long distance = getEchoDistance();

  //If front obstacle is encountered
  if((distance < 5) && (distance != 0)){
      carStop();
      servo.write(180);                     //turn echo sensor left
      delay(250);
      long distanceL = getEchoDistance();   //trigger and read sensor value
      servo.write(0);                       //turn echo sensor right
      delay(250);
      long distanceR = getEchoDistance();   //trigger and read sensor value

      //this will always show distance as 0
      Serial.print("  LEFT :"); Serial.print(distanceL); Serial.print("\n");
      Serial.print("  RIGHT:"); Serial.print(distanceR); Serial.print("\n");

      carDriveBackward(135, 1.185, 1.0);     //drive backwards
      delay(250);
      if(distanceR>distanceL)                //turn in the direction that was furthest
        carTurnRight(100,1250);
      else
        carTurnLeft(100,1250);
      carStop();
      servo.write(90);                        //face sensor forward
      delay(250);
    }
    else
      carDriveForward(135, 1.185, 1.0); //R - L
}

I bet something is wrong with how I'm implementing the triggerEcho() and getEchoDistance(). I excluded anything on the wiring and pins, as the reading of the distance is very correct when reading the facing the front.


texts: Student Code: map function not functioning

texts:
We made this code in class:

 int red = 6;
  int green = 7;
  int blue = 8;
  int pot = A0;
  int potVal = 0;
  int chosenColor = 0;

void setup() {
  // put your setup code here, to run once:
  pinMode(red, OUTPUT);
  pinMode(green, OUTPUT);
  pinMode(blue, OUTPUT);
  pinMode(pot, INPUT);
  Serial.begin (9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  potVal = analogRead(pot);
  chosenColor = map(potVal, 0, 1023, 1, 3);
  if(chosenColor = 1) {
    redCycle();
  }

  else {
    analogWrite(red,255);
  }

  if(chosenColor = 2) {
    greenCycle();
  }

  else {
    analogWrite(green,255);
  }

  if(chosenColor = 3) {
    blueCycle();
  }

  else {
    analogWrite(blue,255);
  }
  Serial.println(chosenColor);
  Serial.println(potVal);
  delay(500);
}

void redCycle() {
    analogWrite(red,0);
  for(int i=0; i < 256; i+=5) {
    analogWrite(red, i);
  }
}

void greenCycle() {
  analogWrite(green,0);
  for(int i=0; i < 256; i+=5) {
    analogWrite(green, i);
  }
}

void blueCycle() {
  analogWrite(blue,0);
  for(int i=0; i < 256; i+=5) {
    analogWrite(blue, i);
  }
}

When we open the serial monitor we find that chosenColor is always 3 regardless of what the potVal is reading. I am sure is something simple but we can't find where is the error. Please help.


texts: How can I get my Arduino to recognize a specific object using some kind of sensor?

texts:
This is my first question on this site, and I'm relatively new with Arduino. I do have some experience using the board to reprogram a robot that used infrared proximity sensors, servos, and switches.

I would like to add a sensor on to the robot that will allow him to recognize specific "obstacles" that I will put in his environment (not walls!) For instance, when he sees a red card, he needs to spin, but when he sees a green card, he needs to roll in the opposite direction. I do not want to spend much on the cards, but I would be willing to put a small battery and LED in them if I had to. The cards do not necessarily need to be colored, I was just using that as an example.

The robot will be in a well-lit room with noise in the background. He will be controlled by an Arduino Uno, an infrared sensor and a remote control. He can be pretty close to the cards if he has to (3 centimeters or so would be enough). It would be ideal if he could discern different types of cards, but that is not necessary as long as he's able to tell a card from the rest of his environment.

I am simply not sure how to go about implementing this. I have read about using photoresistors to differentiate color, and they're really cheap, but will they be accurate enough from a distance? This is the light sensor I was considering using:

http://www.mouser.com/ProductDetail/Adafruit/161/?qs=GURawfaeGuDpQ5XPTNqKUw%3D%3D&gclid=Cj0KEQiA6IC2BRDcjPrjm_istoUBEiQASrLz1rQNwZgntUcccnOmrFph-pCbu60R00GNozB_XbZxYz0aAn0j8P8HAQ

I'm willing to pay about 5$ for one if I need to.

If I use the light sensor method, can I just use brightly colored cards or will I need to use LEDs? Is there a better way to accomplish my goal that you are aware of?

Thank you for your time. If there is missing information in my question, please tell me and I will add it.


texts: Why do people complain when I call my functions voids?

texts:
I have posted questions about "my void loop" or "my void setup" and people complain that they aren't really voids. But they are! See this example code:

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

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

Clearly setup and loop are voids because they have the word void right before them!

Note: this is a reference question.


texts:
An Arduino UNO is given.
I want to establish an I2C communication channel between Arduino UNO and a Linux Machine which have only USB ports available to communicate with peripherals.
Currently I can communicate with Arduino board via USB Serial cable (TXD and RXD which are on pins D0 and D1).

My question is: is there any way to use those pins as SCL/SDA to communicate via I2C with Arduino Board?

I am thinking that the only way to accomplish this is to buy an USB to I2C Adapter and connect to A4 (SDA) and A5 (SCL); but maybe I'm wrong.

I have also seen that way: https://gist.github.com/kraftb/8c0bbcc35a9778608d74. Basically to use an intermediate Arduino board.


texts: Problems with (somewhat) large boolean arrays

texts:
I am writing a simple Conway's Game of Life implementation just to get to grips with the "Nokia 3310" LCD and I am having problems with boolean arrays. I am using an (unofficial) Arduino Pro Micro 5V/16MHz

Here's the code that is causing me trouble:

boolean buffer[84][48];

void setup(){
  for(int i = 0; i < 84; i++){
    for(int j = 0; j < 48; j++){
      buffer[i][j] = true;
    }
  }
}

void loop(){}

When I upload this to the Arduino, it seemingly freezes up with the RX led on and its COM port stops working. If I want to upload any other sketch, I have to manually pull the RST pin LOW (since the Pro Micro doesn't have a reset button).

I've been playing around with the code and found out that the source of problems is this line:

buffer[i][j] = true;

It also doesn't matter if I use true or false.

I have tried debugging with Serial to the computer, but the Serial communication doesn't work at all, so I tried using an LED to find out where the problem is. I don't have any "regular" LEDs on me, so I had to try with an Adafruit NeoPixel. The outcome was quite interesting. When I comment out the problematic line, everything runs just fine, the led goes red for 500ms then it blinks white every time the problematic line would run and then it goes green and stays that way. With the problematic line in place, the LED won't do anything, even turn red, which I put much earlier in the code than the source of the problem.

Does anybody have any insights that might be useful? (Also, I really hope it is not some stupid typo, I swear I read it through about twenty times)


texts:
I have a simple Arduino sketch which I have been playing with on my Uno.

The idea is simple, the user turns a potentiate (pin A2), when they pass a certain threshold a LED is turned on (pin 7).

Here is the code:

// Digital pins
const byte ledPin = 7;

// Analog pins
const byte userInputPotPin = A2;

// Potentiometer constants
const int userInputPotMinimumValue = 0;
const int userInputPotMaximumValue = 1023;
const int userInputMinimumValue = 1;
const int userInputMaximumValue = 100;

// Variables
const int threshold = 90;

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

    // Digital pins
    pinMode(ledPin, OUTPUT);

    // Analog pins
    pinMode(userInputPotPin, INPUT);
}

void loop()
{
    int rawValue = analogRead(userInputPotPin);
    int mappedValue = map(rawValue, userInputPotMinimumValue, userInputPotMaximumValue, userInputMinimumValue, userInputMaximumValue);

    String messageText;
    messageText += "Raw:   " + String(rawValue) + "\t";
    messageText += "Mapped:" + String(mappedValue);

    if(mappedValue > threshold)
    {
        messageText += "\tThreshold exceeded!";
        digitalWrite(ledPin, HIGH);
    }
    else
    {
        digitalWrite(ledPin, LOW);
    }

    Serial.println(messageText);

    delay(100);
}

The problem is that when it is run the hardware is very unresponsive - I can turn the pot, but I don't see the light change for several minutes. The log messages in the serial monitor also seem to be lagging behind.

I have tried:
* Removing the Serial statements (so there is no serial communication when the sketch is running), and just observing the LED. This makes no difference.
* Increasing the value in the delay up to 1000. This makes no difference in the responsiveness.

However, when I run the sketch on my Mega2560 the problem goes away and the circuit is as responsive as I expect.

Is there something wrong with my Uno board?


texts: Arduino reading screen color from device (without light/color sensor)

texts:
I am a beginner working on a project in which I have purchased a device that can display 4 colors on the display (blue, green, yellow, or red). I would like the Arduino to read what color is on the display and depending on the color supply power to an attached motor. For example, if the screen is green supply power to the motor, if screen is yellow or red or blue do not supply power to the motor.

On the circuit board of the attached device there are clearly labelled wires connecting the LCD display to blue, green, and red LED solder points.

Is it possible to read the current going through these wires to determine what color would be displayed on the LCD display? If not, are there any other suggestions which could work?

As I mentioned earlier, I'm a complete beginner so anything would help. Thanks.


texts: check if a fuse is good or bad in an ac circuit using arduino

texts:
I have a fuse in a ac circuit of which i want to check if the fuse is ok or not. I'm wishing to wire up two nodes of the fuse holder and determine the fuse status. I have a plan of notify user if the fuse is ok or not.

How can I do that using arduino?


texts:
This question might seem stupid, but I have been curious about it for a long time.

So I am a new engineering student, and we learned a lot about "designing a controller". For example, design controller for a car steering system and so on. All the "controllers" we designed are in the Laplace domain aka s-domain. And most of the times it will be just a transfer function. So how do real control system engineers use these transfer functions in arduino and other microcontrollers? I mean you cannot just put the function in there right?

Do you have to convert the transfer function to some other form and write the code for the microcontroller or is there a simpler way to do it?

Thanks for your time!


texts: Solid-state relay boards: Can they be used to switch audio signals?

texts:
So I tried to use one of those widely available solid-state relay boards to switch some 12V power, and I found out the hard way that they are not designed to switch DC current. They use some sort of variac that only works when AC voltage is applied. Do I have that right??

So I got this other project where I need to multiplex some audio signals in a mixer board, and I was already planning on using those solid-state relays before I learned all this. If I send audio through these relays, is it going to work as planned? Will I suffer any noticeable delay, signal degradation or attenuation?


texts:
I am thinking of making a wireless speaker using the ESP8266 chip. I have some questions regarding this.

Which pin of the ESP8266 chip can be used as I²S output? I have an ESP chip of this type :

Which ESP chip would be the best choice for this purpose?
I know about the MAX98357A which is used to convert digital I²S data to analog. But, for stereo output I need to use 2 of those. Is there any alternative to this chip which supports stereo output by default?
I have found many tutorials which shows how to play audio from SD card of ESP8266. But, how can I stream audio over standard WiFi connection?


texts: How to change input pin of FreqCounter Arduino Uno/Dumilanove library?

texts:
The following link to the library defines arduino pin 5 for input pin for signal.
 https://www.pjrc.com/teensy/td_libs_FreqCount.html

But the problem is I'm using an 16x2 LCD display with the arduino pin 5. The display needs pin 5 to work. So the question can solved in two ways,to both of which I don't know the answer.
1. Change LCD pin number to other pin. (Tried it was a failure. I've probably done it wrong)
2. Change the input pin for the freqcount library.

Any idea how to get past this bottleneck?


texts: Marlin g-codes applicable for a Melzi Sanguino board

texts:
How/where do I find a complete listing of "acceptable" Marlin g-codes applicable to a Melzi Sanguino board on a 3D printer (Zonestar). It appears that not all printer boards accept all available Marlin codes.

Then I was thinking incorrectly. I had assumed that not all g-codes (from a Marlin build) were, in fact, “implemented” the same way on all boards, and some would not even be recognized or interpreted. But I still don’t understand why that is.


texts:
I bought a light sensor (LDR), but he got stained, what it means? It is used? Or is residuum of time?

I must give back? I have to clean up or something?

I bought as new, so I tested one of the LEDs will not turn on.

I bought the (Mercado Livre in BRAZIL).

The product is:
http://www.gbkrobotics.com.br/exemplo-produto/p7-sensor-de-luz-com-leds.pdf

I pay R$8 BRL (equivalent aprox. $2 dollars) but, i just wanted to know if he had something I could do, because only shipping was R$ 13 BRL ($4 dollars)

I'm starting with Arduino, thx


texts: Is there a cheap relay that can control voltage from stuff like bulb lights with a 5 V control output?

texts:
I need to power a light bulb or something like 110 V or 220 V at normal amperage for TV or something at that range like a fan...

My micro-controller is an Arduino with 5 V out and 12 V max out trough transistor switch.

To my understanding a stepper motor drive could be a viable option to enable the relays... I can even control current, right?

Up to 8 channels

Could this work better?


texts: Vcc measurement with internal 1.1V reference fails on 3.3V powered Atmega328

texts:
I need to monitor a battery plugged to an ATmega running on standalone mode.

I use the "ATmega on a breadboard (8 MHz internal clock)" bootloader.
More info here

When the ATmega is powered with 5V the sketch outputs good values : arround 5100 mV.

But when I power it with 3.3V the sketch gives strange values : arround 178619 mV.

Here is my code Inspired from here

void setup()
{
  Serial.begin(9600);
  Serial.println(F("Internal Voltage Sensor"));
}

void loop()
{
  Serial.println( readVcc());
  delay(1000);
}

long readVcc()
{
  long voltage=0;
  uint8_t wADC;

  // Read 1.1V reference against AVcc
  // set the reference to Vcc and the measurement to the internal 1.1V reference
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
  ADCSRA |= _BV(ADEN);  // enable the ADC

  delay(20); // Wait for Vref to settle

  ADCSRA |= _BV(ADSC); // Start conversion
  while (bit_is_set(ADCSRA,ADSC)); // measuring

  // Reading register "ADCW" takes care of how to read ADCL first and ADCH then.
  wADC = ADCW;

  voltage = 11253000L / wADC; // Calculate Vcc (in mV); 1125.3 = 1.1*1023*1000
  return voltage; // Vcc in millivolts
}

I don't understand what's going on. The returned value with Vcc=3.3V should be lower than with VCC=5V. Something like 3300 mV !


texts: HC-05 Bluetooth Module Blinking Red Light-Arduino Uno

texts:
I have looked on google for an answer to my problems to no avail. The you tube video I am following is here: https://www.youtube.com/watch?v=f1v0IMegCvU
So basically on my android, I can't see the HC-05 device show up and the module itself is flashing red unlike the video's flashing blue light. I have connected the circuit exactly like he has in the video with the 2 10K resisters. I am using the same app. What is wrong? Here is my code as I copied from the video.

void setup()
{
  pinMode(13, OUTPUT);
  Serial.begin(9600);
  Serial.println("Connection Successful!");
}
void loop()
{
  if(Serial.available()>0){
    int data=Serial.read();
    switch(data){
      case 'a': LEDON();break;
      case 'b': LEDOFF();break;
      default : break;
    }
  }
  delay(50);
}
void LEDON(){
  Serial.println("Led On!");
  digitalWrite(13,HIGH);
}
void LEDOFF(){
  Serial.println("Led Off!");
  digitalWrite(13,LOW);
}

I also get the error avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00 when connected through usb. I do not get any errors when just flashing the arduino without any wires connected to the arduino. I know that the port is correct. Any ideas would be helpful. Thanks.


texts: ArduinoJSON: Using a reference to a reference when parsing array of arrays

texts:
I started to play around with the ArduinoJson library to parse data I got from one of my APIs (the format of the JSON data I get from my API can be improved for sure, but the software I had to implement the API with is rather limited in formatting JSON strings). The data is formatted as an array of arrays like this:

[["P101","1.2345","bar(a)"],["P102","1234.567","mbar"],["P103","2345.678","mbar"],["P104","2.3456","bar(a)"]]

In order to get a first impression about how much memory is needed I used ArduinoJSON's Assistant to analyse my dataset, calculate memory requirements and get a very basic code snippet for parsing the data. Code snippet generated by the assistant is as follows:

const size_t bufferSize = 4*JSON_ARRAY_SIZE(3) + JSON_ARRAY_SIZE(4) + 90;
DynamicJsonBuffer jsonBuffer(bufferSize);

const char* json = "[[\"P101\",\"1.2345\",\"bar(a)\"],[\"P102\",\"1234.567\",\"mbar\"],[\"P103\",\"2345.678\",\"mbar\"],[\"P104\",\"2.3456\",\"bar(a)\"]]";

JsonArray& root = jsonBuffer.parseArray(json);

JsonArray& root_ = root;

JsonArray& root_0 = root_[0];
const char* root_00 = root_0[0]; // "P101"
const char* root_01 = root_0[1]; // "1.2345"
const char* root_02 = root_0[2]; // "bar(a)"

JsonArray& root_1 = root_[1];
const char* root_10 = root_1[0]; // "P102"
const char* root_11 = root_1[1]; // "1234.567"
const char* root_12 = root_1[2]; // "mbar"

JsonArray& root_2 = root_[2];
const char* root_20 = root_2[0]; // "P103"
const char* root_21 = root_2[1]; // "2345.678"
const char* root_22 = root_2[2]; // "mbar"

JsonArray& root_3 = root_[3];
const char* root_30 = root_3[0]; // "P104"
const char* root_31 = root_3[1]; // "2.3456"
const char* root_32 = root_3[2]; // "bar(a)"

I did not test this, yet but had a look at the produced snippet and stumbled upon these lines:

JsonArray& root = jsonBuffer.parseArray(json);

JsonArray& root_ = root;

What is the exact advantage of using address-references root, root_ and e.g. root_1 here? Those should, as far as I understood the code, reference to the same data at the end. Is it for better readability only?


texts: Servo library unable to control more than 11 servos

texts:
I am working on assembling the ROFI robot from Project Biped (http://www.projectbiped.com/prototypes/rofi) and I have not been able to run any arduino program as they will not function correctly.

To be more specific, when I attempt to run 12 servos on a single Arduino Mega, the servos twitch uncontrollably and do not move to the positions which are set in the program.  At the same time the power light on the arduino mega blinks and does not turn solid (as opposed to if I use less than 11 servos when the pwr light is solid).  I predict it might be the power source but after checking the batteries with the multimeter they check out to be fine (7.6 V).  The circuit is pretty simple, I am using a servo shield connected to a 6V regulator connected in parallel to two 7.2 V 1350 mah LiPo batteries.  The arduino is connected through the dc power jack to the same circuit in parallel.

Here is the code...

   #include <Servo.h>

// 0 Right Ankle (roll)
// 1 Right Lower Leg
// 2 Right Knee
// 3 Right Middle Leg
// 4 Right Upper Leg
// 5 Right Hip (roll)
//LEFT LEG JOINTS
// 6 Left Ankle (roll)
// 7 Left Lower Leg
// 8 Left Knee
// 9 Left Middle Leg
// 10 Left Upper Leg
// 11 Left Hip (roll)

int c=0;

Servo rightAnkle;
Servo lowerLeg;
Servo rightKnee;
Servo rightMiddleLeg;
Servo rightUpperLeg;
Servo rightHip;
Servo leftAnkle;
Servo leftLowerLeg;
Servo leftKnee;
Servo leftMiddleLeg;
Servo leftUpperLeg;
Servo leftHip;

void setup(){
  rightAnkle.attach(0);
  lowerLeg.attach(1);
  rightKnee.attach(2);
  rightMiddleLeg.attach(3);
  rightUpperLeg.attach(4);
  rightHip.attach(5);
  leftAnkle.attach(6);
  leftLowerLeg.attach(7);
  //leftKnee.attach(8);
  //leftMiddleLeg.attach(9);
  leftUpperLeg.attach(10);
  leftHip.attach(11);
}

void loop(){
  rightAnkle.write(90);
  lowerLeg.write(90);
  rightKnee.write(90);
  rightMiddleLeg.write(90);
  rightUpperLeg.write(90);
  rightHip.write(100);
  leftAnkle.write(90);
  leftLowerLeg.write(90);
  leftKnee.write(90);
  leftMiddleLeg.write(90);
  leftUpperLeg.write(90);
  leftHip.write(90);
}


texts: Problems With Fading Through Neopixel Colors

texts:
I have a 20x20 matrix of neopixel LED's. I have a certain set of LED's on in different places at different times. Each one is set to mainColor. Right now mainColor is just set to strip.Color(r, g, b) but I would like to have those color fade through the spectrum. I decided the easiest way would just be to do something like this, and simply return strip.Color(r, g, b) to mainColor, then calling it to turn change the colors like so:

strip.setPixelColor(pixelNumber, mainColor(5));

Here is the code for mainColor:
    int r;
    int g;
    int b = 255;
    int _r;
    int _g;
    int _b = 255;

void Color (int FADESPEED)
{
    // fade from blue to violet
    for (_r = 0; _r < 256; _r++) {
        r = _r;

        mainColor = strip.Color(r, g, b);
        Clock ();

        delay(FADESPEED);
    }
    // fade from violet to red
    for (_b = 255; _b > 0; _b--) {
        b = _b;

        mainColor = strip.Color(r, g, b);
        Clock ();

        delay(FADESPEED);
    }
    // fade from red to yellow
    for (_g = 0; _g < 256; _g++) {
        g = _g;

        mainColor = strip.Color(r, g, b);
        Clock ();

        delay(FADESPEED);
    }
    // fade from yellow to green
    for (_r = 255; _r > 0; _r--) {
        r = _r;

        mainColor = strip.Color(r, g, b);
        Clock ();

        delay(FADESPEED);
    }
    // fade from green to teal
    for (_b = 0; _b < 256; _b++) {
        b = _b;

        mainColor = strip.Color(r, g, b);
        Clock ();

        delay(FADESPEED);
    }
    // fade from teal to blue
    for (_g = 255; _g > 0; _g--) {
        g = _g;

        mainColor = strip.Color(r, g, b);
        Clock ();

        delay(FADESPEED);
    }
}

This was good but it would only return r, g, b as it was on the last iteration of the last for loop, which obviously isn't what I want. But when I un-comment the Serial.print's the values were perfect. So then I put return strip.Color(r, g, b) into each for loop, however this only returns the first iteration of the first loop, which is also not what I want. Does anyone know how in the world I can return strip.Color(r, g, b) for every iteration of every for loop? Or if not, any alternatives that would work in this situation.

Thanks, Matthew


texts:
Look at this snippet of code (from TinyGPS++ library):

Serial.print(gps.location.lat(), 6);

It prints the latitude location with 6 decimal points.
I want, instead of printing that value, to have it assigned to a variable.

But i want it assigned just like above, with six decimal points. Is there a way to do this?


texts:
WT8266-S1 WiFi module in my hand I want to encode this module with Ardino IDE. I have a coded program for Arduino NodeMCU 1.0. How can I convert it to the WT8266-S1 WiFi module? Do you have the WT8266-S1 WiFi module source code? Firebase connection to do the application to turn off the LED. Below is a sample code share.

#include <SoftwareSerial.h>

SoftwareSerial esp01(9,11);

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

  pinMode(4,OUTPUT);
  digitalWrite(4,LOW);

  pinMode(12,OUTPUT);
  digitalWrite(12,LOW);

  pinMode(13,OUTPUT);
  digitalWrite(13,LOW);

  sendData("AT+RST\r\n",2000);
  sendData("AT+CWMODE=2\r\n",1000);
  sendData("AT+CIFSR\r\n",1000);
  sendData("AT+CIPMUX=1\r\n",1000);
  sendData("AT+CIPSERVER=1,80\r\n",1000);
}

void loop()
{
  if(esp01.available())
  {
    if(esp01.find("+IPD,"))
    {
     delay(1000);

     // odczytanie ID połączenia
     int connectionId = esp01.read()-48;

     esp01.find("pin=");

     int pinNumber = (esp01.read()-48)*10;
     pinNumber += (esp01.read()-48);
     digitalWrite(pinNumber, !digitalRead(pinNumber));
      String closeCommand = "AT+CIPCLOSE=";
     closeCommand+=connectionId;
     closeCommand+="\r\n";

     sendData(closeCommand,1000);
    }
  }
}

String sendData(String command, const int timeout)
{
    String response = "";

    esp01.print(command);

    long int time = millis();

    while( (time+timeout) > millis())
    {
      while(esp01.available())
      {
        char c = esp01.read();
        response += c;
      }
    }
    Serial.print(response);
    return response;
}

Warning: espcomm_sync failed when I install this thread
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed
 getting the error


texts: Any way a GSM sim 900 can still work (USA)?

texts:
so I’m pretty new to arduino and have been working for weeks on a GPS tracker using a sim 900 and a knock off neo 6M. All my code seemed to be working but for some reason I could not get the sim900 to establish a connection. Took me long enough to find out 2G carriers have been pretty much shut down. This is for a project and I don’t have time to start over with a 4G shield. Are there any cell carriers that still support 2G? What are my options? I don’t know what to do
Edit: more detail, I’m using the sim 900 to send an sms with a gps location


texts: Is it a rule of thumb to always use a buffer for realtime data acquisition from a microcontroller?

texts:
I probably have a misunderstanding one way or another, so this may be a bad question, but whenever I see sketches of projects that are outputting realtime data or in general, I always see the use of buffers.

For example if you were collecting temperature data in realtime from 3 separate sensors, I could understand using a buffer to first collect those 3 samples, storing them in a buffer, and then outputting that buffer over Serial instead of individually at a time.

But for cases where say you're just sampling a single temperature sensor, I would think you wouldn't need or use a buffer since theres no need to organize the data in such way.

Is there a computational advantage of first reading all values, storing them in a buffer, then outputting the buffer to Serial over just printing the values one at a time in a continuous stream? or am I missing something completely?


texts: Sustainable power source for outdoor arduino weather station

texts:
I have been running a simple weather station composed of a Sparkfun Pro Micro (8kHz/3.3V), a DHT22 and a NRF24L01+ transceiver during the last couple of months, and I can tell you up here in Canada weather stations save lives...

The board checks the temperature and the humidity once every second and transmits the new measurements back to my home server over RF if the changes are above some threshold. As such, the board sleeps most of the time, and the transmissions happen rarely (about once to thrice per minute).

The system has been running off an iPhone charger up to now, but I am now thinking of weaning it off the mains. The maximum power consumption of the whole circuit when DHT22 is on and RF chip is transmitting remains below 200mA and many articles suggest that with some optimization one can reduce the power draw by levels of magnitude. Actually, from what I read I gather that the average consumption of the circuit can be pushed below 1mA.

So, I was thinking of adding a solar panel, a charging circuit and a Li-ion battery to my setup, when I discovered these low-cost solar-powered USB power banks on several vendor websites. They make outrageous claims about their charge capacity, that in my experience one has to divide at least by two (20,000 ~= 10,000), but they are pretty rugged and seem appropriate for outdoor installation. The units seem to use a 6V/0.6W (100mA) solar cell that should theoretically be sufficient for charging the battery even if some days are less sunny or shorter.

I wonder if anyone has used one of these as a continuous power supply for an arduino kit, or can inform me about the possible limitations. The idea is not to deal with the power apparatus myself each time I want to assemble a kit.


texts:
I wrote a function that takes characters and noticed that the Arduino Compiler treated some characters like system-reserved, and other like functions, and a few just like characters. Lowercase doesn't seem to be effected.
I'm just wondering why.


texts: Changing ESP-12E NodeMCU to ESP-01S - how to trigger sketch?

texts:
I had my sketch up and running with a NodeMCU and a Leonardo Pro Micro and decided I wanted to minimize the footprint of the project and use the smaller ESP-01S board instead.

The ESP-01S is programmed to send a push notification to Pushover and my old code works - the only problem is that I don't know how to trigger it from the Pro Micro.

With the NodeMCU I just setup it up to listen on Pin 2 and I triggered a high/low from my Pro Micro and it sent the push notification - at the moment as soon as I power the ESP-01S up it just sends the push notification over and over and doesn't see the connection from the Pro Micro to stop it doing this.

Here is my current code on the ESP-01S

#include <ESP8266WiFi.h>

// Wifi Settings
const char* ssid = "Redacted";
const char* password = "Redacted";
// Pushover settings
char pushoversite[] = "api.pushover.net";
char apitoken[] = "Redacted";
char userkey [] = "Redacted";
int length;
WiFiClient client;
void setup() {
  pinMode(0, OUTPUT);
  digitalWrite(0, LOW);
  pinMode(2, INPUT);
  Serial.begin(9600);
  delay(10);

  // Connect to WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");

  // Print the IP address
  Serial.print(WiFi.localIP());

}

void loop()
{
if(digitalRead(5) == 1) pushover("Deployment Completed");
}

byte pushover(char *pushovermessage)
{
 String message = pushovermessage;

 length = 81 + message.length();

if(client.connect(pushoversite,80))
 {
   client.println("POST /1/messages.json HTTP/1.1");
   client.println("Host: api.pushover.net");
   client.println("Connection: close\r\nContent-Type: application/x-www-form-urlencoded");
   client.print("Content-Length: ");
   client.print(length);
   client.println("\r\n");;
   client.print("token=");
   client.print(apitoken);
   client.print("&user=");
   client.print(userkey);
   client.print("&message=");
   client.print(message);
   while(client.connected())
   {
     while(client.available())
     {
       char ch = client.read();
       Serial.write(ch);
     }
   }
   client.stop();
 }
}

and my Leonardo Pro Micro code is as follows

#include <HID-Project.h>
#include <HID-Settings.h>
int buttonPin;
int buttonPin2;
char chr;   // for incoming serial data, type char is signed 8-bit, -128 to 127, ASCII is char codes. Save 1 byte over type int.

void setup() {
  pinMode(5, OUTPUT);
  pinMode(7, OUTPUT);
  BootKeyboard.begin();
  Keyboard.begin();
  Mouse.begin();
  Serial.begin(115200);
  buttonPin = 4; //White Button
  buttonPin2 = 6; //Black Button
  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(buttonPin2, INPUT_PULLUP);
}

void loop() {
  delay(5000);
  digitalWrite(5, HIGH);
  delay(100);   //short wait time
  digitalWrite(5, LOW);
  }

Obviously I want the digital pin 5 of the Pro Micro to trigger the ESP-01 to send a push notification when it's trigger.

Just for the record I'm using a 3.3v Pro Micro btw so there's no issue with the voltage here, before I was using a Logic Converter with a 5v board.

I have the ESP-O1S setup with the 3V3 and EN are connected to the 3v VCC on the Pro Micro, the GND to GND and I tried IO0 and IO2 to Digital Pin 5 on the Pro Micro.

Could someone point me in the right direction?


texts: Can someone please show me how to make an LED chaser with 4LEDs

texts: I want to make a LED chaser with 4 LEDs that run from right to left, but when we push a button it runs from left to right?


texts: Is the analogread function averaging the samples taken by the ADC?

texts:
In many development boards the analog voltage data which is sampled by the ADC can be sent to the serial port. But the data speed I see on the serial port by HyperTerminal or Serial monitor is much slower than the sampling rate.

Lets take Arduino as an example. As far as I understand the analogread() function samples an analog input at 10kHz rate. It means 10000 samples taken per second.

But when I use the Serial Monitor it seems the data speed which we see as upcoming/flowing line by line per second on Serial Monitor is much slower.

Is that because the analogread() is averaging the samples before the data is sent to the serial port?


texts:
I'm using Energia to program one of TI's MCU. Since Energia is based off the Arduino IDE, I'm hoping someone can help me here.

I'm building a simple UDP packet sender and receiver app. The MCU starts up and connects to the local Wifi network and waits for a packet from another device on the same network.

This packet is collected in a char array char packetBuffer[16];

I want to split this array into two separate arrays each of 8 elements. These are char lampCmdRead[8]; and char pwdReadBuffer[8]; Now the network bit works great. I can send the packet through my desktop and receive it on the MCU. However when I split this array I see that the pwdReadBuffer shows the same contents as packetBuffer even though they are of different sizes. How is this possible?

Here is the code:

char packetBuffer[16];
char lampCmdRead[8];
char pwdReadBuffer[8];

// This is code from the 'void loop()' section
int packetSize = Udp.parsePacket();

if(packetSize) {
 int len = Udp.read(packetBuffer, 16);
 if (len > 0) packetBuffer[len] = 0;
 Serial.println();

 Serial.println("packetBuffer:");
 Serial.println(packetBuffer);
 Serial.println();

 for(ctr = 0; ctr < 8; ctr++) {
   pwdReadBuffer[ctr] = packetBuffer[ctr];
 }
 if (len > 8) pwdReadBuffer[len] = 0;

 for(ctr = 0; ctr < 8; ctr++) {
   lampCmdRead[ctr] = packetBuffer[ctr+8];
 }
 if (len > 8) lampCmdRead[len] = 0;

 Serial.println("pwdReadBuffer:");
 Serial.println(pwdReadBuffer);
 Serial.println();

 Serial.println("lampCmdRead:");
 Serial.println(lampCmdRead);
 Serial.println();
}

And here is the output:

Received packet of size 16
From 192.168.1.101, port 55056

packetBuffer:
2qZ@X51Rredledon

pwdReadBuffer:
2qZ@X51Rredledon

lampCmdRead:
redledon


texts:
I need to assign a string to an array value:

char mystr[3] = "Hello";

But when I run this code on arduino simulator: tinkercad.com, I get this error:

1:17: error: initializer-string for array of chars is too long [-fpermissive]

Why I'm getting this error?


texts: Problem with SIM800L GSM module and servo

texts:
I have a SIM800L GSM module like in this link, .

.

The problem is when I connect the GSM to my Arduino Uno the GSM turns on for a while and then turns off. I tried to connect it with a 9-volt battery and an LM7805 voltage regulator, but I have the same problem. Attached to the Arduino are an LM35 temperature sensor, two LEDs, a buzzer, an LCD, a GSM module, a gas sensor and a servo.

The other problem is with the servo. I tested the servo and it works fine but when the servo stops moving, it starts to shake. I do not know what the problem is.


texts:
I am controlling a stepper motor with a potentiometer and I am trying to map the potentiometer values (0-1023) to the stepper motor steps (200). I only want this stepper motor to turn 1 (one) rotation from 0 on the potentiometer (0 steps on the stepper, yes I have a micro switch to mark 0) all the way to 1023 on the potentiometer (200 steps on the stepper). But I have trouble understanding the map() function.

potValue = map ( potPinValueRead,0,1023,0,200) ;

As per the Arduino example:

map(value, fromLow, fromHigh, toLow, toHigh)

I think I am interpreting the map() function wrong

UPDATE:
Even with the map() values the stepper still turns 5 (and a bit (1023/200) ) rotations and not just 1 (one) rotation.

Here is my code:

#include <Stepper.h>
#define STEPS 200
Stepper stepper(STEPS, 7, 8, 9, 10);
int previous = 0 ;
int potData = 0 ;
int potPin = A0 ;

int outputA = 7 ;  //Stepper Output
int outputB = 8 ;  //Stepper Output
int outputC = 9 ;  //Stepper Output
int outputD = 10 ; //Stepper Output

int limitSwitch = 2 ; //Limit switch (home switch) is on pin 2

void setup() {
   Serial.begin(9600) ;
   stepper.setSpeed(10);
   pinMode ( outputA, OUTPUT ) ;
   pinMode ( outputB, OUTPUT ) ;
   pinMode ( outputC, OUTPUT ) ;
   pinMode ( outputD, OUTPUT ) ;
   pinMode ( limitSwitch, INPUT ) ;

   //Turn the motor until the limit scwitch is triggered
   while ( digitalRead(limitSwitch) == 0 )
    {
      stepper.step(30);
    }
   //Stop turning when the limit switch has been triggered
   while ( digitalRead(limitSwitch) == 1 )
    {
      stepper.step(0);
    }
   //Turn 5 steps away from the limit switch to un-trigger
   //This is also the "home" position
   stepper.step(-5);
 }

 void loop() {
   int potData = map(analogRead(potPin),0,1024,0,200);

   if (potData>previous)
    {
      stepper.step(5);
    }
   if (potData<previous)
    {
      stepper.step(-5);
    }

  previous = potData;
}


texts:
here is the code:

#include "DHT.h"
#include "NewPing.h"
#define DHTPIN 7
#define DHTTYPE DHT22
#define TRIGGER_PIN  10
#define ECHO_PIN     10
#define MAX_DISTANCE 400

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
float hum;
float temp;
float duration;
float distance;
float soundsp;
float soundcm;
int iterations = 5;

DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin (9600);
dht.begin();
}
void loop()
{
delay(2000);

hum = dht.readHumidity();
temp= dht.readTemperature();
soundcm = soundsp / 10000;
duration = sonar.ping_median(iterations);

Serial.print("Sound: ");
Serial.print(soundsp);
Serial.print(" m/s, ");
Serial.print("Humid: ");
Serial.print(hum);
Serial.print(" %, Temp: ");
Serial.print(temp);
Serial.print(" C, ");
Serial.print("Distance: ");

if (distance >= 400 || distance <= 2) {
Serial.print("Out of range");
}
else {
Serial.print(distance);
Serial.print(" cm");
delay(500);
}

Serial.println(" ");
}

here is the error:

Arduino: 1.8.7 (Windows 7), Board:
"Arduino/Genuino Uno"

Sketch uses 6156 bytes (19%) of program storage
space. Maximum is 32256 bytes.
Global variables use 326 bytes (15%) of dynamic
memory, leaving 1722 bytes for local variables.
Maximum is 2048 bytes.
Please select a Port before Upload


texts: Arduino Uno (or Teensy 3.2) programmatically powering an external USB connection

texts:
I'd like to create a process to programmatically turn-on/activate a separate USB device connected to my computer...Thinking another way to state the problem, I want the Arduino to complete the USB power circuit and then "turn off" on a schedule.

In an essence, I'd like to have my Arduino facilitate the manual process of un-plugging a USB into my computer (lets say for 5 seconds) and then re-plugging it in (let's say for 5 mins)-- rinse and repeat on a schedule....I'd like to have this coded/programmed though (I'm ok in the Arduino IDE -- sample code would really help me out a ton though) -- I'm not going to setup an actual servo to do this.

I thought getting a Arduino Shield would be the right place to start but I'm really lost.  I also thought getting a USB cable with a flip power switch might be another way to tackle the problem too-- but I haven't started to mess with it yet.

Any ideas or resources to point me in the right direction are greatly appreciated.  Thanks so much.


texts: ESP8266-01 Does not receive or respond to AT Commands

texts:
I have an ESP8266 wifi module that I want to test, to use it later. I uploaded the original Espressif AT firmware "ESP8266 AT Bin V1.7.0" from: https://www.espressif.com/en/support/download/at.

FTDI seems to be connected to the ESP all properly, since firmware upload successfully finished and prompted:

  Leaving...
  Hard resetting via RTS pin...

I use the Arduino IDE's serial monitor at 115200 baud rate set to "both NL & CR", to send the commandS "AT", "AT+GMR" e.t.c.

No response ever returns. I have no idea about what am I doing wrong, or why esptool.py can connect to the board smoothly but there is a problem with sending AT commands to it.

Thanks for all suggestions in advance. Please comment if you need any other information about the issue.

P.S: I have two modules bought at different times. Both of them wont work with AT commands.


texts: Can only program Pro Mini board once then error getsync()

texts:
I am 100% new to Arduino.  I am using the Pro Mini 328P 3.3v 8mhz board.  I can successfully write to the board once with the Blink program. I set the FTDI to 3.3v jumper. It works.  Then if I try to upload again (I changed the timing on the blink) I get the getsync error.  I tried two boards they both fail after the first upload.  I am using Win 10.

This is the error I see:
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xaf


texts: Creating a library of C++ classes for Arduino; How to #include "Arduino.h", "WProgram.h"?

texts:
I've written 6 C++ classes on the CLion IDE to be used on Arduino. One of these classes uses a C++ library called "Adafruit_PWMServoDriver.cpp" provided by Adafruit to use the PWM driver they sell. I'm trying to test my code in a main.cpp, but upon building my code, I noticed that "Adafruit_PWMServoDriver.cpp" has the following code:

#if ARDUINO >= 100
 #include "Arduino.h"
#else
 #include "WProgram.h"
#endif

Naturally, I copied Arduino.h from the Arduino installation folder to my C++ project header directory. But for reasons I don't know, ARDUINO is apparently not greater than or equal to 100, so it attempts to include "WProgram.h." Because I cannot find this header file, I changed my code to only attempt to include Arduino.h.

#if ARDUINO >= 100
 #include "Arduino.h"
#else
 #include "Arduino.h"
#endif

However, Arduino.h itself includes several header files, and I am not sure where I can find all the find them, or if it is even necessary to try to do so. I need to get my test code running, so I don't want to directly test it in the Arduino IDE yet. What can I do to overcome #include Arduino.h and #include WProgram.h?


texts:
I need to plot serial data from Arduino.

I require support for:

Various data formats (e.g. signed, unsigned, 8 bits, 16 bits);
Plots several data on the same axes;
Exports / Imports file data.

As plotting serial data from Arduino is a common need, my question is:
What programs/utilities are available for plotting serial data from Arduino that meet the needs above?

What are the advantages / disadvantages of the method you have suggested?


texts: Print 2 numbers stored in 24-bits in decimal format

texts:
An implementation function from the nice little Wiegand library YetAnotherArduinoWiegandLibrary prints a hexadecimal representation of a facility # & card # (8-bit facility #, 16-bit card #) — 24 bits of a 26-bit stream that comes across the wire.

Example encoded 24-bit number: 7111097 (decimal). Hex equivalent: 6C81B9. The 6C portion is the facility # (decimal: 108). 81B9 is card # (decimal 33209).

This function from the library's example usage serial prints the hexadecimal format of the number:

void receivedData(uint8_t* data, uint8_t bits, const char* message) {
    Serial.print(message);
    Serial.print(bits);
    Serial.print("bits / ");
    //Print value in HEX
    uint8_t bytes = (bits+7)/8;
    for (int i=0; i<bytes; i++) {
        Serial.print(data[i] >> 4, 16);  //1st, 3rd, 5th hex digit
        Serial.print(data[i] & 0xF, 16); //2nd, 4th, 6th hex digit
    }
    Serial.println();
}

What I've tried to do unsuccessfully so far is to loop over the bits to also serial print the two decimal formatted numbers (facility:card) in the final output form:  108:33209


texts: Sending data from Arduino UNO as a SOAP request

texts:
I have a servo motor on one end which can be turned ON and OFF with web service sending SOAP request. In the other end I have my Arduino UNO with ESP8266. Currently, I am able to send HIGH or LOW status from my Arduino to ESP8266.

My query is: After receiving the status "HIGH" from Arduino to ESP8266, I need to POST the status via SOAP request so that my motor would be "turned ON" . After turning ON the motor in the other end I would like to GET a simple SOAP response.

I am not sure if the above explains to you clearly but I am tired of thinking "how to do this".


texts:
I am building a rather complicated model railroad crossing signal and have moved to using the Mega since I need more pins than the Uno. Upon reading the specs of the Mega on the Arduino.cc website I noticed a potential pin conflict, or not, maybe they serve a dual purpose?

External Interrupts: 2 (interrupt 0), 3 (interrupt 1), 18 (interrupt 5), 19 (interrupt 4), 20 (interrupt 3), and 21 (interrupt 2).
I2C: 20 (SDA) and 21 (SCL).

SDA and Interrupt 3 both function on pin 20? Likewise with Interrupt 2 and SCL?
I assume this is true, how/why do they share the same pin?


texts: Connection from Arduino Uno to Microsoft SQL Server Database

texts:
I would like to make a connection from Arduino Uno to Microsoft SQL Server for storing student attendance records into a table from my database.

So, what is the best way to do that? I need a suggestion or useful references and links.

I have written a web application on Visual Studio using C# language. What Arduino does is getting fingerprint through sensor, then I would like to store the attendance records of a student into database. So the attendance records can be retrieved from database to the web application and display to teachers.

This is just for project purpose only and the connectivity between Visual & SQL Server using these two lines below:

SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=DESKTOP-H7KQUT1;Initial Catalog=SAOS1;Integrated Security=True";


texts:
I need your help in SD card and image. It's been a week since I have involved with this problem, So I wish you can help me.

Here is the problem:

I saved a photo to the SD card and now I want to read the color information of each pixel and put the servo in a definite position based of the pixel color.
I want to read pixel by pixel information in a row and after completing a row reed the next row.

The image has 2000*2000 pixels in BMP format, but I can change the format if it is necessary and the picture consist 100 colors, so it means the servo should have 100 different position.

I can also take photo information as a CSV file with 2000 rows and 2000 columns as int values and save the .csv file to the SD card.

it would be grate if someone can help me.


texts: Which board should I use with ESP8266 Lolin V3 in Arduino IDE?

texts:
I got some "NodeMCU V3" similar to this: https://www.aliexpress.com/item/New-Wireless-module-CH340-NodeMcu-V3-Lua-WIFI-Internet-of-Things-development-board-based-ESP8266/32683073762.html

I have arduino ide 1.8.5, I see nodemcuv1, nodemcuv2 in the board list. I normaly use nodemcuv2.

I don't see explicitly a V3. For 99% of my needs this is not a problem. But LED_BUILTIN doesn't work as expected. Is there any boards.txt or something I should update to get it to work?

I know that there is a different pinout here:
Does the Node MCU v3 (LoLin) not have a builtin led?  and that the logic is reversed. I can turn on the LED_BUILTIN if I do digitalWrite(D4,LOW) will turn led on, but my question is:

can I have something defined at the level of boards.txt or similar that allows me to say something like:

digitalWrite(LED_BUILTIN, LED_ON)

and it will work with both nodemcuv2 and nodemcuv3 depending on the board I choose in the dropdown list...? since I have a mixed batch of boths and I want to have the same code base.


texts: Code for ESP32 without Development Board

texts:
I'm very new to microcontrollers. I'd like to start developing for the esp32, as it has integrated wifi & bluetooth for quite cheap. This being said, i don't have a board yet. Is there a way i can emulate an esp32 board, so i can start programming and debugging my code?
As i'm very new, any advice is welcome.
Thanks


texts: What speaker can you drive with output pin?

texts:
I'm wondering how to drive a speaker using an arduino output pin.  I am using a pwm playback method with a sound data file.  If you wire a speaker across an output pin and ground then how do you calculate what speaker power and impedence you can use without damaging the arduino?  Is there a reference making these calculations?

Thanks


texts:
I am new to Arduino and I am learning how to avoid using delay.

I have written some code to move my servo by 20° using delays, but can only move the servo once with my current code. In setup(), I assign the servo 150. The next value the servo receives is 15, which it performs. It does not iterate through the following values though. I have been using this guide, BlinkWithoutDelay, with no luck.

Here is my code:

#include <Servo.h>
Servo myservo;
unsigned long previousMillis = 0;
const long interval = 1000;

    void setup() {
       myservo.attach(9);
       myservo.write(150);
    }

   void loop() {
       unsigned long currentMillis = millis();

       if (currentMillis - previousMillis >= interval) {
            previousMillis = currentMillis;
            myservo.write(15);
       }
       if (currentMillis - previousMillis >= interval) {
            previousMillis = currentMillis;
            myservo.write(35);
       }
       if (currentMillis - previousMillis >= interval) {
            previousMillis = currentMillis;
            myservo.write(65);
   }


texts:
I've been messing around with arduinos and other microcontrollers for around a year now and I've always struggled to find ways to encase my projects. I've seen some people use custom PCBs and then 3D print a case for that.  How would one go about that? I am only a computer science student so I know nothing about electrical circuitry.
For example, lets say I have a UltraSonic Sensor that uses a Arduino nano to light an LED. How would I transfer that to a single PCB? And are there websites where I can order custom 3D printed cases for my projects?
Please let me know if you need me to make my question clearer. Thank you!


texts: How to use a potentiometer to access data within a 2 dimensional array?

texts:
I'm trying to create a 2D array of notes that are split into 3 scales. There are 3 notes in each scale. There are 3 buttons to play each note and I want to use an available potentiometer to select each of the scales to be played.

Despite my searching I cannot understand how to achieve this correctly. So far this is what I have.

Using an Arduino Uno:

// musical notes
int C = 1046;
int D = 1175;
int E = 1319;
int F = 1397;
int G = 1598;
int A = 1760;
int B = 1976;
int C1 = 2093;
int D1 = 2349;

const int numScales = 3;
const int numNotesPerScale = 3;

const int  notes[numScales][numNotesPerScale] = {
  {C, D, E},
  {F, G, A},
  {B, C1, D1}
};

const int numberOfButtons = 3;
int buttonPin[numberOfButtons] = {2, 7, 4};
//int notes[numberOfButtons] = {C, D, E};
int ledPin[numberOfButtons] = {11, 10, 9};

int buttonState = 0;         // variable for reading the pushbutton status
int speaker = 3;                 // name of the speaker key

void setup() {

  for (int i = 0; i < numberOfButtons; i++) {
    pinMode(buttonPin[i], INPUT);
    pinMode(ledPin[i], OUTPUT);
  }
  pinMode(speaker, OUTPUT);     // set speaker to be an output
}

void loop() {
  int numScales = map(analogRead(A2), 0, 1023, 0, 2);
  //int numScales = analogRead(A2 / 341);

  for (int i = 0; i < numberOfButtons; i++) {
    checkButton(buttonPin[i], notes[i], ledPin[i]);
  }
}

void checkButton(int buttonPin, int note, int ledPin)
{
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == HIGH){
    digitalWrite(ledPin, HIGH);
    tone(speaker, note);                 // play the note
    delay(100);                       // wait for 1/10th of a second
  }  } else {
    digitalWrite(ledPin, LOW);
    noTone(speaker);                  // stop playing the note
  }
}


texts: Why can't the OCR1A register be set to 1 to get a 8MHz PWM?

texts:
The max PWM frequency that can be achieved with an Arduino is by using the PWM fast mode with the pre-scaler set at 1 and the TOP counter value at 3, getting 4MHz

f_OC = 16000000/(1(1 + 3)) = 4000000

Why can't be the TOP value set at 1?


texts: MCU fuses used by Pro Mini and ATMega 2560 and power down

texts:
In context of Pro Mini and ATMega2560

Fuses, as documented in chip factory doc are complex topics (I have not really used it before), appreciate pointers and advises, to narrow down those that are needed for contexted task and left un-needed in their default modes.

Which fuses are used within context of the IDE in general, and in specific of software loading via bootloader and ISP?

Which fuses related to sleep and power down modes, in context that individual chip modules can be set to various power-saving modes via registers. Does fuses play a part in getting the power-saving effect?

Many thanks in advance


texts: Connecting ESP8266 with Arduino Uno - WiFi shield not present

texts:
I have an Arduino Uno and ESP8266. I want to connect and control an LED from a web server. I made a connection referring to this:

I uploaded the WifiWebServer code to the Arduino, and applied my router's credentials.

char ssid[] = "Router SSID";      // your network SSID (name)
char pass[] = "Router's WPA Password"; `

I'm getting a "Wifi Shield not present" message from the Serial Monitor. I even tried giving external 3.3v power supply to my ESP8266 module, but no change. What am I missing here? Can someone help me fix this issue?


texts: pro micro - Can't get USB apple Keyboards to work with an USB Host Shield

texts:
I am a beginner in the field of arduino, I bought the usb shield 2.0
https://www.okystar.com/wp-content/uploads/2017/11/mini-usb-host-shield-2.0-oky2231-1-2.jpg
for arduino pro micro, I connected them and I uploaded the following code https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino
I have seen other discussions dealing with this issue
Uno r3 - Can't get USB Keyboards to work with an USB Host Shield
but I tried to remove the comment but it still doesn't work, I use a keyboard of an old mac that has 2 integrated usb ports, I don't know why when I connect it it doesn't work but I checked and the current is there, possible solutions?


texts:
Arduino Uno with ATMega328P Processor.analogWrite is not working properly in if statement. It changes the brightness of the LED as if there wasn't any if statement at all.

There are 2 potentiometers to create an intervall in which to program increases of the LED brightness, starting at 40% of the maximum. When it's lower than the minimum value, the LED is turned off.

int ledPin = 6;
int sensorPot = 1; // it's a potentiometer for now
int maxPot = 7; // potentiometer
int minPot = 3; // potentiometer
int fortypercent = 255*0.4;
int brightness = 0;

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

void loop() {
  int start = analogRead(minPot);
  int maxVal = analogRead(maxPot);
  int sensor = analogRead(sensorPot);
  Serial.println(sensor/4);
  Serial.println(start/4);
  Serial.println(maxVal);
  if(sensor/4 > start/4) {
    analogWrite(ledPin,sensor/4);
  } else if(sensor = baslangic) {
    analogWrite(ledPin,LOW);
  } else if ((start < sensor < maxVal)) {
    brightness = sensor/4 - fortypercent;
    analogWrite(ledPin,brightness);
  } else if (sensor = maxVal) {
    analogWrite(ledPin , 255);
  }
}


texts:
I am reading a string which i have to convert into a float with a maximum of precision.I didn't want to use toFloat() function since it make a truncation so i made my own code.
My problem is that the final result is also approximated.
I need a precision of 4 digits after the float.I read the documentation about float in the arduino website.They say it should be maximum 7 digits of precision but i don't get it.When i test my code on the value of '23,459' ,all i get is 23,46.
Any suggestions?

void setup() {

 Serial.begin(9600);

}
int longu=0;
char data='2';
  String data2="23,459";
  float val=0;
  int posVir=0;
  int t=0;
  float postVir=0;
  float preVir=0;
  int lonPostVir=0;
  int lonPreVir=0;
  float posvir2=0;
  void loop()
{

   lonPostVir=(data2.substring(posVir+1)).length();
   lonPreVir=(data2.substring(0,posVir)).length();

   longu=data2.length();
   posVir=data2.indexOf(",");
   preVir=(data2.substring(0,posVir)).toFloat();
   postVir=(data2.substring(posVir+1)).toFloat();
   posvir2=postVir*pow(10,-lonPostVir);
   val=preVir+postVir*pow(10,-lonPostVir);

  Serial.println(val);

    }


texts:
We are building a circuit based on ATMega328* that :

Reads 32 current transducers, multiplexed into one Analog Input,
Reads 12 voltage transducers, multiplexed into one Analog Input,
Reads 6 temperature sensors, multiplexed into one Analog Input,
Manipulates all the readings with some math (like scaling, averaging etc.),
Calculates new variables (power, crest factor, etc.),
Tracks trends (max/min/avg) of certain (calculated) readings,
Stores some events (peaks/dips - max/min values) etc. with time stamps from RTC,
Generates Alarm Flags (by comparing readings to software-set thresholds),

The circuit should be connected as a ModBus Device (Slave) to an existing
Modbus network with several other devices on an RS485 interface.
The circuit should communicate all these calculated values and alarms
as well as some other info, like peak/max values with date and
time stamps that were recorded at their time of occurrence, to the
Modbus Master. We have the freedom of allocating the register numbers
and their formats etc. (Modbus Map) to the controller's vendor (SAUTER).
For example we tell them Register 30001 is the current sensor x,
30002 is voltage sensor y, etc.
We think that sending time stamps (of certain events) will be based on
"agreed-upon" coding of register values (MM, DD, YYYY, etc.) and the
same for alarms (to be sent as hex codes).
We have searched for libraries and got really confused from the
multitude of libraries out there, as well as the lack of documentation -:)
Can you please kindly help us :
select the proper Arduino Modbus Slave Library that :

Has MAX485 support,
Assigns Modbus registers to any arbitrary variables,
Issues Exception Responses to Modbus requests (e.g. non-existing registers
or un-supported Function Codes.
Complies to Modbus Standards
Has a manual !!

We found the "yaacov" library on Github but it assigns registers directly to "Pins".
Also we looked at its "issues" and one of them was very serious : in which frames
coming from the Master with corrupted CRC gets responded to and causes collision
with other slaves. We dont like that ! as it indicates that the library was not tested
in true industrial environment.
We also found that the Library at :
https://electronhacks.com/2014/04/arduino-modbus-plc-rtu/
somewhat fits to our requirements, however it lacks the RS485 support, and more
important, it has no documentation.
We really appreciate any kind support.

The ATmega328 will be probably replaced with a larger CPU, but we are still
in development phase.

Thank you.


texts: Import into Arduino a vintage data bus from TMS1000

texts:
For experimentation I want to import or receive into Arduino the output data from a TMS1000 (1980s) data bus.  For model train controller Hornby Zero1, and the bus sends data to receivers, for loco number, speed, direction etc. I have all the data structure etc) Is it feasible  to import to Arduino, and export from the same Arduino back to the original bus.    Just to see it working, and then later experiment with the data in the Arduino.
What libraries would be best ?
Thanks
Charles Harris


texts:
I made a struct like this:

typedef struct {
  int color[3];
  int positions[4];
  char init[20];
  void (*fn)();
} buttons;

and a variable like this:

button test[1] =
{
  {{0,0,0},{0,0,100,100},"getSomething",setSomething}
}

In loop() I call test[i].color, test[i].position normally.

Problems start when I want to execute a function.

I made two attemps, one with string and one with a function statement. With the string I have no problems using a strcmp() but it's not what I want.

I need to know how I can store 2 different functions in the struct and how I can execute.

Thanks in advance!


texts: Fastest way to send serial commands and do something

texts:
I am trying to send a lot of serial commands really fast. I basically need to change color of my LED strip many times per second (10 times per second should really be enough). If I do this over WiFi, it will eventually clutter up and make the ESP8266 unresponsive. I need to send the colors as hex, then convert them into usable values (HEX to RGB). Something tells me that's going to cost a lot of resources and the MCU is therefore spending a lot of time just converting the colors into RGB values. Here's a pseudo code example of what I am trying to achieve:

void loop() {
    if(Serial.available()) {
        if(Serial.read().first(8) == "0xABCDEF") {
            //0xABCDEF is basically my indicator saying "this is for individual LEDs"
            //Serial.read() can now be something like 0xABCDEF FF0000 00FF00 0000FF FFFFFF 000000
            char* colors[] = Serial.read().split(" ");
            colorLED(colors);

        }
    }
}

void colorLED(colors) {
    for(i = 1; i < colors.length; i++) {
        strip.SetPixelColor(i, color[i]);
    }
}

I hope this example makes sense. I can send a serial command like 0xABCDEF FF0000 00FF00 0000FF FFFFFF 000000. 5 colors in HEX.

My real question is: How do I take a lot of inputs like above (or another way) and turn them into strings, so I can convert them to RGB? Is there a better way to send commands (like pure RGB values? but remember I need to send many)?. Here is how I convert my colors into RGB:

//hexColor can be "FF0000"
int number = (int)strtol(&hexColor[0], NULL, 16);

int r = number >> 16;
int g = number >> 8 & 0xFF;
int b = number & 0xFF;


texts: How can i develop a fish tank automation using arduino

texts:
As a part of my final year Engineering project I would like to develop a  fish tank automation system. In my project I need to check the quality  of water concurrently and also I need to check the sedimentation of my fish tank. Which are the different types of sensors  used for this?
How can i connect it to my arduno uno?


texts:
I am creating an IC checker for some high school juniors since a faulty IC can be a nuisance of a bug to find when bread-boarding. These ICs are all simple TTL gating from the 74LS series; the set I am using are all 14-pin and have VCC and GND at pin 14 and 7 respectively.

Thus far my prototype's hardware looks like this:

14 digital pins to connect to the IC inputs/outputs
1 analog pin reading a joystick to navigate through the IC options
1 analog pin set to digital read as a button, which starts the checking process
1 analog pin writing to an LED to indicate whether the IC is valid
2 analog pins (SDA and SCL) as a serial bus to control my display

I actually have the prototype working for a few ICs, but I am concerned that these high school students may test an IC under the wrong selection. Since the digital pins have to dynamically change input/output depending which IC its checking, this allows for inputs and outputs to be mismatched, which could prove fatal to both the IC and the Arduino board.

I want to know if there is a way to check that inputs and outputs are misaligned without having serious electrical failure. Possible some advanced pin control I am unaware of?

Also, if you could answer my question with an example with the 74LS00, whose pinout is diagrammed below and datasheet can be found here.


texts:
I want to wrap a random number using modulo, so that values exceeding 11 starts over from 0 and greater. However, i would also like numbers less than 0 to dividend 11 or less.

Please correct me if i'm wrong, but as far as i can tell the modulo operator only dividends values exceeding the divisor. If so, how can i write code that also dividends values less than 0?


texts: Accuracy reading two analog inputs on Arduino

texts:
I need a help with this question. I'm trying to make a Wheatstone Bridge with Arduino, the main idea is read the two legs of the circuit with two analog inputs of Arduino, for the while I'm analyzing the values with 4 equal resistors as the Arduino reads (0 to 1023 bits). The problem is when I change one of the resistors (Rx), the voltage on A0 (first leg C) should not be changed, but it happens.

I've read something about the analog inputs of the Arduino suffer interference, but I don't know how to avoid this.