texts:
I have an Arduino Nano v3 clone setup with DS3231 RTC.

It constantly get time from RTC and controls outputs by comparing in if-else statements.

Now I want to output PWM signal starting and stopping at definite times. And I want PWM duty cycle time dependent.

(Ex. PWM starts at 5AM stops at 6AM with DutyCycle=0% at 5AM, DutyCycle=100% at 6AM and after 6AM PWM pin pulled to ground or 0% duty cycle whatever possible)

I want previous code as well as this code working simultaneously.


texts: Is there a sensor to measure a distance between 2 point as in range [0-2 meter]?

texts: I'm looking for a way of detecting if 2 pieces of hardware are within 2 meters of eachother or not. The idea is to build a prototype to lock computers automatically. I just need a recommendation on the sensor if it exists. Geofencing, bluetooth etc are not reliable enough.


texts: Arduino Yun & nRF24L01+ -> Linino crashing

texts:
I'm trying to hook up a nRF24L01+ wireless transmitter to an Arduino Yun Mini on SPI, but I'm having a hard time. After a few minutes Linino crashes and becomes completetly inaccessible - until I upload a new sketch to the Arduino.

I connected the SPI pins (MOSI, MISO and SCK) to the corrensponding pins of the Yun. I connected CE to pin 3 and CSN to pin 2. I'm using the RF24 library found here: https://github.com/TMRh20/RF24

The following little code is enough to make Linino crash:

#include <SPI.h>
#include "RF24.h"

RF24 radio(3,2);

void setup() {
  radio.begin();
}

void loop() {

}

What am I doing wrong here? Any ideas? Any help is greatly appreciated!


texts: How to detect if LED is switched on in external circuit using Arduino NANO?

texts: I want to detect when an LED is powered on using an Arduino NANO. The LED is part of an external circuit. The LED uses about 1.8V. Would the circuit below allow me to detect when the LED is switched on? Is this the correct method of doing it? (The LED in the diagram represents the external circuit).


texts: Arduino/Genuino 101 - EOL / Junk the board(s)?

texts:
https://hackaday.com/2017/07/25/the-end-of-arduino-101-intel-leaves-maker-market/
https://downloadcenter.intel.com/download/25832/Arduino-101-Firmware-Package-1-0
https://community.intel.com/t5/Intel-Makers/Intel-Curie-End-of-Life-Scheduled/td-p/397068?profile.language=en
Intel EOL'd the Arduino/Genuino 101 board.  The end is so complete that you cannot download the drivers using the Board Manager.
To make matters worse, my old Ubuntu machine, with an old Arduino IDE, is unable to upload to my existing 101 boards (PRESS MASTER RESET error).

Should I junk these boards?
Is there a 3rd party site that is hosting the drivers?


texts:
I was working on a school project in where i need to analog read form A0 and test if my value is bigger than some boundary (500 for example) to return 0 or 1
well with a simple code in an infinity loop
this will keep returning 0000000 and 1111111 for infinity
but need 1 only once when my analog value passes from 900 to 300 for example and I dont need once when It stays at 300.
and the same problem for 0 : I need 0 only once when it passes from 300 to 900 and not 0 from staying at 900
thanks for help in advance


texts: I have to play audio files using an isd1820 sound module. I am using arduino uno microcontroller but I am able to play only one file. Is there a way I can play different audio files according to need?


texts: Arduino Pro Micro not recognised by computer or showing up in ports

texts: Around 4 days ago my Arduino Pro Micro arrived. I've been messing around with it, using it to run keyboard commands on a computer. Just recently, whenever I plug it in to the computer it isn't detected by ports or anything. The green light is still on, and the left red light (looking at it from the side of the micro USB input) still works as well, however the right red light no longer works. Can someone tell me what's happening? Have I broken it all ready?


texts: Why adding a LED between Pin 3 and Ground causes LCD display not to show text?

texts:
For a project of mine I am programming an Arduino UNO to show information I get from some sensors on an LCD display.

As a first step I setup Arduino to show "Hello, world!" on the LCD, which worked.

For "decorative" reasons I wanted to add some LEDs between the resistors that I placed in series between PIN 3 (V0) of the LCD and ground (about 1.5K Ohm total resistance).

I first of all added one LED between the last resistor and ground. To my surprise this causes the LCD display not to show "Hello, world!" any more.
As you can see the current is flowing (the LED is lit), but I can't understand why the LCD does not show the text.

Can you help me understand what's going on? I know very little of electronics and I am learning it by doing, so I would appreciate an answer that is good for a beginner!


texts: Can Arduino Mega2560 Use this 24VDC Relay?

texts: Can a Arduino MEGA 2560 R3 provide enough current out of its pin to activate the Songle srd-24vdc-sl-c relay? Will powering the Arduino with an external power supply help?


texts: Defining a function before a class makes the class undefined? (MWE provided)

texts:
In ArduinoIDE 1.8.12 this code will Verify successfully:
struct myINT {
  int i;
};

myINT makeINT() { return myINT{5}; }

void setup() {}
void loop() {}

...no surprise, right? However this won't:
int two() { return 2; }

struct myINT {
  int i;
};

myINT makeINT() { return myINT{5}; } // <-- error: 'myINT' does not name a type

void setup() {}
void loop() {}

It will compile again if the definition of two() is moved after the one of myINT.
Is this behavior expected?


texts: Issues in interfacing relay with Arduino

texts:
I want to control AC bulb with Arduino, 5v-relay.
My connections are

My code is

#define RELAY1  7

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

void loop()
{
  digitalWrite(RELAY1,LOW); // Turns ON Relays 1
  Serial.println("Light OFF");
  delay(15000); // Wait 5 seconds
  digitalWrite(RELAY1,HIGH); // Turns Relay Off
  Serial.println("Light ON");
  delay(20000);
}

Red LED is on according to AC bulb.
Power LED (Green colored one) is also on as I have given 5v supply from Arduino.

The issues are

Bulb is not following the delay given in the code. The output for the above code is 20sec ON - 15sec OFF -20sec ON - 15sec OFF- 20sec ON -15sec OFF -  1sec ON - 20sec ON - 15sec OFF etc. means apart from 20,15 sec duration there is a duration of 1sec is coming in between as noise. What might be the reason?
On monitor also, only first 3 actions are getting printed after that no printing is observed.

==>The relay I am using is:


texts:
I'm using two nRF24L01 to communicate with each other. I did the right setup and they worked fine, however I wanted to change the air data rate to a lower value, for more stability, as the datasheet says.

How can I setup the configuration for this?

After a small research I knew that you can change this using RF_DR
to change the value of the transmission, but I didn't really know how I could exactly write the correct code for this.

Another question: does this effect the range of the module? Or does it only affect the stability? And if not, then which code can I use to extend the range of these two modules ?


texts:
I'm new to Arduino Uno, When I run this piece of code, I get numbers 340 to 370.

This is my question, why it returns 340 to 370 which correspond to 1.66 to 1.80 actual voltage? since I don't have any input equipment plugged into these pins so it must return zero voltage if i'm right in other words why default values in these pins are in this range of numbers ?

void loop() {
int val = analogRead(A0) ; //A1, A2 ...
Serial.println(val) ;

}


texts: Project 2: Arduino controlled spaceship interface

texts:
The circuit diagram attached shows that the switch is open. Yet, the LED connected to pin 3 of the arduino board lights up.

I don't understand this - the circuit is open, so why should pin 3 light up?

I discussed this with one of my friends - he said that each pin on the board receives voltage after the battery is connected. If this is true, then that would answer my question.

This is my code:

int switchState = 0;
//configures the digital pins
void setup() {
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(2, INPUT);
}

//Checks the voltageo of the digital input and chooses the pin for voltage ( pin 2 )
void loop() {
  switchState = digitalRead(2);

  if (switchState == LOW) {
    //Button is not pressed

    digitalWrite(3, HIGH); //Green LED
    digitalWrite(4, LOW); //Red LED
    digitalWrite(5, LOW); //red LED
  }

  else { //the button is pressed
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, HIGH);

    delay(250); //wait for a quarter second
    //toggle the LEDs
    digitalWrite(4, HIGH);
    digitalWrite(5, LOW);
    delay(250); //wait for a quarter second
  }
} //go back to the beginning of the loop


texts: How to use and retrieve data file from AT command in Arduino D1 Mini Wemos (With esp8266)

texts:
I stumbled upon an AT command for the ESP8266 that I really need. The following command is "AT+CWLAP", but I have no idea how to use it. I can't seem to find any resource on how to implement it.

I need the SSID, RSSI, and MAC addresses of the AP and pretty much use those data internally. For example (not necessarily doing this but you get the point), depending on the signal strength, choose the best option and print the SSID of the AP.

Is it even possible?


texts: ESP8266WiFi client.print() strange response

texts:
I am using a NodeMCU, so ESP8266. I installed the core via the Boards Manager at the last version.

My goal is to control a GoPro camera through WiFi.

I am getting mad with these few lines of code:

uint8_t GoProControl::sendRequest(String request) {
    client.stop();
    if (!client.connect(_host.c_str(), _port)) {
        if (debugStatus){
            Serial.println("Connection lost");
            GoProConnected = false;
        }
    return false;
    }

    client.print(request);
    client.print("Connection: close\r\n\r\n");

    if (debugStatus){
        Serial.println("my request is:");
        Serial.println("-------------");
        Serial.print(request);
        Serial.print("Connection: close\r\n\r\n");
        Serial.println("-------------\n");
    }
    if (listen() == "HTTP/1.1 200 OK\r") {
        return true;
    }
    else {
        return false;
    }

}

the client is connected without problem (it never gives me error) and so i send the request:

GET http://10.5.5.9/camera/SH?t=password&p=%00 HTTP/1.1
Connection: close

the listen function mainly does:

char c = client.read();
response += c;

and then print the response, this is what i get from it:

HTTP/1.1 404 Not Found
Connection: close
Date: Sat, 13 Jan 2018 16:26:27 GMT
Server: Cherokee/1.2.101b150604_3b16072 (UNIX)
Content-Length: 355
Content-Type: text/html
Cache-Control: no-cache
Pragma: no-cache

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

<title>404 Not Found</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

404 Not Found

The requested URL /camera/SH was not found on this server.

Cherokee web server 1.2.101b150604_3b16072 (UNIX), Port 80

It looks like I am connected to the wrong host.
Since I am sure that this is the correct request, where is possible that I am doing any error?


texts: Finding address of OLED using I2C communication and Arduino

texts:
It is known that address of OLED SSD1306 is 3C. The frame format is as follows:

The figure implies that the binary pattern should be 01111000 for the first frame (considering write mode and the second last bit is a dont care).
So I was trying to send the first frame using Wire.h library. The following is a code
Wire.beginTransmission(0b01111001);
But i receive a nack (return value of 2)

However, If I send 00111100, i receive a ack(return value of 0). What is wrong in my interpretation?


texts: I can't upload my program to Arduino Uno

texts:
I've not used my Arduino for about 2 months. Before this time it worked fine, but now when I want to upload my program I get this error:

  Couldn't find a Board on the selected port. Check that you have the correct port selected.  If it is correct, try pressing the board's reset button after initiating the upload.

I reset immediately after uploading but it doesn't work.What else should I do?
I'm using Ubuntu and the Arduino IDE.


texts: What would the total current requirements be for these items?

texts:
I'm using 5 of those 8mm NeoPixels + a 5V Trinket.

I'm trying to get a rough estimate of the current requirements that would have, assuming all 5 NeoPixels were running at full brightness "white" (255 RGB).

I'm voltage-regulated to about 150 mA from the Trinket and my current hunch is that those NeoPixels need more than that, but trying to confirm it.


texts: How to run 50 IR LEDs off an Arduino UNO?

texts:
Hi I have 50 camera devices I want to program. Luckily the camera devices have a param.xml file I can import. I have already loaded the param.xml file on each of the camera devices however, now I need to import the param.xml file.

The devices work on IR waves, Usually I would have to import the params on each individual device with a remote but I decided to try and create a neat project where I would attempt to program all of the devices at once using an Arduino.

I would like to buy 50 IR LEDs, make small booster circuits for each LED and then point each one too the receiving module on the camera devices. All the Signal wires would be connected to Arduino pin 3.

I am mostly concerned about all the signal wires connected to Arduino pin 3. is there perhaps some kind of circuit I can use on pin 3 to ensure that this project will work perhaps someone Knows of a better way or has some advice?

Any suggestions will be appreciated.

I am not worried about power because I will connect the IR LEDs + & - to an external Power supply with adjustable current and voltage.

Booster Circuit:

Link To IR Led Datasheet

Link To Transister Datasheet

simulate this circuit – Schematic created using CircuitLab

This is the code I am using with an Arduino Uno and I have tested it with the IR booster circuit and it does work.

#include <IRremote.h>

IRsend irsend;

void setup()
{
}

void loop() {
    for (int i = 0; i < 3; i++) {
        irsend.sendNEC(0x1067E21D, 32); // Login
        delay(1000);
        irsend.sendNEC(0x106722DD, 32); // Password Digit 1
        delay(1000);
        irsend.sendNEC(0x106722DD, 32); // Password Digit 2
        delay(1000);
        irsend.sendNEC(0x106722DD, 32); // Password Digit 3
        delay(1000);
        irsend.sendNEC(0x106722DD, 32); // Password Digit 4
        delay(1000);
        irsend.sendNEC(0x106722DD, 32); // Password Digit 5
        delay(1000);
        irsend.sendNEC(0x106722DD, 32); // Password Digit 6
        delay(1000);
        irsend.sendNEC(0x10676897, 32); // Down Arrow
        delay(1000);
        irsend.sendNEC(0x10676897, 32); // Down Arrow
        delay(1000);
        irsend.sendNEC(0x10676897, 32); // Down Arrow
        delay(1000);
        irsend.sendNEC(0x10676897, 32); // Down Arrow
        delay(1000);
        irsend.sendNEC(0x10676897, 32); // Down Arrow
        delay(1000);
        irsend.sendNEC(0x10676897, 32); // Down Arrow
        delay(1000);
        irsend.sendNEC(0x10678877, 32); // Right Arrow
        delay(1000);
        irsend.sendNEC(0x10676897, 32); // Down Arrow
        delay(1000);
        irsend.sendNEC(0x1067A857, 32); // Enter
        delay(1000);
        irsend.sendNEC(0x1067A857, 32); // Enter
        delay(1000);
        irsend.sendNEC(0x10678877, 32); // Right Arrow
        delay(1000);
        irsend.sendNEC(0x1067A857, 32); // Enter
        delay(1000);
    }
    delay(5000); //5 second delay between each signal burst
}


texts: PCA9685 seemingly no PWM output Arduino Uno when attempting to do LED dimming

texts:
Just for a quick test I've wired up the Arduino to a PCA9685 board (similar to http://www.ebay.com.au/itm/PCA9685-16-Channel-12-bit-PWM-Servo-motor-Driver-I2C-Module-For-Arduino-Robot-AU-/162059198475?hash=item25bb7b200b:g:S7IAAOSw9ZdXKa7h) as follows

5v > Vcc & V+
GND > GND
A4 > SDA
A5 > DCL
OE > Not connected

I've wired a 1k resistor in series and an LED in between PWM0 and GND

The same LED dims fine when powered directly via PWM from the Arduino.

The power light on both boards come on and +5v is available at the V+ pins.

The library I'm attempting to use is https://github.com/kasperskaarhoj/PCA9685-Arduino-Library and from what I can tell the I2C address I've configured "works"

The sketch I'm trying to run is (which is one of the example sketches with the address I2C altered):

#include <Wire.h>
#include <PCA9685.h>

PCA9685 ledDriver;

void setup()
{
  Serial.begin(9600); // set up serial
  Serial.println("Serial Started");

  Wire.begin();           // Wire must be started!
  ledDriver.begin(B000000);  // Address pins A5-A0 set to B111000
  Serial.println(ledDriver.init());

}

void loop()
{
  // Notice: setLEDDimmed cannot be used in a loop to give you a pleasant
  // "turning-up" of the LED. This is because each time you set a level for a LED
  // it will calculate random timing intervals for the PWM function in the chip
  // This is done in order to distribute current consumptions of the full time period.
  for(int level=5;level>=0;level--)  {
    for(int i=0; i<16; i++)  {
      ledDriver.setLEDDimmed(i,level*20);
      delay(100);
    }
  }
  for(int level=0;level<=5;level++)  {
    for(int i=0; i<16; i++)  {
      ledDriver.setLEDDimmed(i,level*20);
      delay(100);
    }
  }
}

Serial monitor outputs:
Serial Started
1

So it looks like the device is detected and I expect that the commands are sent but nothing happens.

I've also tried one other library and setting the duty cycle to 100% on/off just to see if I could get output with no luck. It just seems that all the PWM pins are dead. I also tried wiring up the OE pin and setting it high/low with no luck.

Any thoughts on how I might be able to get the board to output something or how I can test further would be appreciated. I'm beginning to think that maybe the IC is damaged as I've tried most the pins with no luck.

I'm out of ideas and haven't worked with I2C or PCA9685's before at all so any help would be appreciated :)


texts:
I am a newby to the world of electronics and IC chips, and am looking to make an ATMEGA328 based board to monitor 12v batteries. The board will be powered from the batteries being monitored, with a regulated power supply taking 12v input and outputting 5v to the board.
The data sheet for the ATMEGA328 chip says that AVcc should be connected externally to Vcc via a low-pass filter. A bit of internetting tells me the low-pass filter will filter out noise above a specific frequency, and provides links to calculators that show the affect of different resistor / capacitor pairs.

My problem is that, I have no idea what frequencies I need to filter! All / any advice much appreciated.

Further info: voltage measurements will be via voltage divider circuits, amp hour consumption will be via sensors, all of which will be connected to analog pins for ADC conversion.


texts:
I have a question regarding SIM800L and HTTP GET request. I'm using this https://exploreembedded.com/wiki/Setting_up_GPRS_with_SIM800L simple code to communicate with SIM800l with AT commands. To perform the HTTP request, I use the following set of AT commands:

AT+CFUN=1
OK

AT+CSTT="internet","",""
OK

AT+CIICR
OK

AT+CIFSR
10.180.xxx.xx

AT+CIPSTART="TCP","84.42.xxx.xx",80
OK

CONNECT OK

AT+CIPSEND=52
>
GET /bakalarka.php/? HTTP/1.1
Host:84.42.xxx.xx

SEND OK
HTTP/1.1 200 OK
Date: Mon, 19 Aug 2019 16:20:27 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

10
time201908191820
0

CLOSED

The problem is that sometimes. Or every other time, I don't get the whole HTTP answer. I usually get only the beginning. Something like this:

AT+CIPSEND=52
>
GET /bakalarka.php/? HTTP/1.1
Host:84.42.xxx.xx

SEND OK
HTTP/1.1 200 OK
Date: Mon, 19 Aug 2019 16:20:27 GMT
Server: Apac

and then after a couple of seconds, the connection closes.

CLOSED

Do you know what could cause that? It's literally random. I need the information from the webpage (it's the current time) and currently, it's really unreliable.

Another question. What does the "10" and "0" mean in the HTTP request? The "time201908191820" is the current time from printed from PHP.

Thank you very much!


texts: TCP communication between Arduino client and server

texts:
I'm currently trying to build an Arduino robot controlled via a wifi connection. I have an Arduino Mega running as a client and it successfully connects to the server on LAN via the Adafruit cc3000 wifi board. However instead of grabbing the contents of the JSON file and printing it to serial, I'm just getting a 100 continue response. While this means I'm doing something right, I don't know what to do next in order to grab the data I need. Do I need to get the 100 message then respond with the GET request, or is there a way that I can GET the data straight away?

Thank you all in advance. Here is the Arduino code I have so far:

#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>
#include "utility/debug.h"
#include <stdlib.h>

// These are the interrupt and control pins
#define ADAFRUIT_CC3000_IRQ 3  // MUST be an interrupt pin!
#define ADAFRUIT_CC3000_VBAT 5 // Apparently these can be any two pins
#define ADAFRUIT_CC3000_CS 10  // But I wouldn't change these...
// Use hardware SPI for the remaining pins (On a Mega 2560, SCK = 52, MISO = 50, and MOSI = 51)
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIV2);

#define WLAN_SSID "VM540258-2G"
#define WLAN_PASS "XXXXXXXX"
#define WLAN_SECURITY WLAN_SEC_WPA2

String readString = String(100); //string for fetching data from address
uint32_t ip = 3232235523; // This translates into the ip address we need
                          // 323223552X; 192.168.0.X

void setup(){
  Serial.begin(115200); //Can also work at 9600

  //Initialise CC3000 module
  Serial.println(F("\nInitializing CC3000..."));
  if (!cc3000.begin())
  {
    Serial.println(F("Couldn't begin()! Check your wiring?"));
    while(1);
  }
  //Connect to the Wireless Access Point
  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F("Failed!"));
    while(1);
  }

  Serial.println(F("Connected!"));

  Serial.println(F("Request DHCP"));
  while (!cc3000.checkDHCP()) { //Obtain IP addeess
    delay(100);
  }

  while (! displayConnectionDetails())
  {
    delay(1000);
  }
}

void loop(){
  Adafruit_CC3000_Client client = cc3000.connectTCP(ip, 80);

  if (client.connected()) {
    client.println("GET /project-test/state.json HTTP/1.0"); //Make a request for state.json
    client.println(""); //Mandatory blank line?
    if (client.available()){
      char c = client.read();
      Serial.print(c);
      //read char by char HTTP request
      if (readString.length() < 100) {
       //store characters to string
       readString += c;
      }
    }
  }
  //Once we have obtained the data, disconnect from the server
  client.close();
  Serial.println(readString);
  delay(1000);
}

bool displayConnectionDetails(void)
{
  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;

  if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
  {
    Serial.println(F("Unable to retrieve the IP Address!\r\n"));
    return false;
  }
  else
  {
    Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress);
    Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask);
    Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway);
    Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);
    Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv);
    Serial.println();
    return true;
  }
}

The initial JSON file I'm using contains the following:

{"speed_left":null,"speed_right":null,"direction_left":null,"direction_right":null}

And the serial output I get when I run the Sketch:

Initializing CC3000...
Started AP/SSID scan

Connecting to VM540258-2G...Waiting to connect...Connected!
Request DHCP

IP Addr: 192.168.0.7
Netmask: 255.255.255.0
Gateway: 192.168.0.1
DHCPsrv: 192.168.0.1
DNSserv: 192.168.0.1

Connect to 192.168.0.3:80
100

Connect to 192.168.0.3:80
100

ad infinitum


texts: Make arduino board controler for watering system with power bank

texts:
I am trying to build an off-grid automatic watering system, and I was thinking of many options and the most reliable one that I found is to use a power bank which is charged by a solar panel.

So, I have a solar panel that outputs 5V, and I can charge a standard power bank with it. In addition to this, I bought a USB pump which I can also power with the power bank and controlled using an Arduino board. The problem is that the power bank doesn't support charging and discharging at the same time, and I thought that I could use an Arduino board to control this, but I have no knowledge on this. Therefore, I need help.

Is it possible to have a system like the one sketched below, where the Arduino board controls the input/output of the power bank?

The black path is my current path, but I was wondering if I could do the red path so that I can have both chargings from the solar panel and discharge due to the pump and Arduino board.


texts: Serial Communication Between 3 Arduinos Doesn't Work (Daisy-Chain)

texts:
In my project, I have to send a string from one arduino to a second arduino, and make it send the same string to a third arduino. I used UART and SoftwareSerial library, and connected the arduinos like that:

In all the arduinos:
Pin 10 - RX port, pin 11 - TX port

Arduino 1 pin 11    ---->  Arduino 2 pin 10
Arduino 2 pin 11    ---->  Arduino 3 pin 10
Arduino 3             ---->  PC (by hardware Serial)

By theory, Arduino 1 sends string "CA" to arduino 2, which resends that same string to arduino 3, that prints it back on Serial.

The problem is that I get the string "C�" instead of "CA" (that weird "C�" is equal to "067 255" on ASCII).
Does anyone knows why it happens? Maybe there's something wrong with my code?

Here's the code for all the three Arduinos:

Arduino No. 1:

#include <SoftwareSerial.h>

#define ADDR "CA"
SoftwareSerial tiny(10, 11); //TBD

void setup() {
  Serial.begin(9600); //debug only
  tiny.begin(9600);
  delay(2000);

  tiny.write(ADDR);
}

void loop() {
  //nothing here
}

Arduino No. 2:

#include <SoftwareSerial.h>
SoftwareSerial tiny(10, 11); //TBD
void setup() {
  Serial.begin(9600); //debug only
  tiny.begin(9600);
}
void loop() {
  if(tiny.available() > 0) {
    tiny.write(tiny.read());
  }
}

Arduino No. 3:

#include <SoftwareSerial.h>
SoftwareSerial tiny(10, 11); //TBD
void setup() {
  Serial.begin(9600); //debug only
  tiny.begin(9600);
}
void loop() {
  if(tiny.available() > 0) {
    Serial.write(tiny.read());
  }
}

Any idea on what went wrong?


texts: can homemade arduino be powered up with battery?

texts: I am new to arduino. It is costly for me to buy an arduino uno board. Therefore I am going to make a Arduino with breadboard at my home. I also want to make my Arduino portable. Arduino Uno boards can be powered up with battery. But can I do so with my homemade Arduino? If it is possible, what things need to be included in my homemade Arduino?


texts: Multiple rgb control plus calculation help

texts:
Hi me and a friend is making a computer shelf with leds in the woodwork, were using a special glue for the plexiglass in the shelf which means we're using individual rgb leds, four leds for each window (3 windows) and what I need help with is, amount of voltage, ampere, code and how to connect all this up. I've used 123d.io to sketch something up but I'm struggling with getting proper strength in the leds.

(code https://puu.sh/lI6PC/e214028b07.txt)

Aswell as some of them change colors as the picture here shows:

I'm very new at these things so I really appreciate all help and advice (and from an earlier post, reason for not using strips is purely based on the method of build, the shelf will not sit correct if the strips were in use)


texts: How to pass a changing value to a graphic display using Arduino?

texts:
I am using an EA DOGM132-5 graphic display, they also have provided a library for Arduino, so everything is nice and easy. The library has a function for easily passing a string to the LCD.

void dog_7565R::string(byte column, byte page, const byte *font_adress, const char *str)
{
unsigned int pos_array;                                         //Postion of character data in memory array
byte x, y, column_cnt, width_max;                               //temporary column and page adress, couloumn_cnt tand width_max are used to stay inside display area
byte start_code, last_code, width, page_height, bytes_p_char;   //font information, needed for calculation
const char *string;

start_code   = pgm_read_byte(&font_adress[2]);  //get first defined character
last_code    = pgm_read_byte(&font_adress[3]);  //get last defined character
width        = pgm_read_byte(&font_adress[4]);  //width in pixel of one char
page_height  = pgm_read_byte(&font_adress[6]);  //page count per char
bytes_p_char = pgm_read_byte(&font_adress[7]);  //bytes per char

if(type != DOGM132 && page_height + page > 8) //stay inside display area
        page_height = 8 - page;
  else  if(type == DOGM132 && page_height + page > 4)
    page_height = 4 - page;

//The string is displayed character after character. If the font has more then one page,
//the top page is printed first, then the next page and so on
for(y = 0; y < page_height; y++)
{
    position(column, page+y); //set startpositon and page
    column_cnt = column; //store column for display last column check
    string = str;             //temporary pointer to the beginning of the string to print
    digitalWrite(p_a0, HIGH);
    digitalWrite(p_cs, LOW);
    while(*string != 0)
    {
        if((byte)*string < start_code || (byte)*string > last_code) //make sure data is valid
            string++;
        else
        {
            //calculate positon of ascii character in font array
            //bytes for header + (ascii - startcode) * bytes per char)
            pos_array = 8 + (unsigned int)(*string++ - start_code) * bytes_p_char;
            pos_array += y*width; //get the dot pattern for the part of the char to print

    if(type != DOGM132 && column_cnt + width > 128) //stay inside display area
                width_max = 128-column_cnt;
    else if(type == DOGM132 && column_cnt + width > 132)
       width_max = 132-column_cnt;
            else
                width_max = width;

            for(x=0; x < width_max; x++) //print the whole string
            {
                spi_out(pgm_read_byte(&font_adress[pos_array+x]));
                //spi_out(pgm_read_byte(&font_adress[pos_array+x])); //double width font (bold)
            }
        }
    }
    digitalWrite(p_cs, HIGH);
}
}

So I just use the function in the sketch with the variables I want and I can easily show a string, but I want to show a changing value for example a temperature reading Tc.

int ThermistorPin = 0;
int Vo;
float R1 = 10000;
float logR2, R2, T, Tc, Tf;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;

Vo = analogRead(ThermistorPin);
R2 = R1 * (1023.0 / (float)Vo - 1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
Tc = T - 273.15;

But the string function doesn't support variables. Can someone help me to adjust the string function to take variables or perhaps suggest a better way altogether?


texts: Arduino Mega and gyroscope erroneous values

texts:
I have Arduino mega2560 and MPU6050.

I connected to Vcc pin of the gyro to +5V on the mega, the SDA to SDA pin, SDL to SDL pin, AD0 and GND to 2 GND pins.

I used this code:

#include<Wire.h>

const int MPU=0x68; //I2C address of MPU
int GyX,GyY,GyZ;
float pitch=0;
float roll=0;
float yaw=0;

float v_pitch;
float v_roll;
float v_yaw;
float a_pitch;
float a_roll;
float a_yaw;

void setup(){
  Wire.begin();
  Wire.beginTransmission(MPU);
  Wire.write(0x6B); //power management register 1
  Wire.write(0);
  Wire.endTransmission(true);
  Serial.begin(9600);
}

void loop() {
  Wire.beginTransmission(MPU);
  Wire.write(0x43);
  Wire.endTransmission(false);
  Wire.requestFrom(MPU,6,true);
  GyX=Wire.read()<<8|Wire.read();
  GyY=Wire.read()<<8|Wire.read();
  GyZ=Wire.read()<<8|Wire.read();
  v_pitch=(GyX/131);
  if(v_pitch==-1) {
    v_pitch=0;
  }
  v_roll=(GyY/131);
  if(v_roll==1) {
    v_roll=0;
  }
  v_yaw=GyZ/131;
  a_pitch=(v_pitch*0.046);
  a_roll=(v_roll*0.046);
  a_yaw=(v_yaw*0.045);
  pitch= pitch + a_pitch; roll= roll + a_roll;
  yaw= yaw + a_yaw;
  Serial.print(" | pitch = ");
  Serial.print(pitch);
  Serial.print(" | roll = ");
  Serial.print(roll);
  Serial.print(" | yaw = ");
  Serial.println(yaw);
}

But the values I am reading are not angles at all, plus when I move the X axes for 45 degrees, the value is not like that at all.

I don't want to use the pre made library as I want to understand how to read from Gyroscope. Any ideas?


texts: Specify F_CPU in arduino to use 8MHz clock

texts: I am using a custom made AVR board with Atmege-328p on it and it doesn't have a 16MHz crystal on it. I would like to use the internal 8MHz as clock. I have set the appropriate Fuses but now I am unable to tell the programs that F_CPU is 8000000UL. One way of doing it is to add another variant to the boards. I would like to if there is another way to set F_CPU ?


texts: Arduino Uno R1 I soldered resistor but I cannot DFU program atmega8u2

texts:
I have an Arduino R1 board (the very first one) and I managed to solder the resistor into Arduino's Atmega8u2 (I went to a specialist in order to do that). Then I reset atmega8u2 and by wiring the pins mentioned in: https://www.arduino.cc/en/Hacking/DFUProgramming8U2
I can confirm it via this message over my GNU/Linux machine by running dmesg:
[ 1544.679504] usb 1-6: new full-speed USB device number 42 using xhci_hcd
[ 1544.808341] usb 1-6: New USB device found, idVendor=03eb, idProduct=2ff7
[ 1544.808350] usb 1-6: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[ 1544.808356] usb 1-6: Product: Arduino Uno DFU

I also to confirm that I run lsusb and I got the following result:
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 248a:8367
Bus 001 Device 058: ID 03eb:2ff7 Atmel Corp.
Bus 001 Device 003: ID 058f:6362 Alcor Micro Corp. Flash Card Reader/Writer
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Further indicating to me that arduino is in DFU mode over my ubuntu 16.04 machine. Also I further verify via dfu-util -l command:
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

Found DFU: [03eb:2ff7] ver=0000, devnum=63, cfg=1, intf=0, alt=0, name="UNKNOWN", serial="UNKNOWN"

The I try to run:
sudo dfu-programmer atmega8u2 erase
But for some reason I get the following error:
dfu-programmer: no device present.
Do you know why I get this error and how I can fix it?
Edit 1
I installed the latest version of dfu-programmer and compiled from source via https://sourceforge.net/projects/dfu-programmer/files/dfu-programmer/0.7.2/ but still I get the error. I also tried to compile it with libusb-1.0.0
Edit2
I also tried this version with libusb-1.0.0 but still the same error occurs.
Edit 3
As many suggest I tried to do multiple times but still I get this error.
Edit 4
I also used dfu-util and I try to insert the data into the atmega8u2 via:
 sudo dfu-util -d 03eb:2ff7 -D ./Arduino-usbserial-uno.hex -R

But I get the error:
dfu-util 0.8

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 03eb:2ff7
Run-time device DFU version 0100
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0100
Device returned transfer size 3072
Copying data from PC to DFU device
Download    [                         ]   0%            0 bytesdfu-util: Error during download
dfu-util: can't detach
Resetting USB to switch back to runtime mode


texts: ESP8266: Multiple analog inputs using software

texts:
Is there a way to get at least three analog inputs to the esp8266 (without a multiplexer)?

Each digital or analog pin on an Arduino can be configured as digital or "analog" (e.g., PWM software).

Here is a way to squeeze one additional analog input pin: hackaday.io/project/8435-2-analog-inputs-for-esp8266-without-multiplexer

Any ideas or software?


texts: Timers, PWM pins and digital outputs on Arduino Mega

texts:
I'm using an Arduino Mega to control motors via PWM and Adafruit DRV8871 motor drivers.  I also use TIMER1 for a timed interrupt.  After adding the TIMER1 interrupt I discovered I had problems with motor control, which I finally tracked down to using pins 11 & 12 for PWM simultaneously with using TIMER1 for timed interrupts.
My initial thought was to change the timer used for the ISR to avoid the pin 11/12 conflict, but now I'm uncertain as to what the restrictions are for using pins associated with timers.  I now realize that pins associated with a timer interrupt can't be used for PWM using analogWrite(int val), but can they be used as general purpose digital outputs?
For instance, if I change from TIMER1 to TIMER0 for my timer interrupt, that appears to change the pin dependency from 11/12 to 4/13.  I don't use pin 13, but I do use pin 4 as a digital output.  Will using pin 4 as a digital output still work properly?
TIA,
Frank


texts: Which Datasheet applies to the ATmega328p?

texts:
While researching minimum-voltage requirements of Uno, I came across what appear to be two datasheets for the ATmega328P:

http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf

http://ww1.microchip.com/downloads/en/DeviceDoc/ATmega48A-PA-88A-PA-168A-PA-328-P-DS-DS40002061A.pdf

Specifically, the power requirements (and processor speed for each power level) differ. How could I know which datasheet applies to the chip I'm using? I'm actually using an Arduino clone:


texts: How to read RC receiver channels without using pulsein() command with arduino

texts: I am building a quad-copter, the problem is of stability and for better stability lesser sampling time is required. For lesser sampling time I need to have faster loop() function. But the Pulsein() command takes very large time which in turn expands the sampling time. Is there any method to read the rc channels in background and read them from an integer.


texts: Sets of Ultrasonic frequencies using arduino uno

texts: Is it possible to create a set of ultrasonics frequencies using only the Arduino? What code to be used? And how am I going to do for it to work? For this project I need to focus in  the emitter side; all resources on Google are only on sensor and distance detector. I just want to use ultrasonic on other field just like for example on repelling rats. Thanks!


texts: How to connect multiple NodeMCUs and 1 PC over wifi and have PC control NodeMCUs?

texts:
I am trying to design a laser tag system using multiple NodeMCUs in the guns. I am trying to figure out how to connect and control them over WiFi. I also need a computer connected that will control the game. I was origionally just thinking I could use the PC as a server that tells all the guns what to do. Im sure this is possible, but it looks very complicated and I dont know a whole lot about theese types of things. So then I was thinking it might be better to have another NodeMCU connected to the computer with USB. That NodeMCU would then act as a WiFi server for the clients(Guns). That way, the PC would only have a GUI for that MCU, and once started the MCU would actually control the game. Is that the best option or is there some easier and simpler way? That seems like the best solution to me. I am just making sure this will work. Are there any other solutions or tips? Here is a basic idea of what would happen when someone shoots someone else.

Gun 1 will send IR signal (Shoot) gun 2.

Gun 1 will tell the server that it tried to shoot gun 2.

Gun 2 tells server it got IR signal from gun 1.

Server will first make sure no other guns were shot accidentally at the same time. If they were, it will determine which gun received the IR signal stronger. That gun will be the one actually shot.

Server will add points to gun 1 score and remove points from gun 2 score on both PC monitor and small screens on guns themselves.

Thanks!


texts: Zero crossing detection circuit correct?

texts:
I am working on a DIY AC dimmer circuit with arduino.
This project is part of the AC dimmer circuit as mentioned here
Since, I was stuck in so thought of retracing my steps and checking each part of the circuit and then only moving further ( to the triac part ).
Turns out I am not able to do zero crossing detection even.
My code in arduino :
int led_to_glow = 12;

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  attachInterrupt(digitalPinToInterrupt(2), zero_crosss_int, RISING);  // Choose the zero cross interrupt # from the table above
}

//the interrupt function must take no parameters and return nothing
void zero_crosss_int(){
  digitalWrite(led_to_glow, HIGH);
  delayMicroseconds(10);
  digitalWrite(led_to_glow, LOW);
  delayMicroseconds(10);
}

void loop()  {
}

Following is the circuit diagram :

Now, I am a newbie in DIY projects and since this circuit wasn't working so, I thought I would post my breadboard circuit here too.
Please have a look into the physical circuit.

( I have erased the irrelevant parts of the circuit )
A little bit of explanation ( cause maybe the diagram isn't clear enough )
The yellow jumper wire from PC 817 is sent as interrupt to the arduino's digital pin 2 ( as can be seen in the diagram ).
The arduino detects the RISING signal on it and calls the ISR.
I have checked the output on the pins of PC 817 going to the arduino ( using a multimeter ) , it gives ~10 V.
I have added a common ground and VCC from arduino , as later in the AC dimmer circuit it's going to be used ( and my understanding is that wherever VCC is of arduino , gnd also must be of arduino and not from somewhere else , right ? ).
Thanks.
Sizu
Update 1 :
I have changed PC 817 to 4N25 ( as I found later that I had that component )
I have added a resistor to the input of 4n25 which inputs 2 V ( I am considering a higher resistor as the max forward voltage for 4n25 is 1.5V )
YELLOW Wire is directly connected to arduino digital pin 2 ( i.e. INT0 )

Update 2 :
As it turns out, when AC is switched off, voltage drop between yellow wire ( interrupt pin ) and gnd of arduino is 5V DC , whereas when AC is turned on it's 0.54-0.55 V , any reason why ?
I have also tried
attachInterrupt(digitalPinToInterrupt(2), zero_crosss_int, FALLING);  // Choose the zero cross interrupt # from the table above

I changed RISING to FALLING, it still didn't work.
Hopefully Solved :
I got to glow the LED, I forgot to define LED's pin as the output pin in the arduino code but then also it glows very faintly and even multimeter can't find the potential drop across the LED
So the new code looks like this :
pinMode(12, OUTPUT);
attachInterrupt(0, ledBlink, FALLING);  // Choose the zero cross interrupt # from the table above
}

Note :
Falling / RISING / CHANGE ( all 3 worked but I think FALLING should be used cause of the pull up resistor )


texts:
Haii All,
I am using gsm SIM900A module with arduino uno. I am trying to send some data from that to server. When i am writing some commands for that, let's say i have written 3 commands before. But when i am adding one more command, it is giving me error. It seems like there's a buffer issue i.e, maybe it is getting full. So it is nto taking extra commands written on sim900A. How to solve this problem? If it a buffer issue then how should i solve it?

Thanks in advance.


texts: Printing char array from array of structs in progmem to serial

texts:
(I apologize if this is a c++ question, I'm too green to know if this is unique to the Arduino IDE)

I've moved an array of structs into my PROGMEM because I was running into memory issues:

#define HU_ADDR                 0x190
#define ALL_AUDIO_ADDR          0x1FF
#define MY_ADDR                 0x360
#define UNKNOWN_ADDR            0xFFF

typedef byte MessageID;
enum {
  ACT_UNKNOWN,
  ACT_POWERON,
  ACT_POWEROFF,
  ACT_PASSIVEOFF_0,
  ACT_PASSIVEOFFRARE_0,
  ACT_PASSIVEONRARE,
  ACT_PASSIVEON_0,
  ACT_KEYTURN,
  ACT_PRESSDISC,
  ACT_PRESSAM,
  ACT_CD,
  ACT_STATIONFOUND,
  ACT_ENABLECD,
  ACT_CD2
};

struct MessageDef {
  MessageID ID;
  word MasterAddr;
  word SlaveAddr;
  byte PayloadLength;
  word Payload[24];
  char Description[20];
};

const MessageDef MessageTable[] PROGMEM = {
  {ACT_POWERON,           HU_ADDR, ALL_AUDIO_ADDR, 13,  {0x00, 0x00, 0x00, 0x00, 0x100, 0x100, 0x00, 0x81, 0x100, 0x01, 0xF1, 0x31, 0x60},                    "Tune Knob"},
  {ACT_POWEROFF,          HU_ADDR, UNKNOWN_ADDR, 13,    {0x00, 0x60, 0x31, 0xF1, 0x00, 0x00, 0x81, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00},                       "off?"},
  {ACT_PASSIVEOFF_0,      HU_ADDR, UNKNOWN_ADDR, 3,     {0x46, 0x01, 0x11},                                                                                "Passive: Weak"},
  {ACT_PASSIVEOFFRARE_0,  HU_ADDR, UNKNOWN_ADDR, 4,     {0x60, 0x45, 0x01, 0x11},                                                                             "Passive: Strong"},
  {ACT_PASSIVEONRARE,     HU_ADDR, UNKNOWN_ADDR, 4,     {0x100, 0x20, 0x01, 0x11},                                                                            "Passive: Fierce"},
  {ACT_PASSIVEON_0,       HU_ADDR, ALL_AUDIO_ADDR, 16,  {0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x100, 0x80, 0xF1, 0x31, 0x74},    "Vol Knob"},
  {ACT_KEYTURN,           HU_ADDR, UNKNOWN_ADDR, 11,    {0x31, 0x62, 0x31, 0xF1, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0x00},                                   "Key turned"},
  {ACT_PRESSDISC,         HU_ADDR, ALL_AUDIO_ADDR, 4,   {0x00, 0x9F, 0x31, 0x62},                                                                             "No DISC available"},
  {ACT_PRESSAM,           HU_ADDR, ALL_AUDIO_ADDR, 24,  {0x00, 0x60, 0x31, 0xF3, 0x01, 0x00, 0x01, 0x00, 0x08, 0x00, 0x30, 0x00, 0x58, 0x00, 0x6C, 0x00, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, "AM/FM Switch"},
  {ACT_CD,                HU_ADDR, ALL_AUDIO_ADDR, 11,  {0x31, 0x62, 0x31, 0xF1, 0x01, 0x30, 0x01, 0xFF, 0xFF, 0xFF, 0x00},                                   "CD switch?"},
  {ACT_STATIONFOUND,      HU_ADDR, ALL_AUDIO_ADDR, 13,  {0x00, 0x00, 0x00, 0x04, 0x00, 0x100, 0x00, 0x81, 0x100, 0x01, 0xF1, 0x31, 0x60},                     "FM station found"},
  {ACT_ENABLECD,          HU_ADDR, ALL_AUDIO_ADDR, 13,  {0x00, 0x00, 0x00, 0x04, 0x00, 0x77, 0x00, 0x81, 0x00, 0x00, 0xF1, 0x31, 0x60},                       "Enter CD mode"},
  {ACT_CD2,               HU_ADDR, ALL_AUDIO_ADDR, 4,   {0x62, 0x45, 0x01, 0x11},                                                                             "CD message 2?"}
};

const byte MessageTableSize = sizeof(MessageTable)/sizeof(MessageDef);

I've adjusted accordingly in my code segments that reference this data using pgm_read_byte_near() for example. However, I'm not really sure how to get the Description field anymore. When MessageTable was in dynamic memory I could just use:

Serial.println(pgm_read_word(MessageTable[msgid].Description))

But now that seems to be printing... maybe the addresses of the data? Instead of printing out the character array I need to see. How do I parse this more correctly?


texts:
I'm working on a few arduino projects where I've needed a flexible scheduler and/or timer library and was wondering if anyone has a library they recommend?
Case 1:
I have a sensor that needs to collect observations every hour, but it has a specific  measurement sequence:

Power up/boot (takes about 15 seconds)
Warm-up for 60 seconds.
Observe (2 min), collect raw data, generate stats
Cool-down for 5 min.
Power off

In this case have a single micro-controller acting as a data-logger that is controlling multiple sensors and writing to an SD card.
Case 2:
I have an oven that needs to be controlled to a user-specified temperature profile (up say to 6 points of change), i.e.:

Turn on heater
Set temperature, 100C and hold for 2 min
Set temperature, 160C and hold for 15 min
Set temperature, 250C and hold for 1 hr
....
Set temperature, 100C and hold for 1 hr
Turn off heater

I'm familiar with non-blocking timers and (in the past) have cobbled together a few simple timers with millis() and some ulong variables. Alas, the complexity and debugging time rapidly grows with the number of dependent timers. Before I sit down and sketch out a class definition, I figured I'd ask what others are using.


texts:
I'm pretty new to microcontrollers and Arduino and since I can't find any satisfying information on my problem, I hope that you might answer them:

My project is actually quite simple: I just want to write out data over a serial connection via USB, the problem: My Arduino Nano has to run as USB Host. That's because the other device is a vacuum cleaner: Neato XV-25 with a mini usb jack. I was already able to 'talk' to it using a Raspberry Pi.

Since I don't have much knowledge about USB communication, I would like to know the following, before I start digging deeper:

I found out, that I would not be able to use the 'usual' usb port of the nano. But I've read a few things about that 'V-USB' library, but did not understand very much. Would it be possible to create a USB Host with this library, that can communicate via a virtual serial connection?
I stumbled across the USBHost for Android Nano. It's a shield, but I'm not sure if it would fit my needs. Is it able to handle serial communication? And is there somewhere a store where I can get it cheap? I think more than 20$ for a shield is a bit too much...


texts: Error: invalid types 'int[int]' for array subscript

texts:
I am trying to get an Arduino to work with some Adafruit Motor shields.
Everything seemed to work fine, but when I tried to create a function, I get the error in the subject. As far as I can tell, everything was declared properly (the array is initialized and is indexed elsewhere with without issue). Only the function seems to cause an issue.

Would anyone have a guess at what's wrong?

    //////// Imports
    #include <Wire.h>
    #include <Adafruit_MotorShield.h>
    #include "utility/Adafruit_PWMServoDriver.h"

    ////////My globals. Times are in milliseconds
    unsigned long currentTime = 0;
    unsigned long elapsedTime = 0;
    unsigned long startTime = 0;
    byte currentMotor = 1;
    byte currentShield = 1;
    byte motorRunning = 0;

    //// Settings

    // How many seconds between motors
    unsigned long endTime = 4000;

    // How many shields and motors per shield
    const int nShields = 1;
    const int nMotorsPerShield = 3;

    /////////MicroManager globals
    unsigned int version_ = 2;
    const unsigned long timeOut_ = 1000;
    byte currentPattern_ = 0;
    unsigned long time;

    /////////Adafruit globals
    Adafruit_MotorShield afms[nShields];
    Adafruit_DCMotor *motor[nShields][nMotorsPerShield];

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

      unsigned char address = 96;

      for (int i = 0; i < nShields; i++) {
        afms[i] = Adafruit_MotorShield(address);
        address = ++address;
        afms[i].begin();
      }

      for (int i = 0; i < nShields; i++) {
        for (int j = 0; j < nMotorsPerShield; j++) {
          motor[i][j] = afms[i].getMotor(j + 1);
          motor[i][j]->setSpeed(255);
        }
      }

      pinMode(13, OUTPUT);
    }

    ////////////////////Main
    void loop() {
      currentTime = millis();
      elapsedTime = currentTime - startTime;

      if (elapsedTime > endTime) {
        startTime = currentTime;
        currentMotor = currentMotor + 1;
        if (currentMotor > nMotorsPerShield) {
          currentMotor = 1;
        }
      }

      if (Serial.available() > 0) {
        int inByte = Serial.read();

        switch (inByte) {
          case 1:
            if (waitForSerial(timeOut_)) {
              currentPattern_ = Serial.read();
              if (currentPattern_ == 0) {
                for (int i = 0; i < nShields; i++) {
                  for (int j = 0; j < nMotorsPerShield; j++) {
                    motor[1][j]->run(RELEASE);
                  }
                }
              }
              else {
                switchMotor();
              }
              Serial.write( byte(1));
              digitalWrite(13, HIGH);
            }
            break;

          case 30:
            Serial.println("MM-Ard");
            break;

          case 31:
            Serial.println(version_);
            break;
        }
      }

      digitalWrite(13, LOW);
    }

    ////////////////Function definitions

    bool waitForSerial(unsigned long timeOut)
    {
      unsigned long starTime = millis();
      while (Serial.available() == 0 && (millis() - starTime < timeOut) ) {}
      if (Serial.available() > 0)
        return true;
      return false;
    }

    void switchMotor()
    {
      int shield = currentShield - 1;
      int motor = currentMotor - 1;
      for (int i = 0; i < nShields; i++) {
        for (int j = 0; j < nMotorsPerShield; j++) {
          if (i == shield && j == motor)
            motor[i][j]->run(FORWARD);
          else
            motor[i][j]->run(RELEASE);
        }
      }
    }


texts: Arduino: Reading DS18B20 interferes with servo

texts:
I have an Arduino with a servo, INA219 (current and voltage sensor) and 2 DS18B20 connected to it.

DS18B20 are connected in full-power mode with 5k resistor connected between DATA line and +5V.

I use DallasTemperature library: https://github.com/milesburton/Arduino-Temperature-Control-Library

I get the temperature readings, but the problem is that my servo is jittering slightly almost every time temperature reading is done.
If I disconnect DATA line from pin 2 (where it's normally connected) then servo is not moving anymore and everything is fine.

Any ideas what might be causing it? I would expect servo interfering with OneWire readings, not the other way around :)

Here is the full code:
https://pastebin.com/xcES4PVT

Here is the minimal example with which I can reproduce the problem:

    #include <DallasTemperature.h>
#include <Servo.h>

#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

Servo myservo;

long previousMillis = 0;

long tempRequestedMillis = 0;

bool tempRequested = false;

void setup(void)
{
  // start serial port
  Serial.begin(115200);
  Serial.println("Dallas Temperature IC Control Library Demo");

  myservo.attach(9);

  // Start up the library
  sensors.begin();
  sensors.setWaitForConversion(false);
}

void loop(void)
{

  unsigned long currentMillis = millis();
  if (!tempRequested && currentMillis - previousMillis > 2000) {
    previousMillis = currentMillis;

    sensors.requestTemperatures(); // Send the command to get temperatures

    tempRequestedMillis = currentMillis;
    tempRequested = true;
  } else if (tempRequested && currentMillis - tempRequestedMillis > 2000) {
    Serial.println(sensors.getTempCByIndex(0));
    tempRequested = false;
  }
}


texts: Doesn't work radio transmission from Arduino Uno to Arduino Pro Micro

texts:
I have Arduino Uno, Arduino Pro Micro, XY-MK-5V and FS1000A.
I need transmit data from Pro Micro to Uno.

Transmitter:

    #include <VirtualWire.h>

    void setup() {

      Serial.begin(9600);

      vw_setup(2000);
      vw_set_tx_pin(14);
    }

    void loop() {

      send("Test message!");
      delay(2000);
    }

    void send (char *message)
    {
      vw_send((uint8_t *)message, strlen(message));
      vw_wait_tx();
    }

Receiver:

#include <VirtualWire.h>

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

    vw_set_rx_pin(12);
    vw_setup(2000);

    vw_rx_start();
}

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

    if(vw_get_message(buf, &buflen))
    {
        for(int i = 0; i < buflen; i++)
        {
            Serial.print(buf[i]);
        }

        Serial.println();
    }
}

I dont know why it's doesn't works. When I changed Uno with Micro and Micro with Uno, it's worked.

But I need: Micro + transmitter FS1000A & Uno + receiver XY-MK-5V.

Please help me. I'm using this Pro Micro.


texts:
unsigned long Htime;
unsigned long Ltime;
unsigned long Ttime;
unsigned long f;
int N;

void setup() {
  // put your setup code here, to run once:
cli();
  TCNT2 = 0;
  TCCR2A = 0;
  TCCR2B = 0;
  Serial.begin(9600);
  pinMode(5,INPUT);
  pinMode(3,OUTPUT);
  pinMode(11,OUTPUT);
  TCCR2A = (1 << COM0A1) | (1 << COM0B1) | (1 << WGM21) | (1 << WGM20);
  TCCR2B = (1 << WGM22) | (1 << CS22) | (1 << CS21) | (1 << CS20);
  TIMSK2 = (1 << OCIE2A);
}

void loop() {
  // put your main code here, to run repeatedly:
  Htime = pulseIn(5, HIGH);
  Ltime = pulseIn(5, LOW);
  Ttime = Htime + Ltime;
  f = 1000000 / Ttime;
  Serial.println(f);
  N = (16000000 / 1024 / f ) - 1;
  OCR2A = N;
  OCR2B = N/2;

}

Hi this is what i have written. and i need output a square wave with timer, its frequency is measured from input signal in pin 5. After connecting the oscilloscope, i see the problem, there is phase shift between 2 signals. How could i synchronize this 2 signals?(rising edge to rising edge, falling edge to falling edge) Thank u so much for your help!


texts: How to get the rightmost four bits from a byte

texts: I have a byte that I am looking to break into 2 nibbles. The leftmost nibble I can get easily via shifting right 4 times. However, I can't figure out how to get the rightmost nibble. Any ideas?


texts: Determining which section of code uses the most flash

texts:
I'm running into the 32k flash ceiling of my 328p. The code is pretty compact but I need help making it smaller.

Is there an analysis tool (part of avr?) that can tell me which functions take up the most space?  Obviously looking at the source code won't help because I don't know how the compiler decides to reorganize things.

I've moved strings to PROGMEM, but I'm still hitting the ceiling.

What are some tips for space saving?
What are some ways of seeing what's taking up the most space?


texts: Define a string with single quotation marks?

texts:
This is kind of a short question. All I want to know is, if I can define a string using single quotation marks ('), instead of the regular ones("). I want to use it in a function like this:
print('Hello world');

I unfortunately do not have an Arduino nearby so I cannot test it myself.


texts:
I'm new to Arduino and C.
This behavior is not what I'd expect:

Serial.begin(9600);
while ( ! Serial );

int myCount = 0;

for (int i=0; i<10; i++) {
    myCount = min( ++myCount, 8 );
    Serial.print( myCount );
    Serial.print( "  " );
}

I would expect:

1  2  3  4  5  6  7  8  8  8

But I get:

2  4  6  8  8  8  8  8  8  8

Why is my code counting by 2?


texts:
I'm working on a robotics project where an arduino nano is acting as the motion controller. I'm trying to use a trapezoidal motion profile generator and PID loop to follow that profile, but I found out the motion was quite jerky and I assumed it's because both the motion profile and the PID run at the same speed (10ms loop using timer interrupt library)
#include <TimerOne.h>
void setup() {
  Timer1.initialize(10000);
  Timer1.attachInterrupt(Compute);
}

now I want to use two seperate loops, one running at the same 10ms interval for the profile generation and one running at 1ms for the PID (I'm not sure if the motors can actually act that quickly, but I can adjust the timings a bit), this way the PID has about 10 loops to get to the desired position accurately, reducing the jerky motion.
I'm not sure how I can set up two different interrupts using that library or by setting the flags like TCCR0A to generate the desired interrupt timers.
Here's the actual "Compute" function in case it's relevant (there are some bugs regarding the direction and it's using two different methods for generating the profile, also I'm changing it so don't think it matters, but just in case it does, I posted it)
void Compute(){
  int dir;
  if (setPoint > target){
    dir = 1;
  } else if (setPoint < target){
    dir = -1;
  }
  if (mode == 1) {
    target += v*dir;
    if (abs(setPoint - target) <= turningPoint){
      v -= acceleration;
    } else {
      if (v < maxV){
        v += acceleration;
      }
    }
    if (abs(target) >= abs(setPoint)){
      target = setPoint;
      mode = 0;
      v = 0;
      Serial.println("Finished!");
    }
    #ifdef DEBUG
      printDebug();
    #endif
  } else if (mode ==2){
    target += v*dir;
    if (phase == 1 and v < reachableV){
      v += acceleration;
      if (v >= reachableV){
        phase = 3;
        v = reachableV;
      }
    } else if (phase == 3){
      v -= acceleration;
      if (v <= 0){
        target = setPoint;
        mode = 0;
        v = 0;
        phase = 0;
        Serial.println("Finished!");
      }
    }
    #ifdef DEBUG
      printDebug();
    #endif
  }
  error = target- pos;
/////////////////////////////////////////////////
  PID_P = kp * error;
  if (PID_P > outMax) PID_P = outMax;
  if (PID_P < outMin) PID_P = outMin;
/////////////////////////////////////////////////
  if (abs(error) < 50){
    PID_I += ki * error * sampleTime;
  } else {
    PID_I *= 0.8;
  }
/////////////////////////////////////////////////
  PID_D = kd * (pos - lastPos) / sampleTime;
  if (PID_D > outMax) PID_D = outMax;
  if (PID_D < outMin) PID_D = outMin;
/////////////////////////////////////////////////
  output = PID_P - PID_D + PID_I;
  if (output > outMax) output = outMax;
  if (output < outMin) output = outMin;
/////////////////////////////////////////////////
  lastPos = pos;
  if (output < 0){
    digitalWrite(DIR,1);
  } else {
    digitalWrite(DIR,0);
  }
  analogWrite(PWM,abs(output));
/////////////////////////////////////////////////
}

p.s: I'm most likly going to use the PID library instead of trying to write my own like I currently have the code.


texts: How to control Arduino robot wirelessly?

texts:
I have a few potentiometers connected to analog inputs in an Arduino UNO. These are then processed and then the servo motors start moving to move the bot.
I would like to keep the motors with the uno and send signals from the pots to the uno. I do not want to use a laptop or another arduino as the remote control. However.. XBEE and other related stuff will do... Thanks

Edit- The wireless solution has to cover a long range preferrably 1 mile.(I dont think I will get any that will cover a mile but I'll give it a try.)

Edit 2- I have 8 servos and 4 potentiometer. I don't necessarily need an xbee. However it may be used.


texts: I am currently building my first Arduino project : a car that you can control from your computer. I have my Arduino Mega that outputs 3.3 or 5V and my stepper that receives 12-25V, how can I make my Arduino digitally write something to that stepper?


texts: How to power Arduino externally for long term?

texts:
For a robotic project, I need to keep an Arduino powered up for a long time in an outdoor environment. What can I use to power the board?
If battery is the only solution, can the device tell me remotely that battery is getting low?

It needs to be powered for at least few days ( at least). The unit monitors an outdoor sensor that is shaded from sun but still exposed to wind and moisture. The unit does not move.


texts: Can I power a LilyPad with an iPhone lightning port?

texts: I want to make a toy car that follows a black line on the ground by using two sensor on the left and right sides of the car both pointing down. The sensor converts the light into a voltage that I will use to make the car turn left or right. I know that I can use batteries, but I am still very curious to find out if I could use my iPhone to power an Arduino because I also want to make a case with different sensors in it, and it would be thinner if I didn't have to put a 9V battery in the case.


texts: How to make auto keyboard using arduino nano V3.0 ATmega 328P ?

texts: I have an Arduino Nano v3.0 ATmega328p board. I want to make an auto keyboard that types in a string when its plugged in. I have googled and found that these chips doesn't support that feature unlike "pro micro". keyboard.h is not supported with this chips. So is there any alternative way to use it as a HID and emulate keyboard inputs using any other additional shield other than using the built in USB port. Im a noob in this field, please help. Thanks in advance.


texts: Arduino HTTPClient passing string to variable

texts:
For some reason I can't seem to pass a simple string from one variable to another. Below is my code:

  HTTPClient http; // Declare an object of class HTTPClient
  http.begin(address); // Specify request destination
  int httpCode = http.GET(); // Send the request

  Serial.println("String: " + http.getString());

  String prp = http.getString();
  Serial.println("temp string: " + prp);

It prints out:

  String: < ! DOCTYPE HTML>
  26

  temp string:

Why doesnt my string get correctly passed on to my temporary string variable?

Tom


texts:
If you want to submit sensor data such as temperature to a remote server/database somewhere you need to use some kind of call to a web server since it isn't possible to connect directly to a database from the Arduino.

How do you post data to a JSON web service from an Arduino that's connected to the Internet?


texts:
Last time, when I supplied 12 V from a power supply to the Arduino's 5V pin, it blew up. This time I'm going to use an adapter. Why does an adapter with a 12 V input not blow an Arduino up, as in the previous case?

Or, should I have supplied 12 V to Vin pin, instead of the 5 V pin?

Edit: Sorry for saying 12V input, it is written 12V output and I meant a power adapter that is plugged into wall.


texts:
I am moving my first steps into Arduino and electronics and I have tried to program an LCD 1602A display following this tutorial.

I managed to complete the tutorial up to setting up the contrasts of the display using the potentiometer (on the display I get nice "white" rectangles), but when I tried to upload the code provided I get no text on the display.

I checked and I connected pins the right way but I suspect that my soldering skills might affect the final result: the pins seem wiggly and even just to power up the display I have to adjust the cable connections quite a bit before the LCD turns on.

Which steps should I follow to check that the pins are soldered correctly and that the right current flows through each of them? I figured I could use a multimeter to check the intensity through and voltage applied to each of the pins, but I have no clue what readings I should get. How should I proceed?

EDIT (2016/12/12)>
Here is the picture showing the step I got stuck

And here is a picture showing the soldering I did:

Also I checked with the multimeter and each of the pin passes a continuity measurement.

What else can I try?


texts: trigger a function of a Arduino Uno from signal received by LoRa module

texts: I have two sx1278 Lora transceivers where both are connected to two Arduino Uno boards. I want to trigger a function in the Arduino Uno board where receiver side of LoRa connected using the signal received by Lora receiver.


texts: Why the need to use the volatile keyword on global variables when handling interrupts in Arduino?

texts:
I am familiar with the keyword Volatile being used to declare variables that are shared among multiple threads on a software application (basically on a multithreaded application).

But why do I need to declare a variable as Volatile when running the code on an an Arduino interrupt? Is the code running in the interrupt executing on different thread? Is there something else going on?


texts: The code does not produce the serial output

texts:
#include <Streaming.h>
#include <StopWatch.h>
#include <Albert.h>
#include "avdweb_AnalogReadFast.h"
const byte adcPin = A0;
void setup(void)
{
    Serial.begin(9600);
    while(!Serial);
    Serial << "\nanalogRead_10bit us1 analogRead_12bit us2 analogReadFast_10bit us3 analogReadFast_12bit us4";
    for(int i=0; i<10; i++)
        testAnalogRead();
}
void testAnalogRead()
{
    static Stopwatch stopwatch(micros);
    //delay(1000);

    stopwatch.start();
    int adc1 = analogRead(adcPin); // default resolution 10bit 425us on SAMD21
    stopwatch.stop();
    int t1 = stopwatch.interval;

    analogReadResolution(12);
    stopwatch.start();
    int adc2 = analogRead(adcPin); // 425us on SAMD21
    stopwatch.stop();
    int t2 = stopwatch.interval;

    analogReadResolution(10);
    stopwatch.start();
    int adc3 = analogReadFast(adcPin); // 23us on SAMD21
    stopwatch.stop();
    int t3 = stopwatch.interval;

    analogReadResolution(12);
    stopwatch.start();
    int adc4 = analogReadFast(adcPin); // 24us on SAMD21
    stopwatch.stop();
    int t4 = stopwatch.interval;

    Serial << endl << adc1, t1, adc2, t2, adc3, t3, adc4, t4;
    analogReadResolution(10); // restore default
}
void loop()
{
}

This code does compile in the Arduino Zero, but does not produce the serial output on the serial monitor (serial plotter) at all.

What am I doing wrong?


texts: How to display an entire incoming string from the serial monitor in arduino ide?

texts:
this is my first question in this forum.

I need to receive a string from the Arduino serial monitor and display it when the communication is over. I have a similar problem like the one discussed in this thread:

https://electronics.stackexchange.com/questions/45543/how-do-i-receive-an-entire-string-as-opposed-to-1-character-at-a-time-on-the-ard

Only I'm using the Arduino serial monitor instead of a RaspberryPi to send strings so I can't program the sender to attach an identifier like '\n' at the end of the string.

char inData[20];
char inChar=-1;
byte index = 0;

while (Serial.available() > 0){
  ending[1]=ending[1]+1;
  if(index < 19){

      inChar = Serial.read();
      inData[index] = inChar;
      index++;
      inData[index] = '\0';
      Serial.flush();
  }
  Serial.print(inData);Serial.print("\t");Serial.println();
}

What I receive in the console looks like this:

M
Me
Mes
Mess
Messa
Messag
Message

I need to display only the final string

Message

The code has to know when the incoming string ended and then display it once.

I'd really appreciate any help I can get.


texts: Using SCL and SDA of ESP8266-01 with GY-30 BH1750FVI for lux measurement

texts:
I followed this tutorial to get lux measurement from GY-30 BH1750 with Arduino.

It's working fine. But now I want to use it with ESP8266-01.

I read Pin 4 is SDA and 5 is SCL for it. But it's not working. Can someone tell me what do I need to change in the code? I'm a "bit" confused about the addressing.

Following is the code for Arduino:

#include <Wire.h>

int BH1750_address = 0x23; // i2c Addresse
byte buff[2];

void setup() {
  Wire.begin();
  BH1750_Init(BH1750_address);

  delay(200);
  Serial.begin(9600);
  Serial.println("Starte Beleuchtungsstaerkemessung - blog.simtronyx.de");
}

void loop(){
  float valf=0;
  if(BH1750_Read(BH1750_address)==2){
    valf=((buff[0]<<8)|buff[1])/1.2;

    if(valf<0)Serial.print("> 65535");
    else Serial.print((int)valf,DEC);

    Serial.println(" lx");
  }
  delay(1000);
}

void BH1750_Init(int address) {
  Wire.beginTransmission(address);
  Wire.write(0x10); // 1 [lux] aufloesung
  Wire.endTransmission();
}

byte BH1750_Read(int address) {
  byte i=0;
  Wire.beginTransmission(address);
  Wire.requestFrom(address, 2);
  while(Wire.available()){
    buff[i] = Wire.read();
    i++;
  }
  Wire.endTransmission();
  return i;
}


texts:
I want to control 61 SMD 3528 RGB LEDs (KT-SMD3528-RGB) with 3 arduino Micro's 3 PWM pins.
I learned from reading up that I'll have to use 3 NPN Transistors to control RGB LEDs and external power source.

So I decided to go with external 5V power supply to power up those LEDs and since I have 61 of them and I'm noob in calculating power requirements I would like to ask a question of how much amperage draw I'll need a power supply

I have 3528 RGB led which draws roughly 25mA on each channel, meaning I'll need
25*61 = 1.5 Amp to power up each channel. Does this mean I'll need 3*1.5=4.5 Amp 5V power supply?

Also regarding resistors as I understand some channels have more Vd than others (I haven't measured them yet as I'm still waiting for shipment to arrive) but according to sellers, specs are 1.8 to 3.5 Vd on those SMD LEDs. So for example to calculate resistor I need for 1.8 Vd I need to do math like this (5-1.8)/0.025 = 128 meaning I'll need at least 128 Ohm resistor for each led channel. Is my logic correct?

Also regarding NPN transistor for each channel I need a transistor that could sustain at least 1.5 Amp is this also correct?


texts: ESP8266 cannot connect to an existing network after using AT command

texts:
I followed this tutorial to connect the ESP8266 to a wifi network using AT commands. I used the below schematics (without the connection between ESP's CPIO 0 and Arduino's Ground):

After that, I was able to follow through the tutorial and got this response in the Serial Monitor:

That means my ESP8266 has successfully connected to my Wifi named W3. However, I decided to switch the mode of my ESP8266 from Network Device (mode 1) to Both network device AND Access Point (mode 3) (at this point I called AT+CWJAP? and can still see that it's connected to W3 wifi). I then was able to see the ESP wifi in my wifi list as (AI-THINKER_4C8CF2) but when I connected to it, I cannot connect to the internet. I'm wondering what the problem is and would appreciate any help.

Note: The reason why I switched to mode 3 is because I want to control an Arduino Pro Mini (instead of Arduino Pro) using NodeJS. I followed another tutorial and I figured that I need to connect to an ESP8266 access point.

I uploaded the StandardFirmataSketchPlus to my Arduino Pro Mini, with the baud rate set to 115200 (which is the same baud rate with my ESP8266). The schematic I used is similar to the one below, except I used a 3.3V Pro Mini and a Lipo battery, instead of a 5V:

The nodejs code is below:

var VirtualSerialPort = require('udp-serial').SerialPort;
var firmata = require('firmata');
var five = require("johnny-five");
var sp = new VirtualSerialPort({
  host: '192.168.1.243' //I got this number from the AT command (STAIP above)
 });

var io = new firmata.Board(sp);

io.once('ready', function(){
    io.isReady = true;

    var board = new five.Board({io: io, repl: true});

    board.on('ready', function(){
        var led = new five.Led(12);
        led.blink(3000);
    });
});

This code is to test the connection between Arduino and Nodejs and when I run this file, it doesn't work.


texts: Does millis() conflict with the PWM pins associated with timer 0?

texts:
I've read that the millis() function uses the same timer as a couple of PWM pins.

If you're using those PWM pins, will millis() still return the correct value?


texts: I want to make a CNC machine that uses 5 NEMA 17 rated for 2A and a RAMPS 1.4 to control it all. I have a power supply that can deliver 1.5A at 12V. Is it enough? I am worried that when all 5 motors are under load, the amperage will get distributed and there will be very low amperage per motor.


texts: Is arduino suitable for high frequency application?

texts:
Can I use the arduino for an application with a frequency of 4 MHz?

I need to create a clk with this frequency and send and receive data on the rising and falling edges. and it is not a normal SPI interface I have my own conditions so I need to do it manually.

If it is not suitable, is it technically possible?


texts: Unable to load the arduino sketch through ISCP/serial interface

texts:
I am unable to load the customized Arduino sketch from one board to another through Arduino ISP or bootloader. I am able to replicate the same through ISCP pins only if the slave board is connected to the Master board through serial interface(using RESET) else, the slave board loses memory once the serial port is disconnected. I am looking to permanently load the sketch to Arduino slave for bootload testing.
Also, is it possible to power on digital pins such as D7 or D4 through serial interface ?? By default the serial interface produces output only through D13.
NOTE - I am using Arduino Uno as both Master and Slave.
Thanks in Advance.


texts:
I have ldr module with 4 pins
 1. Vin
 2. Gnd
 3. AO
 4. DO

I want to know how can i take advantage of DO suppose i want to turn on lcd display when light falls on the ldr sensor!

I have noticed when light falls on ldr sensor the Green  led with DO written next to it lights up.


texts:
I am working on an esp8266 and I am connecting it with Arduino Uno. I have programmed the Arduino but when I write AT command on the serial monitor it doesn't show anything.The connections which i have made are:

tx uno - rx esp
rx uno - tx esp
gnd uno -gnd esp
vcc and ch_pd - 3.3v supply

I am using an external supply and not the 3.3v from the Arduino.
I need help with this.


texts: Arduino due - Getting 0xFF (garbage) from serial

texts:
I am developing application with serial communication with arduino due.

Like this:

while(1)
{
  if(Serial2.available() > 0){
  byte l_byData = Serial2.read ();
  Serial.println(l_byData,HEX);
  }
}

But I am getting "0xFF" from serial very frequently.

I am using Arduino 1.6.6 IDE.

Can anyone help on this?


texts:
I have a rig with 5 light sensors on an I2C mux and I am wondering if I need only 1 pull-up resister set for the whole bus or one on each branch from the mux?
Or should I remove all the pull-ups from the branches and leave the one on the mux?
My issue is that the Arduino softlocks after 5-60 min of running, and it always softlocks on a read lux call.


texts: Port manipulation in Arduino using byte value

texts:
I'm trying to write PORTB and PORTD in ATmega328P using byte system like this,

    //  PD7  PD6  PD5  PD4  PD3  PD2  PD1  PD0
    //  N     N    N    N    N    U    U    U
    //  7     6    5    4    3    2    1    0
    //======================================
    //  PB7  PB6  PB5  PB4  PB3  PB2  PB1  PB0
    //  X     X    1    1    1    1    1    1
    //  C     C    13   12   11   10   9    8
    //======================================
    //C-Crystal Pins/U-Un used/N-Used/X-unknown value

    byte pins[] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};

    //uint16_t style1=1365; //10101010101
    //uint16_t style2=682;  //01010101010

    void setup() {
      for (int i = 0; i < 11; i++) {
        pinMode(pins[i],OUTPUT);
        PORTD=B00000000;
        PORTB=B00000000;
      }

    }

    void loop() {
      PORTD=B10101000;
      PORTB=B00101010;
      delay(1000);
      PORTD=B01010000;
      PORTB=B00010101;

    }

According to this , Port value should be swapped.
But, It's still remaining given value of the code before delay()

What is the problem in this code?


texts:
I don't think USB chip is more expensive than Ethernet chip. So, I expect there should exist a board like Arduino, but where USB is removed in favour of Ethernet.

Are there such boards?


texts: Is it advisable to reload Pro Mini with the bootloader originally designed for UNO to save 1.5 KB flash space?

texts:
In order to allow bigger user program size, is it possible and advisable to reload Pro Mini with the boot loader originally designed for UNO. This will save 1.5 KB flash space (UNO boot loader is 0.5KB, Pro Mini is 2KB).

Using a smaller boot loader is an 'intermediate' step to get more space while still enjoy the easy benefit of the Arduino IDE and many library/code example. Of course, ultimate step is to remove all boot loader (only small saving of 0.5KB if above is possible) and switch to ATmel development environment, ATmel studio, which is complex but programmer has full control of everything.

Did I miss anything in the followings?

I tend to believe that it is possible as

a) same ATMega328 chip is used in both board

b) Pro Mini is essentially cutting UNO into two halves, the MCU and the USB/Serial converter now use external USB to Serial converter

If the Pro Mini board is reloaded with UNO boot loader, how should the boards.txt file be edited to reflect the changes so that the IDE will handle it correctly?

Many thanks in advance


texts:
I'm trying to create a car that's being controlled by an Arduino.
I'm using the following chasis:
http://www.aliexpress.com/item-img/New-2WD-car-chassis-DC-gear-motor-wheels-easy-assembly-and-expansion-car-toys-robot-toys/32310649967.html

And L298N motor driver.

The problem is it's hard to make the car go straight. Giving the same PWM value to the motors still makes them spin in different speeds, trying to calibrate the value is hard and every time I recharge my batteries the value changes.

What are my options on making the car go straight when I want (well, sometimes I'll want to turn it around of course)?

I've thought about using an encoder but I wish to avoid that since it will complicate the whole project, is there any other viable option? and even when using an encoder, Does it means I will need to keep track all the time and always adjust the motors value continuously? is there some built-in library for that?

Thanks in advance!


texts:
I am beginning to get a bit confused about sampling rates and baudrates etc. I have this Arduino code:

#include <eHealth.h>

extern volatile unsigned long timer0_overflow_count;
float fanalog0;
int analog0;
unsigned long time;

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

void loop() {
  while (Serial.available()>0){
    serialByte=Serial.read();
    if (serialByte=='S'){
      while(1){
        fanalog0=eHealth.getECG();
        // Use the timer0 => 1 tick every 4 us
        time=(timer0_overflow_count << 8) + TCNT0;
        // Microseconds conversion.
        time=(time*4);
        //Print in a file for simulation
        //Serial.print(time);
        //Serial.print(" ");
        Serial.print(fanalog0,5);
        Serial.print("\n");

        if (Serial.available()>0){
          serialByte=Serial.read();
          if (serialByte=='F')  break;
        }
      }
    }
  }
}

Since there is no delay interrupt, what is the sampling rate/frequency? Is it based on the Arduino ADC speed? When I increase the baudrate am I increasing the sampling frequency or just the rate at which I send data over the serial port?


texts:
I have wired up a 6502 to run a program, and to check what is happening on address and databus, I have built a monitor setup with an Arduino Mega2560. The monitor should read from the buses, each time the clock signal rises. (This is basically from Ben Eaters YouTube videos.)
The problem I am experiencing now, is that the Arduino seems to detect rising edges. Sometimes it is a few extra, sometimes it just keeps firing, while the clock signal is steady high. I have wired up a logic analyzer to see where and if the signal is bouncing. But even going up to 48MHz, I do not see any bouncing going on.
This is code I use to wire up the clock edge:
#define CLOCK 2

void setup() {
  pinMode(CLOCK, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(CLOCK), onClock, RISING);
}

static void onClock() {
  // read signals from data and address
  // send that info out over the serial port
}

Update I have wired a LED with a 220Ohm resistor to ground connected. When removed, the problem seems to be gone.


texts: Servo start to turn like madman with simple if statement

texts:
I tried to write a simple program. Press button 1 servo goes to position 1, press button 2 servo goes to position 2.

But when I hook everything up my Servo goes full Crazy mode. It starts to jiggle back and forth like a madman. Even when I unhook the buttons.

What is the mistake I made? Any help is appreciated :D

Thanks in advance

/* Sweep
     by BARRAGAN <http://barraganstudio.com>
     This example code is in the public domain.

     modified 8 Nov 2013
     by Scott Fitzgerald
     http://www.arduino.cc/en/Tutorial/Sweep

    modified 5-12-2017
*/

#include <Servo.h>

Servo myservo;  // create servo object to control a servo

int buttonState = 0;         // variable for reading the pushbutton status
int buttonState2 = 0;        // variable for reading the pushbutton status
const int buttonPin = 4;     // the number of the pushbutton pin
const int buttonPin2 = 5;    // the number of the pushbutton pin

void setup() {
  myservo.attach(9);         // attaches the servo on pin 9 to the servo object
  pinMode(buttonPin, INPUT);
  pinMode(buttonPin2, INPUT);
}

void loop() {
  buttonState = digitalRead(buttonPin);
  buttonState2 = digitalRead(buttonPin2);
  if (buttonState == HIGH) {
    myservo.write(173);        // tell servo to go to position
    delay(25);                 // waits 25ms for the servo to reach the position
  }
  if (buttonState2 == HIGH) {
    myservo.write(97);         // tell servo to go to position
    delay(25);                 // waits 25ms for the servo to reach the position
  }
}


texts:
I'm testing SIM800L GSM module with Arduino UNO and module is blinking 3 times every 15 seconds or sometime every 45 seconds. Why this is happening?
In serial monitor it shows Message Sent Successfully! but I'm not getting any message.I tried with multiple numbers. Still not getting any message.

I have tested several codes which shows outputs of AT commands. Nothing was working. Power supply is 5V 5A.

/*
 *   Author@ExploreEmbedded
 *   Example to Send messages Interactively using GSM Sim800L
 *
 *   LIBRARY CREDITS:
 *   Thanks to Cristian Steib(steibkhriz@gmail.com) for the library.
 *
 *
 *
 *      PINOUT:
 *        _____________________________
 *       |  ARDUINO UNO >>>   Sim800L  |
 *        -----------------------------
 *            GND      >>>   GND
 *        RX  10       >>>   TX
 *        TX  11       >>>   RX
 *       RESET 2       >>>   RST
 *
 *
*/

#include <Sim800L.h>
#include <SoftwareSerial.h> //is necesary for the library!!
Sim800L Sim800L;  //to declare the library
char text[161]=""; //buffer to store message
char number[11]=""; //phone number to send message
int cnt;
bool error; //to catch the response of sendSms

void setup(){
    Sim800L.begin(); // initializate the library.
    Serial.begin(9600);
}

void loop(){

      //Read the Number
      Serial.print("\nEnter 10 digit Phone Number:");
      while(Serial.available()<=0);
      cnt = Serial.readBytesUntil('\n',number, 11);
      number[cnt] = '\0';
      Serial.println(number);

      //clear the serial input buffer so that no typed characters are pending

      delay(1000); //delay required before clearing the input buffer
      while(Serial.available()>0) //clear buffer
      {
        Serial.read();
      }

      //Read the Message to be sent
      Serial.print("Enter Message:");
      while(Serial.available()<=0);
      cnt = Serial.readBytesUntil('\n',text, 160);
      text[cnt] = '\0';
      Serial.println(text);
      delay(1000);

      while(Serial.available()>0) //clear buffer
      {
        Serial.read();
      }

      //Send the message and display the status
      error = Sim800L.sendSms(number,text);
      if(error)
      Serial.println("Error Sending Message");
      Serial.println("Message Sent Successfully!");

}


texts:
There exists a large variety of sensors in the Grove System. Usually these are accessed via a special shield (Grove base shield).

Can I access these sensor directly without a shield. In particular I am interested in using them with an Arduino Pro Mini. My guess is that one definitely needs the 5V version of the Mini, but other than this? How fiddly is it to use these sensors directly?

I am interested in using the Grove dust sensor, but I am also would like to operate a Grove 4 digit display.


texts: How to get power for a nexus 7 while reading serial data from an arduino over usb?

texts: Does anyone know how to simultaneously power a Nexus 7 tablet while simultaneously reading serial data from an arduino over USB? I have had quite some trouble with this and have attempted multiple combinations of usb splitters but no luck. I have also tried to use the nexus's inductive charging while using the arduino usb power. While this does work I need to use the Nexus NFC chip at the same time. What I really need is a solution that allows me USB Data, NFC, and power all at the same time.


texts:
I am in the process of making a talking robot and I have linked my ESP32 to a Google text-to-speech service. The service returns me a base64 8-bit audio response.
I need to play this audio and I can't figure out how to do it. I know that an audio playing library exist for PCM but the data that it requires is not base64.


texts: Issues with interrupts coming from RTC DS3231 and power supply interference

texts:
Several months ago I developed a device able to detect water flood in a closed space and do some operations in case (closing valves, issuing an acoustic and Bluetooth alarm etc.).
After 8 hours it tries to reopen the valves and restart the normal cycle. Arduino UNO is always in sleeping mode (this device remains active 7/24). It wakes up every minute (@ sec.00) to detect presence of water, checks for 4 cycles (4 minutes) the presence of water -if the sensors are on- and then, after have issued the alarms and closed the valves, it wakes up after 8 hours, in order to reopen the valves and come back in its normal check-mode.
It worked and works flawlessly, when left working on my table. I tried it for almost a month.  The problem raised when I installed it in place, because there is a water pump (an autoclave, of some 1,5Hp, 1 phase), connected on the same power supply line, that -of course- starts whenever somebody opens a water valve at home.
Whenever it starts, Arduino wakes up immediately and the 1 minute (or 8 hours waiting cycle) stops.

I tried to use several caps on the 12V power supply line (some 3000uF, 50Vl in total) and a EMI filter between the power supply line and my device, but nothing changed.

I made some mods on the software, checking if the wakeup hour and minute is compatible with the correctly wakeup time calculated and setted on Arduino, and storing an alarm flag with wakeup hour and minute in EEPROM, in order to manage the same check if Arduino undergoes a hardware reset or is turned off/on.

I suspect that the problem raises for the fact that the RTC interrupt is activated when the IRQ pin is lowered from the HIGH state.
There is a way to set the DS3231 to remain in LOW state always, and issue a HIGH level just for the interrupts?
Does anybody have any electrical suggestion? I use this 12V chinese switching UPS/power supply connected to a 12V-7Ah lead battery that assures no interruptions.


texts: Burning the Arduino bootloader without an extra Arduino board

texts:
Is there any way to burn the Arduino bootloader on a standalone Atmega328 (internal clock 8MHz) from the Arduino official website without using an extra Arduino board to burn the bootloader?

I mean, is it possible to burn the bootloader on the Arduino and then remove the ATmega chip from the Arduino board and use it in a breadboard?

Thanks.


texts: STM32 Bluepill with Arduino IDE can not blink LEDs with a few pins

texts: There are a couple pins such as PB4, PA15, and the ones near it where it won't allow me to blink LEDs with. They are stuck at a constant voltage, one that is around 1.5V, which is lower than minimum output. This happened on both STMs. The issue is more apparent when trying to blink LEDs inside of a big program. I don't know why this is.


texts: Arduino SPI - MOSI not writing any data but clock works

texts:
I am trying to iterate over an int array and writing those values to a chip. Here is my code.

#include <SPI.h>

int sine[] = {0x7fc ,0x868 ,0x8d4 ,0x93c ,0x9a8 ,0xa10 ,0xa78 ,0xadc
,0xb3c ,0xba0 ,0xbfc ,0xc58 ,0xcb0 ,0xd04 ,0xd58 ,0xda4 ,0xdf0 ,0xe34 ,0xe74
,0xeb0 ,0xee8 ,0xf1c ,0xf4c ,0xf74 ,0xf98 ,0xfb8 ,0xfd0 ,0xfe4 ,0xff0 ,0xff8
,0xffc ,0xff8 ,0xff0 ,0xfe4 ,0xfd0 ,0xfb8 ,0xf98 ,0xf74 ,0xf4c ,0xf1c ,0xee8
,0xeb0 ,0xe74 ,0xe34 ,0xdf0 ,0xda4 ,0xd58 ,0xd04 ,0xcb0 ,0xc58 ,0xbfc ,0xba0
,0xb3c ,0xadc ,0xa78 ,0xa10 ,0x9a8 ,0x93c ,0x8d4 ,0x868 ,0x7fc ,0x794 ,0x728
,0x6bc ,0x654 ,0x5ec ,0x584 ,0x520 ,0x4bc ,0x45c ,0x400 ,0x3a4 ,0x34c ,0x2f4
,0x2a4 ,0x258 ,0x20c ,0x1c8 ,0x188 ,0x148 ,0x110 ,0xe0 ,0xb0 ,0x88 ,0x64 ,0x44
,0x2c ,0x18 ,0xc ,0x0 ,0x0 ,0x0 ,0xc ,0x18 ,0x2c ,0x44 ,0x64 ,0x88 ,0xb0 ,0xe0
,0x110 ,0x148 ,0x188 ,0x1c8 ,0x20c ,0x258 ,0x2a4 ,0x2f4 ,0x34c ,0x3a4 ,0x400
,0x45c ,0x4bc ,0x520 ,0x584 ,0x5ec ,0x654 ,0x6bc ,0x728 ,0x794};

#define samples 120

const int cs = 9;

int counter = 0;

const int chipSelectPin = 10;

void setup()
{
  pinMode(cs,OUTPUT);
  pinMode(chipSelectPin, OUTPUT);

 SPI.beginTransaction(SPISettings(20000,LSBFIRST,SPI_MODE3));
}

void loop()
{

  digitalWrite(cs,LOW);

  SPI.transfer(sine[counter]);

  digitalWrite(cs,HIGH);

  counter += 1;

  if(counter >= samples)
  {
    counter = 0;
  }

}

Very simple, I am using an Arduino nano and according to this reference the clock pin is 13 and MOSI is 11. I am seeing the clock signal for pin 13 but pin 11 is inactive.


texts:
I am not able to combine the below two sketches. What I require is to either run both the loops together or find a way to run both the functions inside a single loop.

Sketch 1

#include <SevSeg.h>
#include <DS1307RTC.h>
#include <Time.h>
#include <TimeLib.h>
#include <Wire.h>

// Create an instance of the object
SevSeg sevseg;
bool militaryTime = false; // true for 24 hour clock

void setup() {
  byte numDigits = 4;
  byte digitPins[] = {2, 3, 4, 5};
  byte segmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13};
  bool resistorsOnSegments = false; // 'false' means resistors are on digit pins
  byte hardwareConfig = COMMON_ANODE; // See README.md for options
  bool updateWithDelays = false; // Default. Recommended
  bool leadingZeros = true; // Use 'true' if you'd like to keep the leading zeros

  sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments, updateWithDelays, leadingZeros);
  sevseg.setBrightness(90);
}

void loop() {
  tmElements_t tm;
  int time;
  int dot;

  if (RTC.read(tm)) {
    time = tm.Hour * 100;
    if (time > 1200 && militaryTime == false) {
      time = time - 1200;
    }
    if (time == 0 && militaryTime == false) {
      time = 1200;
    }
    time += tm.Minute;
  }

  if ((tm.Second % 2) == 0) {
    dot = 4;
  } else {
    dot = 2;
  }

  //Produce an output on the display
  sevseg.refreshDisplay();
  sevseg.setNumber(time, dot);
}

Sketch 2

// Change this to the output pin you are using
#define TICK_PIN A0

void setup()
{
  pinMode(TICK_PIN,OUTPUT);
  while (1) {
    tone(TICK_PIN,1000,2);
    delay(1000);
  }
}

void loop()
{
}


texts: What is the smallest duration that can be measured using micros()?

texts: What is the least value of time that I could measure(count) using micros()?


texts: Is there Arduino shields with blocks of 4 pins that you can plug your servos into and use the fourth pin as signal pin to the Arduino Mega board?


texts: Switching between SPI Devices when one is an SD card

texts: I'm using a USB Barcode scanner connected via a USB shield, I'm able to get the readings from the barcode using this example, After getting this readings, I'd like to save it to an SD card but the SD card won't initialize since the barcode also uses SPI, how can I deactivate the ICSP in order to activate the SD card? Or how to switch between multiple SPI slaves?


texts: help with input in a Simon arduino uno game

texts:
I' making a Simon game with the arduino uno.

I know something is wrong with the inputs but i don't know why or how to fix it.

The problem is the program takes an input and says it is correct no matter what it is or the length

#define NOTES

int tones[] = {NOTE_E5, NOTE_E6, NOTE_CS6, NOTE_A6};
String sequence;

void setup() {
    pinMode(13, OUTPUT); //green
    pinMode(12, OUTPUT); //yellow
    pinMode(11, OUTPUT); //blue
    pinMode(10, OUTPUT); //red
    pinMode(7, INPUT); //green
    pinMode(6, INPUT); //yellow
    pinMode(5, INPUT); //blue
    pinMode(4, INPUT); //red
    Serial.begin(9600);
}

void loop() {
    while(true) {
        delay(1000);
        randomSeed(random(random(1000000000)));
        sequence = String(random(4));
        boolean run = true;
        while(run) {
            for(int i = 0; i < sequence.length(); i++) {
                simonOut(sequence.charAt(i) - '0');
                delay(500);
                simonClear();
                delay(100);
            }
            for(int i = 0; i < sequence.length(); i++) {
                int input = simonIn();
                while(input < 0 || input > 3) {
                    delay(50);
                    input = simonIn();
                }
                if(sequence.charAt(i) - '0' == input) {
                    flash(0);
                    run = false;
                    goto reset;
                }
                else if(i = sequence.length() - 1)
                    flash(3);
            }
            sequence += random(4);
        }
        reset:;
    }
}

void boolOut(long pin, boolean val) {
    digitalWrite(pin,val ? HIGH : LOW);
}

void simonOut(long num) {
    boolOut(num + 10, true);
    tone(2, tones[num]);
}

 void flash(int led) {
     delay(300);
     for(int i = 0; i < 5; i++) {
         simonOut(led);
         delay(100);
         simonClear();
         delay(100);
     }
 }

 void simonClear() {
     for(int i = 0; i < 4; i++){
         boolOut(i + 10, false);
     }
     noTone(2);
 }

 int simonIn() {
     int ret = -1;
     for(int i = 0; i < 4; i++) {
         if(simonIn(i)){
             ret = i;
         }
     }
     if(ret != -1) {
         simonOut(ret);
         delay(500);
         simonClear();
         delay(100);
     }
 }

 boolean simonIn(long num) {
     return digitalRead(num + 4) == HIGH;
 }