texts:
I made this simple piece of code, to make my LED flash.. Which it does when the pin is set low.. But how does that makes sense?

#include "pins_arduino.h"

void setup() {
  // put your setup code here, to run once:
  pinMode(BUILTIN_LED,OUTPUT);
}

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

I am using the Wemos d1 - http://www.wemos.cc/


texts:
I have been working on a project watch which would work best if it is entirely sealed (to waterproof it). The watch may need future updates, but I will be unable to send code to it using a usb connector or isp programmer without opening the case. What is the best way to connect my PC with this watch wirelessly?

I gather that the serial ports are usually used to send code via the usb, and that most Bluetooth modules use serial coms to communicate with the Arduino.

The Arduino that I am using is an Arduino Pro Mini clone.

Any help will be greatly appreciated.


texts: Is it possible to connect miband2 and arduino nano (?)

texts: I want to make an IOT project using an Arduino nano and I need heart rate sensors. I I have a miband2. So, is it possible to connect them ?


texts: What is the purpose of Galileo (or other unremovable chips)

texts:
I know the Arduino is a nice quick and dirty prototyping board. You quickly test your idea, and if you want to proceed you can do so with AVRs.

Your options are:

Upload the program to Arduino, then remove the AVR chip and make a PCB (with the bootloader)
Start from scratch with AVR (not always feasible because many libs are in Arduino)

Now what is the purpose of a system that has processors that cannot be removed? For example the Arduino Galileo.

Sure, you can do many things with it, but bottom line, you cannot remove the processor and do something with it.

As an example, imagine you are prototyping a system you wish to, then, market and sell. That is feasible with the Arduino Uno family.

But what if you did in in Galileo? Even if it worked, you couldn't sell your system because you rely on the prototyping board. You cannot remove the processor.

Am i missing something?


texts:
I tried to assemble Adafruit's Arduino LCD 16 x 2 using the instructions RGB LCD Shield: Control a 16x2 Character LCD using 2 pins - Assembly  without any success.

After assembly, I uploaded the HelloWorld example sketch on to the Arduino. The shield doesn't seem to be working. The LCD didn't turn on.

If I push back/press the LCD it turn on. Any idea on how to troubleshoot this?


texts: How to check if all pins are connected on my board to make sure Arduino sends the correct pattern number on my tool

texts:
What to add on this code to check my pins state during run? And how can i trigger error using Visual basic when 1 of my pin is disconnected?

String input = "";

void setup(){

Serial.begin(9600); // Sets up communication with the serial port

pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT); // for start of program operation
pinMode(12,OUTPUT); // for stop of program operation

digitalWrite(6,LOW);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);

digitalWrite(11,LOW);
digitalWrite(12,LOW);

}

void loop(){

int recipe;
//Serial.print("Enter recipe number: ");

while(Serial.available()==0){    // Waits for data from serial port
}

while(Serial.available() > 0){
int data = Serial.read();
  // convert the incoming byte to a char
  // and add it to the string
input += (char)data;

recipe = input.toInt()+'0';    //recipe=0 if not a digit
if(recipe == '0')
  recipe = data;

if(data == '\n'){
  //Serial.print("Recipe: ");
  //Serial.println(recipe);
  //Serial.print("String: ");
  //Serial.println(input);
  input = "";
}
}

if(recipe == 's'){
digitalWrite(11,HIGH);
delay(1000);
digitalWrite(11,LOW);

digitalWrite(6,LOW);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
}

else if(recipe == 't'){
digitalWrite(12,HIGH);
delay(1000);
digitalWrite(12,LOW);

digitalWrite(6,LOW);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
}

else if(recipe>'0' && recipe<'32'){

recipe = recipe-'0';
char binary[7] = {0};   // This is where the binary representation will be stored
recipe += 32; // Adding 32 so that there will always be 6 digits in the string
itoa(recipe,binary,2);  // Convert recipe to a string of base 2 and save it in array 'binary'
char* signals = binary + 1; // Get rid of the most significant digit to get the 5 bits

//Serial.print(signals);    // Print out the signals in binary

int i;
for(i=0; i<5; i++){
  if(signals[i] == '0')
    signals[i] = '1';
  else
    signals[i] = '0';
  digitalWrite(i+6, signals[i]-'0');    // write to pin; converts the bit of the string to HIGH or LOW
  //Serial.print(signals[i]);
}

}
else
loop();

}


texts: Arduino to Raspberry Pi wired communication

texts:
I am new to Raspberry Pi (just brought mine before writing this post), and I am looking to see what is the most ideal way for two way communication between an Arduino and a Raspberry Pi (USB, SPI or I2C).

The reason I am asking is because I need to build a small, semi-autonomous robot and plan on using both the Arduino and Pi to control it, using the pins of the Arduino for the motor control and sensors and the Pi for video processing and autonomous part. Both will be on the robot itself. I am pretty good with the Arduino but never used a Raspberry Pi before.

So my biggest question is what would be the best form of communication for the two boards taking into account speed and safety (there is a voltage difference between the Pi and the Arduino).


texts: ESP8266 + NeoPixel - Cannot set pixel color, I got "Exception 29: StoreProhibited"

texts:
I'm trying to use NeoPixel on the ESP8266.
I made simple test put all required code into setup() and loop() methods. Then, to keep everything in order I create a class LedModule which handle the led strip state, changes, etc.

Here some parts of my class

LedModule::LedModule(unsigned int numOfPixels, uint8_t dataPin)
{
    // When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
    // Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
    // example for more information on possible values.
    pixels = Adafruit_NeoPixel(numOfPixels, dataPin, NEO_GRB + NEO_KHZ800);

    mState = LED_MODULE_STATE_IDLE;
    mIsLedStripOn = false;
}

...

// The method to set all leds of the strip to the same color
void LedModule::turnAllNeoPixelsTo(uint8_t red, uint8_t green, uint8_t blue)
{
    for (uint16_t i = 0; i < getLedCount(); i++)
    {
        // Avoid to light up the middle leds
        if (i < 5 || i > 9)
        {
            pixels.setPixelColor(i, red, green, blue);
        }
        else{
            pixels.setPixelColor(i, 0,0,0); // off
        }
    }
    pixels.show(); // This sends the updated pixel color to the hardware.
    mIsLedStripOn = true;
}

After this changes, when I call the method above, I got the exception:

Exception 29: StoreProhibited: A store referenced a page mapped with an attribute that does not permit stores
Decoding 15 results
0x4020ddbd: ieee80211_send_mgmt at ?? line ?
0x4020db5f: ieee80211_send_mgmt at ?? line ?
0x40102864: trc_NeedRTS at ?? line ?
0x4020fe6d: ieee80211_sta_new_state at ?? line ?
0x402101ab: ieee80211_sta_new_state at ?? line ?
0x4021060f: sta_input at ?? line ?
0x402109cb: ieee80211_parse_wmeparams at ?? line ?
0x402103ab: sta_input at ?? line ?
0x40204ce3: pp_tx_idle_timeout at ?? line ?
0x40204607: ppPeocessRxPktHdr at ?? line ?

It seems to crash during the pixels.setPixelColor(i, red, green, blue); method.


texts:
Today, I've started a decision maker, using a Arduino UNO R3, a button and a RGB led.
This project makes a decision for you (yes, no, or maybe) when you don't know your own decision about something.

The code I used in the project is the following one (written by me):

#define out OUTPUT
#define in INPUT
#define H HIGH
#define L LOW

int red = 2;
int green = 3;
int blue = 4;

int randomValue = 0;

int button = 5;
int buttonState = 0;

void setup(){
    pinMode(red, out);
    pinMode(green, out);
    pinMode(blue, out);

    pinMode(button, in);
}

void loop(){
    buttonState = digitalRead(button);
    if(buttonState == H){
        randomValue = random(0,4);
        if(randomValue == 1){
            digitalWrite(red, H);
            delay(200);
            digitalWrite(red, L);
            clear();
        }
        if(randomValue == 2){
            digitalWrite(green, H);
            delay(200);
            digitalWrite(green, L);
            clear();
        }
        if(randomValue == 3) {
            digitalWrite(blue, H);
            delay(200);
            digitalWrite(blue, L);
            clear();
        }

    }
}

The connections are correct, and the code also. The problem is: when I push the button, the LED starts showing random colors, and what I want is for the LED to show one color per push.

What can I do?


texts: How to filter the power supply for an Arduino in a vehicle (car, motorcycle)?

texts:
I want to use an Arduino (maybe Nano, maybe MEGA) in my motorcycle (a new KTM with lots of electronics).
I checked my test circuit (with the MEGA) and it uses about 100mA (with 5V connected to the 5V pin).

Edit: the bike has a 12v battery and when it's on the generator pushes this up to about 14.3v.

For my first tests I used a 3 terminals DC/DC Regulator with output 5V for the Arduino power supply. If the ignition is on the Arduino works. As soon as I start the bike the Arduino restarts every couple of seconds.

Currently I used the BP5293 DC/DC Regulator because it has 2% precision. Currently I don't have any capacitors on the input or output terminals of that regulator.

I guess I have the following options:

a) Use the BP5293 and add capacitors on the input and/or output terminals. In the datasheet an output capacitor of about 10-330uF is recommended. For the input it recommends a capacitor but without any value given.

b) Use another regulator to 5V

c) Use a regulator to i.e. 7V and then connect that to the Arduino power input and let the Arduino do the filtering of the input.

What is the proper solution and what are suitable values for the capacitors?

I have 100nF ceramic capacitors and Low ESR electrolyte capacitors with 6.3V, 16V and 35V from 68uF up to 3300uF in stock. Obviously I could just try but I prefer to know how it should be done.


texts: How to make a 5-volt relay work with NodeMCU?

texts:
I have hooked up 2 channel 5-volt relays with NodeMCU v1.0 as shown in the fritzing below.

Relay are powered with a different power source than NodeMCU.

As of now, I am powering the NodeMCU from my laptop and the relay board from a 5-volt battery.

Below is the code I have written:

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

const char* ssid = "said.";
const char* password = "secret";
ESP8266WebServer server ( 80 );
const int led = 13;
const int outputLed = 12;

void turnOnRelayOne(){
  digitalWrite (outputLed, 1);
  digitalWrite (5, HIGH); //GPIO 5 // Relay 1
  server.send (200, "text/html", "Relay 1 turned on.");
  digitalWrite (outputLed, 0);
}

void turnOnRelayTwo(){
  digitalWrite (outputLed, 1);
  digitalWrite (4, HIGH); //GPIO 4 // Relay 2
  server.send (200, "text/html", "Relay 2 turned on.");
  digitalWrite (outputLed, 0);
}

void handleRoot() {
  digitalWrite ( led, 1 );

  char temp[400];
  int sec = millis() / 1000;
  int min = sec / 60;
  int hr = min / 60;
  int h = dht.readHumidity();
  int t = dht.readTemperature();
  snprintf ( temp, 400,

             "\
  \
    <meta http-equiv='refresh' content='5'/>\
    <title>NodeMCU hooked to Relay Board</title>\
    \
  \
  \

Hello from NodeMCU!
\

Uptime: %02d:%02d:%02d
\
  \
",

          hr, min % 60, sec % 60
           );
  server.send ( 200, "text/html", temp );
  digitalWrite ( led, 0 );
}

void handleNotFound() {
  digitalWrite ( led, 1 );
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += ( server.method() == HTTP_GET ) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";

  for ( uint8_t i = 0; i < server.args(); i++ ) {
    message += " " + server.argName ( i ) + ": " + server.arg ( i ) + "\n";
  }

  server.send ( 404, "text/plain", message );
  digitalWrite ( led, 0 );
}

void setup ( void ) {
  pinMode ( led, OUTPUT );
  pinMode(10, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(outputLed, OUTPUT);
  digitalWrite ( led, 0 );
  Serial.begin ( 9600 );
  WiFi.begin ( ssid, password );
  Serial.println ( "" );

  // Wait for connection
  while ( WiFi.status() != WL_CONNECTED ) {
    delay ( 500 );
    Serial.print ( "." );
  }

  Serial.println ( "" );
  Serial.print ( "Connected to " );
  Serial.println ( ssid );
  Serial.print ( "IP address: " );
  Serial.println ( WiFi.localIP() );

  if ( MDNS.begin ( "esp8266" ) ) {
    Serial.println ( "MDNS responder started" );
  }

  server.on ( "/", handleRoot );

  server.on ( "/inline", []() {
    server.send ( 200, "text/plain", "this works as well" );
  } );

  server.on("/relay1", turnOnRelayOne);
  server.on("/relay2", turnOnRelayTwo);
  server.onNotFound ( handleNotFound );
  server.begin();
  Serial.println ( "HTTP server started" );
}

void loop (void) {
  server.handleClient();
}

When I execute the URL: 192.168.1.8/relay1 the outputLed blinks as per the logic in turnOnRelayOne.

But neither of the relays turns on. Please help.


texts: avrdude: stk500_rcv :programmer is not responding

texts:
I'm a newbee to Arduino programming and hoping someone can help me with this. These are the error messages.

avrdude: stk500_rcv() : programmer is not responding

avrdude: stk500_getsync() attempt 10 of 10:not in sync:

Problem uploading to board.

I'm using a Arduino UNO clone on com port 3,the blink sketch is functioning. I get the mentioned error message on all sketches I have ran. Not sure what to do.


texts: usart sketch uploaded using makefile gives unusual behaviour

texts:
This is a simple usart program in avr c which just transmits a character.

#include <avr/io.h>
#include <util/delay.h>
#define F_CPU 16000000UL
#define BAUD 9600
#define BAUD_PRESCALLER ((F_CPU / (BAUD * 16UL)) - 1)
void send_val(unsigned char);
int main() {

UBRR0H = (uint8_t)(BAUD_PRESCALLER>>8);
UBRR0L = (uint8_t)(BAUD_PRESCALLER);
UCSR0B = (1<<TXEN0);
unsigned char x = 'B';
while(1) {

    send_val(x);
    _delay_ms(1000);
}

return 0;
}

void send_val(unsigned char v) {
while(!(UCSR0A & (1<<UDRE0)));
UDR0 = v;

}

when I upload this code via the Arduino IDE, everything is fine and the code works as expected.The LED labeled "L" on the PCB is still.

but, when I upload the code using the following Makefile, the code uploads successfully but the outcome is unexpected. I see a weird character(see EDIT) and the LED "L" blinks a couple of times in that 1 sec delay.

CC=avr-gcc
OBJCOPY=avr-objcopy

CFLAGS=-Os -DF_CPU=16000000UL -mmcu=atmega328p
PORT=/dev/ttyACM0

led.hex: led.elf
    ${OBJCOPY} -O ihex -R .eeprom led.elf led.hex

led.elf: led.o
    ${CC} -o led.elf led.o

install: led.hex
    avrdude -F -V -c arduino -p ATMEGA328P -P ${PORT} -b 115200 -U flash:w:led.hex

I referred the Schematics and the led is connected to SCK but I don't understand why the makefile is causing it to trigger.
that blinking of LED is what I think is causing the issue. Does the IDE have some other specific flags while uploading the code or am I committing some silly mistake?

EDIT: I wrote a small program to see the values in the device node /dev/ttyACM0. the ASCII value of the weired character(looks like a question mark) is actually 255.

another issue I noticed is that when I touch the solder beneath the pin 13 (only pin 13) the led L goes off!

As led L is connected to pin 13 I thought this is some hardware issue with my board but then I uploaded the blink led example code, touched the solder and everything is fine.

what could be the actual issue? this is getting mysterious.


texts: Motor shield and wireless transceiver compete for same pins

texts:
I would like to use these 2 components with an Arduino Uno:

Arduino Motor Shield R3
nRF24L01 2.4GHz Wireless Transceiver

I use Stepper for the motor shield, and SPI + RF24 for the wireless transceiver.

I could write 2 sketches that work perfectly, but how can I combine them together?

My issue is that they both require access to pins 11, 12 and 13.

Any help is greatly appreciated!


texts:
I have this array of bytes, that I need to convert to an array of unsigned ints. Also the function (btea) that needs it, seems to need a pointer.

I'm currently using reinterpret_cast which seems to work, but I'd like to know how/why. I'm pretty new to C. It also seems kind of dirty. I could use a for loop, and bitshift everything into a separate int array variable, but that seems wasteful.

uint8_t data[] = {1,2,3,4,5,6,7,8};//can be any multiple of 4 bytes

btea(reinterpret_cast<uint32_t*>(data), sizeof(data)/4, encryption_key);

radio.write(data, sizeof(data));

...

void btea(uint32_t *v, int n)
{
  ...
}

Any pointers (pun intended) are much appreciated.


texts: Streaming IMU data over BLE using Sparkfun 6 DOF and Blend Micro

texts: I am trying to use the RedBear Blend Micro to send data captured by my SparkFun 6 DOF IMU.  I am completely lost, and if anyone has any documentation I can read, or even tutorials that work for this specific IMU, I would highly appreciate it.


texts: Vin and Ground pins shorting only under specific conditions

texts:
So I have an Arduino Nano that I think might have gone bad. The Vin and ground pins are shorting (I'm checking continuity with a multimeter). But it only shorts when:

The Arduino has power
The red lead of the multimeter is on ground and the black is on Vin (not the other way around)

I've tried checking with the leads both ways (red to ground as well as red to vin) while both on and off, and with two different multimeters, one of which is brand new. Completely at a loss for words because this isn't really how physics is supposed to work (continuity shouldn't depend on lead orientation from the multimeter or whether the circuit is powered, right?). Any insight would be appreciated. Do I have a bad board?


texts: How do i wire a switch to control Leds on a arduino nano

texts:
I am wiring some LED's with buttons to trigger them but i don't know if i have the wiring right?

Code

    /* switch
 *
 * Each time the input pin goes from LOW to HIGH (e.g. because of a push-button
 * press), the output pin is toggled from LOW to HIGH or HIGH to LOW.  There's
 * a minimum delay between toggles to debounce the circuit (i.e. to ignore
 * noise).
 *
 * David A. Mellis
 * 21 November 2006
 */

int inPin = 2;         // the number of the input pin
int outPin = 13;       // the number of the output pin

int state = HIGH;      // the current state of the output pin
int reading;           // the current reading from the input pin
int previous = LOW;    // the previous reading from the input pin

// the follow variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long time = 0;         // the last time the output pin was toggled
long debounce = 200;   // the debounce time, increase if the output flickers

void setup()
{
  pinMode(inPin, INPUT);
  pinMode(outPin, OUTPUT);
}

void loop()
{
  reading = digitalRead(inPin);

  // if the input just went from LOW and HIGH and we've waited long enough
  // to ignore any noise on the circuit, toggle the output pin and remember
  // the time
  if (reading == HIGH && previous == LOW && millis() - time > debounce) {
    if (state == HIGH)
      state = LOW;
    else
      state = HIGH;

    time = millis();
  }

  digitalWrite(outPin, state);

  previous = reading;
}

  note
  The code is not set to the pins yet.


texts: Is Teensy compatible with the Arduino keyboard library?

texts: I am thinking about buying some Teensy micro-controllers, but I want to know if the teensy are compatible with the arduino keyboard library.


texts: nodemcu doesnt response in at command mode

texts:
I want to sent AT command into node mcu esp8266 module with arduino IDE  through serial monitor.
I connect the node mcu to arduino uno board in following sequence:
RX to pin 2 of arduino
TX to pin 3 of arduino
Vin of node mcu to 3.3V of arduino
GND to GND
EN of node mcu to 3.3V of arduino
I send at commands in serial monitor but dont get any response.
I also checked different baud rates.
what is the problem? what thing I'm doing wrong?

    #include <SoftwareSerial.h>
SoftwareSerial esp8266(2,3); //2 -->rx  ,3 -->tx

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

void loop() {
  if (esp8266.available()>0)
  {
      char c = esp8266.read();
      Serial.write(c);
  }
  if (Serial.available()>0)
  {
    delay(1000);
    String cmd = "";
    while (Serial.available())
    {
      cmd += (char)Serial.read();
    }
    esp8266.println(cmd);
  }
}


texts: I connected the GSM with Arduino as stated, it responds to commands like AT+CFUN and some other than relating to sim card functionality, I have inserted a working sim card and still brings up CME ERROR 10, I tried enabling the sim detection command AT+CSDT and inserted sim, still same error for calling. When I unplug and power on the module again AT+CSDT goes back to 0. Is there something I'm missing?


texts:
I've got an array of char* with serial data that I'm trying to remove ':' from. I have tried to iterate through the char*, find and remove any colons but it just comes out as garbage.

  char* espData[15];

  // pull data from serial and tokenize with strtok > feed to espData

  for(int x = 0; x < index-1; x++){
    size_t nullTerm = strlen(espData[x]);
    espData[x][nullTerm - 1] = '\0';
    char* output
    for(size_t i = 0; i < strlen(espData[x]); ++i){
      if(espData[x][i] != ':') output += espData[x][i];
    }
    espData[x] = output;
    Serial.println(espData[x]);
  }

Moving the null character works fine (I wanted to get rid of the last character in every string). Most of the answers I found for general C++ used std::string which we don't have access to.


texts: Why does the function esp8266.available() always returns FALSE?

texts:
I am trying to develop an Home automation system using Arduino and ESP8266 Module. But stuck at the very first step while checking is esp8266.available() available or not. This function always returns FALSE. Looking for solution. Thanks in advance.

CONNECTION

Vcc -----> 3.3
CH_PD ---> Vcc
RX ------> 2 (Arduino pin)
TX ------> 3 (Arduino pin)
GND -----> GND (Arduino)

CODE

#include <SoftwareSerial.h>
#define DEBUG true
SoftwareSerial esp8266(2,3);

void setup(){
    Serial.begin(9600);   // Setting the baudrate to 9600
    esp8266.begin(9600);  // Set it according to your esp’s baudrate. Different esp’s have different baud rates.
    pinMode(11,OUTPUT);   // Setting the pin 11 as the output pin.
    digitalWrite(11,LOW); // Making it low.
    pinMode(12,OUTPUT);   // Setting the pin 12 as the output pin..
    digitalWrite(12,LOW); // Making pin 12 low.
    pinMode(13,OUTPUT);   // Setting the pin 13 as the output pin.
    digitalWrite(13,LOW); // Making pin 13 low.
    sendData("AT+RST\r\n",2000,DEBUG);            //This command will reset module to default
    sendData("AT+CWMODE=2\r\n",1000,DEBUG);       // This will configure the mode as access point
    sendData("AT+CIFSR\r\n",1000,DEBUG);          // This will get ip address and will show it
    sendData("AT+CIPMUX=1\r\n",1000,DEBUG);       // This will configure the ESP8266 for multiple connections
    sendData("AT+CIPSERVER=1,80\r\n",1000,DEBUG); // This will set the server on port 80
}

void loop(){
    if(esp8266.available()){  // ALWAYS FALSE
        // My codes
    }
}

UPDATE

At the very first run time, the function is returning TRUE and showing an error

deprecated conversion from string constant to char wwrite strings arduino esp8266.find("+IPD,")

for line number


texts:
I am trying to use map command which is used to power servo 180 degrees as the potentiometer moves...

in fact what i want to do is just when i adjust my potentiometer to zero; stop the dc motor then after turn the pot to 512 analog value turn the motor to the left (digitalWrite(I1, HIGH); digitalWrite(I2, LOW);)and then stop when it reach 512 then when adjust the pot back to zero turn the dc motor to the right (digitalWrite(I1, HIGH); digitalWrite(I2, LOW);) but the think is what i am trying to do is exactly what we can do with the servo motor in the knob http://www.arduino.cc/en/Tutorial/Knob

I'm using a normal DC motor and l293D IC but I want to control the DC as knob method like the 200 degrees.

Code

#define E1 11    // Enable Pin for motor
#define I1 10    // Control pin a for motor
#define I2 9     // Control pin b for motor
const int analogPin = A0;
int analogValue ;

void setup() {
  pinMode(E1, OUTPUT);
  pinMode(I1, OUTPUT);
  pinMode(I2, OUTPUT);

}

void loop() {

  int analogValue = analogRead(analogPin);

  if(analogValue > 0 && analogValue < 512)  {

  analogWrite(E1, 255);
  digitalWrite(I1, HIGH);
  digitalWrite(I2, LOW);
    delay(100);
} else
  analogWrite(E1, 255);
  digitalWrite(I1, LOW);
  digitalWrite(I2, HIGH);
 }


texts: Can I use the Arduino Uno's 3.3v pin while powered by a 9 volt battery?

texts: I have an Arduino Uno. It has a 3.3v pin that I would like to use to power another module that requires 3.3v, and nothing more. If I power my Arduino Uno with a 9 volt battery, will this pin output 3.3v, or will it give more than that?


texts: I want to use the Arduino to control various electronics on my motorcycle. I would need to power the Arduino with the motorcycle battery. So the question is, when the motorcycle is running the alternator will be putting out something like 13v to the battery. So can I still just connect the battery directly to the vIn and ground to power it?


texts: Modify SSID and Passwords in WiFi sktechs

texts:
This is a question about modifying sketches other than through the IDE.

I'm using an Arduino Uno r3 + Arduino WiFi Shield (not the 101).  Up to now I've been using the IDE to manually change the ssids and passwords to connect to wireless networks.  As a next step, I'd like to create something that will let update the ssid and password from a source other than an IDE, preferably a batch or bash file.  Over the air updates are out of the question (way too advanced) so it is safe to assume that all updates will be done via the USB cable.  Based on my limited knowledge of what I think needs to happen, I need to solve the following high-level problems:

Get the computer to recognize that a gateway is plugged into a USB port
Prompt the user to enter the new ssid and network password
Write to the ssid and password fields
Compile the code and save it (equivalent compile/upload in the IDE)
Run the sketch to find and connect to the network

I'd like this to look like two blank fields and a "submit" button to the user.

My imaginary use case is that I'm installing a clone of my gateway/sensor network at a technically-illiterate grandparent's house.  I have no idea where to begin or even if such a thing is possible!Assuming that it is possible, how can I make it easy for them to configure the gateway for use on their home network without resorting to the IDE?


texts: How to uniquely identify NodeMCUv2 board?

texts:
I have several NodeMCU boards, each one is sending temperature measurements to web server through WiFi. As they are gathering data from different palces, it's crucial for server to know exactly from where the measurement it receives comes from.

Is there any way I could identify which NodeMCU is which? Do they have some production code number? ID that doesn't change when I restart them? ID that I could send in POST request to let server know which device is currently updating its status?


texts: Reading Two Quadrature Encoder using a single Arduino Due

texts:
I am working on an autonomous robot in my summer vacations. I am currently working on running the motors of my robot in a closed loop. In order to do so, I have to interface two Quadrature encoders of the motors with the Arduino Due that I have. My motor encoder have 3200 Edges per Revolution. I have read the Atmel SAM3x8E datasheet and have successfully tested one encoder in Arduino IDE. It appears that TIOA0 and TIOBO are used to read PHA and PHB of of one Encoder which correspond to Pin 2 and 13 of Arduino Due. I am not using Index pin (TIOB1).

It seems that I can only interface 1 quadrature .Is their any way I can use Quadrature decoder to read 2 encoders instead of one. As I have stated earlier I am not using the index pin. So, maybe there might be a way to decode to encoders using the three available pins as shown in the above diagram. I don't want to use Interrupts to do this job.

Here's is the link of SAM3x Manual:
http://www.atmel.com/Images/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf

Link of Motor that i am using:
www.pololu.com/product/2824


texts: Understanding the compilation/linking/upload process (so I don't have to use the IDE)

texts: I have started to play with and arduino UNO quite recently (without any prior experience with micro-controllers). I would like to use emacs instead of the IDE, and I'd also like to know what the IDE does under the hood, in order to be able to write my own makefile. The tutorials I've found are either outdated, or are presented as a series of steps without any explanation. I'd appreciate it if someone could explain to me how the whole compliation/linking/upload process works using gcc-avr and avr-dude, and how it is used by the IDE.


texts:
I have connected Arduino with ESP8266 with

Arduino pin 2 connected to ESP's Tx Arduino pin 3 connected to ESP's Rx via Voltage Divider Arduino GND connected to ESP's GND Arduino 3v3 connected to ESP's CH_PD

I have powered ESP8266 using 1117 Voltage regulator

When I initially bought ESP8266 it was working properly(I could even set up a server) but now when I connect it to Arduino an endless stream of garbage values is seen on the Serial Monitor...

The arduino is programmed with the following code

#include <SoftwareSerial.h>

SoftwareSerial esp8266(2,3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.
                             // This means that you need to connect the TX line from the esp to the Arduino's pin 2
                             // and the RX line from the esp to the Arduino's pin 3
void setup()
{
  Serial.begin(9600);
  esp8266.begin(9600); // your esp's baud rate might be different
}

void loop()
{
  if(esp8266.available()) // check if the esp is sending a message
  {
    while(esp8266.available())
    {
      // The esp has data so display its output to the serial window
      char c = esp8266.read(); // read the next character.
      Serial.write(c);
    }
  }

  if(Serial.available())
  {
    // the following delay is required because otherwise the arduino will read the first letter of the command but not the rest
    // In other words without the delay if you use AT+RST, for example, the Arduino will read the letter A send it, then read the rest and send it
    // but we want to send everything at the same time.
    delay(1000);

    String command="";

    while(Serial.available()) // read the command character by character
    {
        // read one character
      command+=(char)Serial.read();
    }
    esp8266.println(command); // send the read character to the esp8266
  }
}


texts:
So I`ve got that mouse with serial connector. It is named serial so it should be easier to connect than even a ps2 mouse, right?

I can`t find any instruction on it. Or should I see instruction on ps2 mouse and plug in the same wires?
Btw mouse has only 4 wires connected inside, as usual PS2 mouse. I want to connect it the same way as ps2 mouse to get easy readings of rotary encoder.

UPD1: I`ve tried to connect it like a PS2 mouse according to this schema with no success. So either a mouse is dead or it uses some kind of different connection?


texts:
I recently obtained a Controllino Mini to be used in a small industrial project. While checking it out I also wanted to test the built-in RTC capabilities. In doing so I toyed around with the available commands from the supplied library. After uploading another sketch it seems I have bricked the Controllino, since I cannot upload anything else :

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

and the reset LED is permanently lid. When looking at the pinout diagram of the Controllino Mini I saw that there was a small remark  near the top stating

  Not proper handling of the RTC/INT output can cause permanent
  controllino reset , so I guess I somehow reached that state.

Since I am pretty new to the whole Arduino / Microcontroller scene I don't really know where to go from here.

Is it a viable idea to try and burn a new bootloader ?
Is there a simpler way to reset the state of the device?
What did I even do wrong ?

Any help is greatly appreciated !

Christian

Below is the sketch that got me into this mess:

#include <Controllino.h>

unsigned char day, weekday, month, year, hour, minute, sec;
#define analogInputPin A0
void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(analogInputPin, INPUT);
Controllino_RTC_init(1);
Serial.print("Initalized RTC: ");
Controllino_SetTimeDate(1,6,4,2016,15,14,10);
}

void loop() {
 Controllino_ReadTimeDate(&day,&weekday,&month,&year,&hour,&minute,&sec);
  float voltage = 15*(analogRead(analogInputPin)/1023.0);
  Serial.print(hour);
  Serial.print(":");
  Serial.print(minute);
  Serial.print(":");
  Serial.print(sec);
  Serial.print(" : ");

  Serial.println(voltage);

}


texts: ESP8266 SoftwareSerial not receiving any character

texts:
I want to use a ESP8266 (ESP12) to receive data from a counter at 9600 baud via SotwareSerial. But my program does not receive any data. I broke it down to the code i attach here. I tried it using different libraries (Arduino SoftwareSerial and also espsoftwareserial) i found. I connected and tested RX and TX in different combinations of the available pins 4/5/12/13/14. But no combination is receiving data at all. I only can send data - checked by oscilloscope. Running my test program attached i connected the RX and TX pin together so i should loop back the data from tx.

I hopefully find somebody in the community who can give me a helpful hint. Thank you in advance!

#include <SoftwareSerial.h>
SoftwareSerial mySerial1(14, 12, false, 256);  // RX, TX

void setup() {
mySerial1.begin(9600);   //  Kommunikation mit Zähler
mySerial1.setTimeout(5000);
mySerial1.listen();
//delay(100);
//mySerial1.listen();

Serial.begin(9600);
delay(1000);
Serial.print(__DATE__);Serial.print(" ");Serial.println(__TIME__);

char ch;
while(1){
  wdt_reset();
  Serial.println("\nSoftware serial test started");
  Serial.print("Data sent: ");
  for (byte i = 32; i < 128; i++) { mySerial1.write(i);
  Serial.print(char(i)); }
  Serial.println();
  mySerial1.println();
  ESP.wdtFeed();
  delay(100);
  Serial.print("Data recv: ");
  if(mySerial1.available()) {
    while(mySerial1.available()){
      ch = mySerial1.read();
      Serial.print(ch);
    }
    Serial.println("_");
  }
  delay(400);
}
}

void loop() {}


texts:
Well, I hope this question won' t be buried to the dark depths of this forum as my previous q' s:) But I suppose it won' t this time cause it's pretty short without this introduction part...

I have an Arduino pro mini works with 3.3V and in the other hand, I have a DS1307 DIP ic, works with +3V. I was wondering if I could connect the ic to my Arduino directly.

Thats all. Thanks already:)


texts:
the aim of the project I'm working on is to water my bonsai automatically, depending on numerous sensor inputs. So basically I have Arduino Nano with huminity and light sensor, a relay to switch the water pump and ESP8266 wifi module, which I use to check the data from the sensors in the Blynk app on my phone. I use two isolated circuits. The first one is used only by the DC motor (water pump) and is supplied by a 5V 600 mA power source. The second takes care of the rest (arduino, ESP, sensors, relay) while it's supplied by a 5V 1A power source. I'm using this with the ESP8266 board.

Once I run the program, it connects to the Blynk server and I can read data from the sensors on my phone. The problem comes when I want to switch the relay from the Blynk app. Than the ESP8266 disconnects (nearly immediately, or after few seconds). I tried a different DC motor (not a water pump) and it worked fine. I also tried to switch the pump without using EPS8266, that worked as well (so the code should be ok). I think this has something to do with the current draw caused by the water pump, but that makes no sense - I'm using two independent circuits, the pump draws maximally 300 mA from the 600 mA source, while the rest of the electronics draws no more than 200 mA from the 1 A power supply. Neither different power supplies, nor another relay worked.

Here's my code:

#define BLYNK_PRINT Serial
#define BLYNK_DEBUG

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

#include <BH1750.h>
#include <Time.h>
#include <SoftwareSerial.h>

#define PUMP  10
#define SENSOR A0
#define BUTTON 2

char ssid[] = "XXXXX";
char pass[] = "XXXXXXXXXXXXXXXXXX";

SoftwareSerial EspSerial(11, 12);
ESP8266 wifi(&EspSerial);

BlynkTimer timer;
BH1750 lightMeter;
int humidity;
int light;
bool pressed = 0  ;
bool pump=1;
char auth[] = "XXXXXXXXXXXXXXXXXXXXXXXXXX";

void sendData(){
      humidity=analogRead(SENSOR);
      light=lightMeter.readLightLevel();
      Blynk.virtualWrite(V0,humidity);
      Blynk.virtualWrite(V1,light);
//      Serial.print("humidity: ");
//      Serial.println(humidity);
//      Serial.print("light: ");
//      Serial.println(light);
}
void checkConnection(){
  if(!Blynk.connected()){
    digitalWrite(PUMP,1);
    Blynk.begin(auth, wifi, ssid, pass);
  }
 }
void checkButton(){
  if(digitalRead(BUTTON) && pressed){
     Blynk.virtualWrite(V3,digitalRead(BUTTON));
     pump=!pump;
//      Serial.println("pump from button");
     }
  else if(digitalRead(BUTTON) && !pressed){
    pressed=1;
    }
  else{
    pressed=0;
    }
}
BLYNK_WRITE(V2)
{
    Serial.println("switching pump");
    pump=!param.asInt();
    digitalWrite(PUMP,pump);
}
void setup() {
  Serial.begin(9600);
  delay(10);
  EspSerial.begin(9600);
  delay(10);
  lightMeter.begin();
  pinMode(PUMP, OUTPUT);
  pinMode(BUTTON, INPUT);
  digitalWrite(PUMP, pump);
  Blynk.begin(auth, wifi, ssid, pass);
  timer.setInterval(5000L, sendData);
  //timer.setInterval(5L, checkButton);
//  timer.setInterval(2000L, checkConnection);
  }

void loop() {
  if (Blynk.connected()) {
      Blynk.run();
      timer.run();
    }
}

and the Blynk log:

[2631095] <[06|05|14|00|00]
[2631389] >[00|05|14|00|C8]
[2632112] <[14|05|15|00|08]vw[00]0[00]632
[2632280] <[14|05|16|00|07]vw[00]1[00]28
[2637109] <[14|05|17|00|08]vw[00]0[00]630
[2637214] <[14|05|18|00|07]vw[00]1[00]28
[2641393] <[06|05|19|00|00]
[2651445] Cmd error
[2656470] Cmd skipped:20
[2656471] Cmd skipped:20

[EDIT] and the circuit:


texts:
Servo goes to one end, and immediately travels back without a 2s delay inbetween. After it travels back there is a 2s delay before it loops. Why isn't there a 2s delay before the travel back?

Servo testservo;

void setup() {
    testservo.attach(9);
}

void loop() {
    testservo.writeMicroseconds(700);
    delay(2000);
    testservo.writeMicroseconds(2300);
    delay(2000);
}


texts: Logging data to SD card from software serial

texts:
I have an Arduino Uno and an Adafruit data logging shield and I have connected a digital pressure sensor that uses serial communication. The sensor requires a character to start transmitting data. I have managed to read the data using this code:

#include <SoftwareSerial.h>
SoftwareSerial mySerial(8,9);

int depth;

void setup() {

    Serial.begin(9600);
    mySerial.begin(9600);
    mySerial.print("C");

}

void loop()
{

 if (mySerial.available()) {

   depth = mySerial.read();

 }

}

This returns the following:

  C1000
  C1000
  C1000

where 1000 is the value.

I have written another code that logs data to the shield and tested with other sensors but I cannot log data from this sensor by modifying the above code and cannot find any relevant examples.
If I add something like this it does not return the same value.

logfile.println(depth);

Complete newbie in so any suggestions are welcome.

UPDATE


texts: I am planning to do a periodic table with Arduino's help but I have a few questions

texts:
I'm doing that for my school project, but I have few questions before I purchase the components.

First of all, let me explain how it will work:

There will be 4x20 LCD, an Arduino and probably two potentiometers (due to the potentiometer's sensitivity). When the user turns the potentiometers, the program adds the first potentiometer's value to the other potentiometer's value, because of sensitivity issues. Then the program checks which element corresponds to the two potentiometers' values.

After that, the program shows that element's information in the LCD (like its name, symbol, neutron number, proton number, valence electrons, ...).

Questions:

There are around 118 elements in the periodic table. I'm not an expert with programming, but this means there will be 118 if ... else if ... statements. I can shorten the inside of the if statement by function, but there will be still 118 if statements. I'm afraid it will be over the memory (sketch size limit) limit of the Arduino. How can I shorten the code?
Should I buy a Mega or will a Uno be enough?
Will there be any problems if I connect a 5V Arduino pin to both potentiometers and 4x20 backlight? If not, how can I fix this? I don't want to use any other power source except Arduino.


texts: How can I understand which arduino I need to run some code?

texts:
I want to build this project (but any other project would give me the same uncertainty):
https://github.com/ltpitt/arduino-n64-controller-library

But I cannot understand which arduino I can buy that will be compatible and also very small / easy to program / cheap.

There are countless possibilities but I cannot understand how can I match available code and compatible hardware.


texts:
I have an Uno R3 with a sensor board and a temperature sensor. I'm running a simple temperature check and would like to store that data outside the Ardunio for keeping records, graphs, etc.

I powered it from my PC during development, but obviously I want something more compact when deployed. It's still inside the house, but I want the PC shut down, not running 24/7.

I do have wireless access, and a Raspbery Pi 3 model B. Can any of those help? Or should I buy an ethernet/WiFi shield and try to get acces with those?


texts:
Is it possible to use wire.h on an Arduino Uno to act as a slave for more than one address?  For example I'd like it to emulate two different devices, one at I2C address 23 and the other at address 57.

I'm either looking for a way to do this directly, or to run multiple instances (each would need a different onReceive handler).


texts: Arduino Due ( Atmel Microcontroller) IC Heat up and led goes off

texts:
I was connecting L293d Motor Driver IC with an Arduino Due Board. May be due to wrong connections, but when I made the grounds common, the Arduino LED goes off and Atmel IC heats up. When I reconnect my Due board with my PC anytime, the LED turns on and slowly dims to off and Atmel IC fries up.

I wanted to repair it. What should I do?

I have checked the input voltage of the AMS1117 3.3V regular IC as 3.8 V, while the output is 2.2 V. If I externally give 5 volt at input again, the input voltages drops. The regulator is loading.

I thought of replacing the regular IC?
Will that work?

Also I externally powered the Board with 3.3V by its pin labeled "3.3V" . The LEDs glow on and did not go off. But the Atmel Microcontroller IC becomes very hot.

What should I do?


texts: What is the best way to replace the buttons inside a car remote chip so that it can be controlled via Arduino?

texts:
I have a car remote that looks like the following

I would like to replace the buttons with some sort of switch or relay that can be programmatically controlled via an arduino unit. Would a simple relay switch work if I de-solder the buttons? Any help would be appreciated. Thanks!


texts:
int receive_pin = 2;

#define MAX 120
int value[MAX];
unsigned long time[MAX];
int changes;
int printed;

void setup() {
    Serial.begin(9600);
    pinMode(receive_pin, INPUT);

    changes = 0;
    printed = 0;
    attachInterrupt(2, change_handler, CHANGE);
    Serial.println("Receiver 433MHz setup");
}

void change_handler()
{
    if (changes >= MAX) return;
    value[changes] = digitalRead(receive_pin);
    time[changes] = micros();
    changes++;
}

void loop() {
  if (printed + 1 < changes) {
      Serial.println(time[printed+1] - time[printed]);
      printed++;
  }
}

Hi all

when i run this sketch after the result its stop and i close the serial monitor to run it again

my question how to make it run with out restart it


texts: Reading inside critical sections from ISR

texts:
Is it necessary to protect reads of volatile variables in critical sections when using interrupts? Or are critical sections only required when concurrently writing variables?

Here is an example of a variable written within an ISR which is protected with a critical section:

void loop() {
    portENTER_CRITICAL(&mux);
    uint other = variable_written_from_isr + 1;
    portEXIT_CRITICAL(&mux);
}

What will happen if an interrupt changes variable_written_from_isr while it is being read? Would anything worse that inconsistencies happen?

Here is an opposite example where a variable is written from an interrupt and read from the loop (or a task):

void IRAM_ATTR handleInterrupt() {
    portENTER_CRITICAL_ISR(&mux);
    uint other = variable_written_from_loop + 1;
    portEXIT_CRITICAL_ISR(&mux);
}

Please note that I aware of stdatomic. I am mainly interested in understanding the behavior of concurrent access in the context of interrupts.


texts:
I pretty new to Arduino and I need help to clarify some things.
 First, I want to make an Arduino controlled RC airplane but I don't know what communication module to use. I did some research and found three options.
1. Hc 12 Bluetooth: It has a decent range of about
    1.8km, buy suffers from delay(it can't be used on
     fast rc cars or airplanes)
2. Nrf24I01: About 850m in open space, uses
     2.4ghz which perfect for RC planes but doesn't
     really work through walls.
3. Lora: has a range of up to 10km but I didn't read on it that much.

So my question is: which one is better to use in a mini uav. I have no problem with mounting an antenna on top of my building. Will any of these work or is it better to use a wifi module connected to a modem which gives it internet access so that I can control the plane over the internet.


texts:
I am working on my home made project where i am using SD card to log GPS data into it,As well as i have to access that data from the SD card on my computer while all the system is connected to battery power, so i also have a USB to SD chip USB2240 from Microchip, this SD controller suits best to my application, Because USB2240 has a card detect pin connected to one of the pin of Arduino, from which i can control interface of SD card between Arduino for logging and the computer for the USB..

But I have to Recycle power to the SD card whenever SD Card is interfaced with the USB controller USB2240.

So for an Example : when the device is powered 'ON' , The SD card is interfaced with the Arduino - which logs data to the card, But when i connected the system to my computer to get the logged file on my computer, Then it's not working, Here i have to disconnect power to SD card and Reconnect it...

How do i achieve Power recycle all on it's own when i connected to the USB OR to the Arduino.

Thanks


texts: RF remote control using VirtualWire on ATtiny85 running at 8MHz on internal oscillator

texts:
I'm trying to make an RF remote control using ATtiny85 running at 8MHz on internal oscillator, this cheap RF 434MHz transmitter module (like the one below), and VirtualWire lib, but had no success so far.

So, before I go any further, is it possible to use VirtualWire with ATtiny85 running at 3.6V and 8MHz with its internal oscillator? If so, how?

I've found a few scattered sources of information on the Net about it, but couldn't make much sense of it.

I have build ATMega328 versions of the receiver and transmitter using VirtualWire without any major problems. Both modules talk to each other will very little data drop out. Now, when I tried to replace the ATMega328 transmitter with a smaller version using the ATtiny85, I'm having problems.

Here are the symptoms:

The major one seem to be that when I add the VirtualWire include, my sketch seems to slow down a lot. So I figure it's a timing issue. But I'm not sure what the problem is.
I put a scope on ATtiny85 pin 6 (PB1) but I don't see anything being transmitted. I think I've messed up with the pin names.
I can make the LED blink and also can read the buttons without problems.

Here are the schematics and the board design for the remote controller:

The board is currently powered by 2 AA NiMH batteries that are currently at 2.6V. I can make the ATtiny85 blink with that voltage. I plan to power the RC with a 3.6V CR2 lithum battery.

Here are more details of my development enviroment:

Arduino IDE 1.05
I'm using ATtiny cores from here
I'm programming the ATtiny85 using an Arduino UNO R3 as ISP, without problems (it's working as I can make the ATtiny85 blink an LED).

And here's my code:

#include <VirtualWire.h>

#define VCC_PIN  A1
#define BTN_PIN  A2
#define LED_PIN  A3
#define TXD_PIN  PB1

#define BLINK_UP_TIME  25

#define BUTTON_NONE  0
#define BUTTON_1     1
#define BUTTON_2     2
#define BUTTON_3     3
#define BUTTON_4     4
#define BUTTON_5     5
#define BUTTON_6     6

void setup()
{
  pinMode(BTN_PIN, INPUT);
  pinMode(TXD_PIN, OUTPUT);
  pinMode(VCC_PIN, OUTPUT);
  pinMode(LED_PIN, OUTPUT);

  // leave RF transmitter off for now
  digitalWrite(VCC_PIN, LOW);

  // Initialise the IO and ISR
  vw_set_tx_pin(TXD_PIN);
  vw_setup(2000);    // Bits per sec

  // let the user know we are alive: heartbeat
  blink(3, 50);
  delay(1000);
}

uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;

void loop()
{
  byte button = ReadButtons();
  if (button != BUTTON_NONE) {
    // transmit button pressed
    digitalWrite(LED_PIN, HIGH); // Flash a light to show transmitting
    digitalWrite(VCC_PIN, HIGH); // turn tranmitter on
    delay(10);
    buf[0] = button;
    vw_send(buf, 1);
    vw_wait_tx(); // Wait until the whole message is gone
    digitalWrite(LED_PIN, LOW); // turn off LED
    digitalWrite(VCC_PIN, LOW); // turn tranmitter off
  }
  delay(100);
}

byte ReadButtons()
{
  unsigned int buttonVoltage = analogRead(BTN_PIN);
  byte button = BUTTON_NONE;   // return no button pressed if the below checks don't write to btn
  if      (buttonVoltage < 10)   {    button = BUTTON_1; }
  else if (buttonVoltage < 200)  {    button = BUTTON_2; }
  else if (buttonVoltage < 400)  {    button = BUTTON_3; }
  else if (buttonVoltage < 550)  {    button = BUTTON_4; }
  else if (buttonVoltage < 720)  {    button = BUTTON_5; }
  else if (buttonVoltage < 900)  {    button = BUTTON_6; }
  else if (buttonVoltage > 1000) {    button = BUTTON_NONE; }
  return( button );
}

So, What's wrong with my setup?


texts: Timer 2 interrupt with ATmega328p and make measurement in ISR

texts:
I am working in my project and i want to use Timer2 interrupt every 100ms to get new measurement from the output of my 5 sensors which connected to pins A1,A2,A3,A4,A5.

I read in some article that using delay instruction is not as good as using timers'Interruptions so, I tried this code put it didn't work properly :

void setup(){

cli();

  TCCR2A = 0;
  TCCR2B = 0;
  TCNT2  = 0;
  OCR2A = 99;
  TCCR2A |= (1 << WGM21);
  TCCR2B |= (1 << CS21);
  TIMSK2 |= (1 << OCIE2A);
sei();

Serial.begin(9600);
}
void loop()
{
Serial.print(digitalRead(1));
Serial.print(' ');
Serial.print(digitalRead(2));
Serial.print(' ');
Serial.print(digitalRead(3));
Serial.print(' ');
Serial.print(digitalRead(4));
Serial.print(' ');
Serial.print(digitalRead(5));
Serial.println(' ');

}


texts: Is it dangerous to connect two output pins together?

texts:
If I have two output pins, one set high and the other set low with digital or analog write like this

digitalWrite(PIN1, LOW);
digtialWrite(PIN2, HIGH);

and then I short them together using a wire, will current flow through the wire?


texts:
I would like to connect 3 USB keys on an arduino.
I just want to detect the presence of the 3 USB Key. I do not want to read or write on the keys.
Is there a basic way to do that ?
Thanks


texts: externally powering the Arduino questions

texts:
I have several questions on externally powering the Arduino Uno

I have a 7.2V power source that is 6 rechargeable AA batteries together, 1.2V and 1300mA each. If i use a 4.70 and 1.5 ohm resistors together to give 1.16 amps, can I power the arduino with this?

Can I power a servo off the Arduino 5V rail If i place a 470uF or more capacitor alongside it?
Will anything heat or blow up or am I just being paranoid like always?


texts: Is there a way for an Arduino to flash another one without a computer?

texts:
I am going to create a game console. The games will be in an SD card and an Arduino (or an Atmega chip) will read a hex file's contents to RAM and will flash it to another one. Something like this but here, the guy says that this only works for atmega328, and I am planning to use a ATSAM3X8E chip and also I am worried about the power levels (5v - 3v3).
Is there any way for me to use an Atmega chip like Atmega16u2 and use that to flash something like an ATSAM3X8E? If so, what protocol should I use and how may I implement it in my code?


texts: Methodology for designing/prototyping LED patterns

texts:
Several of my projects go through this time-consuming and tedious phase:

design a LED pattern for a geometry of WS2812 LEDs
implement it with e.g. FastLED
write to Arduino and see results
goto step 1

The second step, implementing different ideas in C with FastLED (or similar) takes a lot longer than I'd like it to. How is this step usually solved? Are there higher-level software solutions? Specialised idea-testing hardware?

I'd like to easily try out ideas such as "what if these four LEDs blinked magenta every second, while a gradient was cycling around the gradient over here".


texts:
By playing with some examples I found the following construct:

void Show(int nav = 0) // -1 top, 1 bottom

and I wondered what effect it has to initialize the handover parameters in the function declarations, I never noticed such an construct consciously.

So I made a small demo:

#include <M5Stack.h> //necessary for my board
  int a;
  int b;
  int c;

int addFunction(int x = 3, int y = 3){
  int result;
  result = x + y;
  return result;
}

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

  // testcase 1
  a = 1;
  b = 2;
  c = addFunction(a, b);
  Serial.println("testcase 1:");
  Serial.println((String)a + " + " + b + " = " + c);

   // testcase 2
  a = 1;
  b = 2;
  c = addFunction();
  Serial.println("testcase 2:");
  Serial.println((String)a + " + " + b + " = " + c);

   // testcase 3
  a = 1;
  b = 2;
  c = addFunction(a);
  Serial.println("testcase 3:");
  Serial.println((String)a + " + " + b + " = " + c);
}

void loop() {
}

The output was:

So I learnd:

if you hand over parameters, the initialization is ignored, if you call the function without handing over paramters, the functions works with the init values.
if you handover only one parameter it will be assigned to the first in the declaration.

Question:

Is there a syntax possible to only call the function with the second parameter, so that for the first paramter the intialized value of the declaration is used? Spoken for this example with a = 1, b = 2 you only handover b and the expected result would be 5.


texts: ard-reset-arduino resetting Leonardo/Micro via USB works on OSX, fails on Ubuntu

texts:
I'm trying to program a Leonardo (actually a Micro ATmega32U4) via the command line using USB.  Schematically, I'm doing ard-reset-arduino followed by a sleep 1 and an avrdude command.

This works reliably on my Mac (OSX 10.12.1, avrdude v6.3), but bombs out on Ubuntu (Ubuntu 5.2.1-22ubuntu2, avrdude v6.1) with the message:

.avrdude: butterfly_recv(): programmer is not responding

Update: I believe this is actually due to a failure to get the atmega32u4 into the bootloader.  See update at the bottom of this post...

Has anyone seen this?  Any suggestions for debugging strategies or things to try?

Details on the Mac:

Here is the command line with results under OS X:

$ ./ard-reset-arduino --verbose --caterina /dev/cu.usbmodem1411 && sleep 1 && /Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -V -D -p atmega32u4 -C /Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -c avr109 -b 9600 -P /dev/cu.usbmodem1411 -U flash:w:./leds_test.ino.leonardo.hex:i
Forcing reset using 1200bps open/close on port /dev/cu.usbmodem1411
/dev/cu.usbmodem1411 has come back after reset

Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
    Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.
Programmer supports the following devices:
    Device code: 0x44

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9587 (probably m32u4)
avrdude: reading input file "./leds_test.ino.leonardo.hex"
avrdude: writing flash (9146 bytes):

Writing | ################################################## | 100% 0.70s

avrdude: 9146 bytes of flash written
avrdude: safemode: Fuses OK (E:CB, H:D8, L:FF)
avrdude done.  Thank you.

Details on Ubuntu:

Here is the command line with results under Ubuntu.  Except for the pathnames, all of the options are the same as under OSX:

$ /boot/ard-reset-arduino --verbose --caterina /dev/ttyACM0 && sleep 1 && /usr/share/arduino/hardware/tools/avr/../avrdude -V -D -p atmega32u4 -C /usr/share/arduino/hardware/tools/avr/../avrdude.conf -c avr109 -b 9600 -P /dev/ttyACM0 -U flash:w:/boot/leds_test.ino.leonardo.hex:i
Forcing reset using 1200bps open/close on port /dev/ttyACM0
Waiting for /dev/ttyACM0 to come back
Waiting for /dev/ttyACM0 to come back
Waiting for /dev/ttyACM0 to come back
Waiting for /dev/ttyACM0 to come back
Waiting for /dev/ttyACM0 to come back
Waiting for /dev/ttyACM0 to come back
Waiting for /dev/ttyACM0 to come back
Waiting for /dev/ttyACM0 to come back
/dev/ttyACM0 has come back after reset

Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding

Postscript

Just to make sure I hadn't borked the bootloader somehow, I moved the Leonardo/Micro back to the OSX and re-ran the reset / programming sequence under OSX.  It worked without error, so I conclude that the resident bootloader is intact.

Update

I believe the real problem is that under Ubuntu, ard-reset-arduino fails to put the Leonardo into the bootloader.

Here's why I believe this is the problem: the resident sketch makes the onboard LEDs blink.  On the Mac, running ard-reset-arduino makes the blinking stop for about 8 seconds.  On Ubuntu, the LEDs continue to blink without interruption after the ard-reset-arduino command returns.

Update 2

Here's an even simpler Python program that resets the Leonardo under OSX but not under Ubuntu.

#! /usr/bin/python
import sys
import serial

ser = serial.Serial(sys.argv[1], 1200)
ser.close()


texts: There is String.toInt(), but no String.toLong() or the many other variations. Do I have to resort to atol(String.c_str()) or is there a better way to convert a String to a long?


texts: ESP8266 (D1 mini) fails to upload sketches

texts:
My Setup: 3.3v LiFePo battery attached to G and 3.3 pins. Serial-USB connected.

Result: During the following code the blue on-board LED blinked rapidly for a few seconds then went off. I unplugged it to see if it was programmed but the Blink Sketch didn't run. Any help would be greatly appreciated.

Sketch uses 222,205 bytes (21%) of program storage space. Maximum is 1,044,464 bytes.
Global variables use 31,572 bytes (38%) of dynamic memory, leaving 50,348 bytes for local variables. Maximum is 81,920 bytes.
C:\Users\jhoxie\AppData\Local\Arduino15\packages\esp8266\tools\esptool\0.4.9/esptool.exe -vv -cd nodemcu -cb 115200 -cp COM3 -ca 0x00000 -cf C:\Users\jhoxie\AppData\Local\Temp\arduino_build_351972/Blink.ino.bin
**(Everything below this line was highlighted in red)**
esptool v0.4.9 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
    setting board to nodemcu
    setting baudrate from 115200 to 115200
    setting port from COM1 to COM3
    setting address from 0x00000000 to 0x00000000
    espcomm_upload_file
    espcomm_upload_mem
    setting serial port timeouts to 1000 ms
opening bootloader
resetting board
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
Uploading 226352 bytes from C:\Users\jhoxie\AppData\Local\Temp\arduino_build_351972/Blink.ino.bin to flash at 0x00000000
    erasing flash
    size: 037430 address: 000000
    first_sector_index: 0
    total_sector_count: 56
    head_sector_count: 16
    adjusted_sector_count: 40
    erase_size: 028000
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    setting serial port timeouts to 15000 ms
    setting serial port timeouts to 1000 ms
    espcomm_send_command: receiving 2 bytes of data
    writing flash
................................................................................ [ 36% ]
................................................................................ [ 72% ]
..............................................................                   [ 100% ]
starting app without reboot
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    espcomm_send_command: receiving 2 bytes of data
closing bootloader
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete


texts: How to send sms message on specific area using Longitude and Latitude

texts:
Good day everyone! what code should i used for sending sms message depends on the area. the things that i used in my protoype i have MPU6050 accelometer, SIM800C GSM MODULE, NEO6MV2 GPS MODULE. So the flow is if the Accelometer triggred the GSM module will get the GPS location only if the area is on the target location 1 so it will only send to the recepient 1. But if its triggred in another location, Targetlocation2 it will only send on receipient 2.
My question is how to used the longitude and latitude data to get the exact data of what my gps module gets? so that i can use that data to send sms message on specific place or area thank a lot
also i used TINYGPS.H LIBRARY thank you!


texts:
I am trying to make a wifi repeater. My router's signals don't come to my study and instead of buying a proper wifi repeater I prefer making one.

I want to learn how to make a simple wifi repeater that:

repeats/boosts my existing home wifi network by connecting to it.
Has some kind of a GUI or something that allows me to connect to it first (from some smartphone or PC) to configure it to my home network. It should find and show wifi networks around and then connect to the one I want it to upon my command.

I am new to electronics. Arduino is my preferred platform. If there are other easy to do alternatives that shall work too.

Any kind of help will be appreciated...tutorials, blogs, etc.


texts: Calling a localhost php script from arduino

texts:
Is it possible to connect arduino uno to call a php script using ONLY an arduino uno board, and an esp8266-01 wifi module.? That is, I lack wifi shield such as node MCU.
I just need the setup to call a php script on my localhost server.
I'm using arduino IDE 1.8.13.
Gracias


texts:
I have a 12V 2.5 ampere Dc adapter.Can i use it to power arduino uno board?
It says on the arduino website that i can use 9-12V and upto 1 ampere. I am concerned with current limit here..


texts: Is it possible to burn a bootloader to an ATTiny85 with USB TTL and avrdude?

texts:
I have:

An Digispark clone (with no Arduino bootloader)
A USB -> TTL serial device
A development breadboard
Avrdude

I want to burn the micronucleus bootloader to the chip.

Is this possible, are there instructions?

ISP programmer is in the post but I'm not expecting it for 3 weeks.


texts:
Is there a way to control 3 relays with 1 button?

My idea is: There are 3 modes; mode 1 for relay 1, mode 2 for relay 2 and mode 3 for relay 3.

With a long press you switch between modes (After 3 comes 1) and with a short press you activate the relay which is in the activated mode.

I need this for my wheelchair so please help me.

Thank you, Michael

Further question:
Does the relays really need a external power supply?
Because I have a small amount of power to control with the relays.


texts:
I am trying to compile and upload code to an Arduino Uno from the command-line, however I seem to be experiencing an odd issue.

When I compile this code:

#include <avr/interrupt.h>
#include <stdbool.h>

ISR(TIMER0_OVF_vect) {
}

int main() {
  while (true);
}

With these commands:

$ avr-gcc -mmcu=atmega328p -DF_CPU=16000000 -std=c17 -O3 -Wall -Wextra -c boot_loop.c -o boot_loop.o
$ avr-gcc boot_loop.o boot_loop.elf
$ avr-objcopy -j .text -j .data -O ihex boot_loop.elf boot_loop.hex
$ avrdude -p atmega328p -c arduino -P /dev/ttyUSB0 -U flash:w:boot_loop.hex

My Arduino ends up in a boot loop, flashing the LED 3 times every second or so (similarly to when you press the reset button or the device powers up).

I've tried it without an empty ISR and also with different interrupt vectors (e.g. TIMER0_COMPA_vect) but to no avail. Completely removing the ISR definition stops the boot loop.


texts:
Many of the receiver modules (MX-05V) working with the Virtual Wire library (I would like to add a link here but it requires 10 reputation, so I'll do that later) have two data pins. However only one of them is used in the examples I have seen so far.

This picture shows a transmitter (top left) and a receiver (bottom right). Apparently the receiver has four pins - two of them are data pins.

Image source

What is the purpose of the second data pin on the receiver module and how to use it?


texts: What happens when code is uploaded using the bootloader?

texts:
When I upload a new sketch to my Arduino Uno using the Optiboot bootloader, what really happens?

What is sent to the Arduino?
How does it respond?
What does "not in sync mean"?
What is "in sync" anyway?

Note: This is intended as a "reference question".


texts: How to set up one second interrupt/ISR for ds3231 RTC

texts:
I am able to set up one hz interrupts using millis and other timers, but would like to do it instead using the RTC I have attached (DS3231)

I am not sure how I can do that.  Can someone point me to a reference for this?

EDIT/UPDATE

I tried to use the square wave to trigger a call back/interrupt, but it's not working for me.  I followed what I thought was the wiring diagram here and
here and here

I also added a led in the circuit to see if I could figure out something that way, but no dice.

Here is some simple code for a sketch that I think should trigger a 1 second interrupt and call my function:

#include <DS3232RTC.h>    //http://github.com/JChristensen/DS3232RTC
#include <Time.h>         //http://www.arduino.cc/playground/Code/Time
#include <Wire.h>         //http://arduino.cc/en/Reference/Wire (included with Arduino IDE)

const int rtcTimerIntPin = 2;
bool flag = false;

void setup(void)
{
    Serial.begin(9600);
    setSyncProvider(gRTC.get);   // the function to get the time from the RTC
    if (timeStatus() != timeSet)
        Serial.println("Unable to sync with the RTC");
    else
        Serial.println("RTC has set the system time");

    bool stopped = gRTC.oscStopped();
    if (stopped)
    {
        Serial.println("Detected clock power loss - resetting RTC date");
        time_t newTime = cvt_date(__DATE__, __TIME__);
        adjustTime(newTime);
        setTime(newTime);
    }
    else {
        Serial.println("Clock did not lose power");
    }

    pinMode(13, OUTPUT);    // onboard LED
    pinMode(rtcTimerIntPin, INPUT);
    attachInterrupt(rtcTimerIntPin, rtc_interrupt, RISING);
    gRTC.squareWave(SQWAVE_1_HZ);

    digitalClockDisplay();
}

void rtc_interrupt(void)
{
    flag = true;
}

void loop(void)
{
    //digitalClockDisplay();

    if (flag) {
        digitalWrite(LED_BUILTIN, HIGH);    // flash the led
        digitalClockDisplay();              // this just prints time to serial port
        delay(500);                         // wait a little bit
        digitalWrite(LED_BUILTIN, LOW);     // turn off led
        flag =  false;                      // clear the flag until timer sets it again
    }
}

void digitalClockDisplay()
{
// do something
}


texts: How does changing arduino power supply from USB to Adapter change the circuit?

texts:
I have a circuit running with capacitive Sensors, that also has an LED strip. everything works fine when using USB power from a laptop (connected to the mains) and 12v 2A adapter powering 1m LED strip.

When the power supply is split and the arduino is also powered from this supply ( using adapter port ) the capacitive sensor begins to give junk values.

What changes in a circuit that would create such a porblem? Could it be a grounding issue? How else to ground this arduino to behave as it would with a usb connection?


texts: Arduino Servo won't move when using classes

texts:
I'm trying to make a class work with Arduino, however it doesn't seem to trigger properly. The code is compiling perfectly, and it's supposed to control the leg of an hexapod. Also, the example sweep works on this servo, so no problem here. However, the servo is not actually moving. I'm thinking it has something to do with the order of declaring the variables:

#include <Servo.h>

// Abstract each leg, so only those functions can be accessed
class Leg {
  // Actions that can be triggered from outside
  public:
    Leg(int hipPin, int kneePin);
    void up();

  // These should be only available for the leg
  private:
    Servo hip;
    Servo knee;
  };

Leg::Leg(int hipPin, int kneePin) {
  hip.attach(hipPin);
  knee.attach(kneePin);
  }

// Testing the leg: move it up
void Leg::up() {
  for(int pos = 0; pos < 180; pos += 1) {
    hip.write(pos);
    delay(15);
    }
  }

// Initialize the leg
Leg topLeft(9, 10);

void setup() {
  }

// Test the function up()
void loop() {
  topLeft.up();
  }

I'm testing only the pin 9 (leaving the 10 empty). It seems in pain, meaning, you can see the servo trembling but not moving really at 0 degrees.


texts:
Bear with me here, I'm new to arduinos, so what I'm saying might only make sense in my own mind.

I'm trying a button matrix and I not completely sure on my wiring and I have a few questions.

Is the diagram correct?
I wire D2 to D3 and set them to output and input respectively. In the code I digital write to D2 a HIGH, will D3 then read high?
What is the best way to read the state of each button? Is there a Library that can simplify it?

I'm sorry if this is all just confused gibberish.

EDIT: I got the idea from this video, which explains some of it, but no code. He however uses an arduino micro.

EDIT #2: I realized I wired the buttons incorrectly.


texts: Simulation of Arduino Mega 2560 with GSM Module using Proteus

texts:
I have really been suffering with my simulation! Tried connecting my arduino mega 2560 to COMPIM (used as GSM Module) in my circuit and also loaded sample code but damn! In vain! I wanted to view the data sent in virtual terminal but am getting nothing! and its also complaining of excessive CPU usage.

This is the circuit as seen below in Proteus.

And thereafter, the log messages are displayed as shown below.

Someone please help me out. Am I making a mistake oh? Infact the arduino code for displaying in the simulation is also giving me hard time. The one am using is as shown below.

#include <SoftwareSerial.h>

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

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{
  if (mySerial.available())
    mySerial.println("Hello, world?");
  if (Serial.available())
    mySerial.println("Hello, world?");
}

Will b every grateful for any help offered.


texts: Connecting two Arduinos via I2C while I2C Pins A4/A5 are already in use

texts:
I have the following problem:
Since the BH1750 Sensor only supports two different I2C adresses, but i need to use 6 of those sensors, i wanna use 3 arduinos, 2 nanos, 1 uno and send the data from the nanos to the uno. Problem is that the I2C bus is already in use and while trying to send data, it does not work properly.
Is this even possible? When trying it out, i can't get anything correct

Update:

That's what i tried now:

Results i get are still not correct

#include <Wire.h>
#include <BH1750.h>

// This code will feature the use of 6 gy 30 light sensors

BH1750 active_sensor(0x23); // We will use this adress for stating the active sensor
BH1750 inactive_sensor(0x5C);

void setup(){

  Serial.begin(9600);

  // Setting the input pins for controling the addr pins of the modules
    pinMode(8, OUTPUT);
    pinMode(9, OUTPUT);
    pinMode(10, OUTPUT);
    pinMode(11, OUTPUT);
    pinMode(12, OUTPUT);
    pinMode(13, OUTPUT);

    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);

  // Initialize the i2c bus
  Wire.begin();

 // Here we will set the mode of the module
  if (active_sensor.begin(BH1750::CONTINUOUS_HIGH_RES_MODE)) {
    Serial.println(F("BH1750 Advanced begin"));
  }
  else {
    Serial.println(F("Error initialising BH1750"));
    Serial.println("Problem on 1");
  }
}

void loop() {
  get_values();

}

void get_values(){
  int i;
  Serial.println("----");
  for(i = 8; i<=13;i++){
    digitalWrite(i,HIGH);
    delay(50);
    int lux = 0;
    lux = active_sensor.readLightLevel();
    Serial.println(lux);
    delay(50);
    digitalWrite(i,LOW);
    delay(150);
  }
}


texts: Comparison of Board Shape between Arduino MEGA and Arduino DUE

texts: I'm using KiCAD to design boards, and while it has a lot of Arduino templates, it doesn't have one for the Arduino Due. Now, I've did some searching, and it looks like the Arduino MEGA is very similar to the Arduino DUE, not the specifications, but the number of I/O pins and the overall shape of the board. I couldn't find a straight answer, so I decided to ask here: Can the template of the Arduino MEGA be used as a template for the Arduino DUE when designing custom 'shields' and such based on the number of I/O pins and overall layout?


texts: How to make sure Arduino's PWM pulses are phase shifted?

texts:
I'd like illuminate my room solely with several RGB LED strips using Arduino's PWM (together with LED amplifier and few transistors).

I want the Arduino to control 2 independent chains of LED strips, and I want to make sure, that the LEDs would not blink simultaneously, creating a very strong stroboscopic effect in my room.

How to delay three Arduino's PWM pins half a phase relative to the other three?


texts:
I´m new working with Arduino. Right now I have a project thar requires to turn on 30 LEDs at the same time with an Arduino Mega. The problem is that it would exceed the max current that the chip can tolerate.

It is possible to do this by turning on one LED at the time, very fast?

If it is, any clue on the code to achieve that will be apreciated.

Thank you very much

P.S.: I know there are components to expand the quantity of pins that work like that, but the idea is to avoid using one.


texts: Get the uploaded code from arduino by using arduino IDE 1.0.6

texts:
Recently bought a arduino device which already have program,

it is model AR-293D and I have already connect it with my PC(windows 7) through usb

when I open the IDE , It seems there is no function that read the uploaded program?

And after searching a while , like some beginner tutorial , it only tell you how to upload the program but not how to get the uploadded program

http://www.forefront.io/a/beginners-guide-to-arduino

So, I wonder how to get the code? Thanks a lot for helping, I worried erase the uploadded program so I need to take caution about this


texts: Arduino IDE c++ 11 raw string literal have issues with // in http://, complier thinks // is comment

texts:
char webpage[] PROGMEM = R"=====(
<html>
  <head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.6/svg.min.js"></script>
  </head>
  <body>
  </body>
</html>
)=====";

I found a problem when using the raw string literal in Arduino IDE.
My code cannot compile if i have http:// link inside the string.

I found that it should be related to how Arduino IDE thought the string after // are comments and during compile time those string are ignored and my codes break.

It looks like the arduino ide's compiler removes all //comment in the code first, before it try to compile the raw string literal and then cause the issue.

As a test I try to debug it by changing my code to https:/-/ the program can be compile as now there is no // in the raw string literal

Is there any workaround?


texts: Bluetooth gamepad via Adafruit Feather M0 Bluefruit BLE

texts:
I'm trying to build a Bluetooth-enabled gamepad out of an old Playstation 1 controller, using an Adafruit Feather M0 Bluefruit BLE.

I've programmed the board as a Keyboard HID and everything works: the controller button presses trigger keyboard presses through the Feather. However, treating the controller as a keyboard means I get no analog joystick support.

The Feather M0 supports a Gamepad HID mode, but it's limited to 8 buttons and one joystick (but not analog), which is obviously not enough for a Playstation 1 controller.

I'm a bit stumped here: do I have any way of registering the BLE as a gamepad, to enable analog support, but with as many buttons as I need and two joysticks?

My code so far, on GitHub.


texts:
A few weeks ago I built my own Arduino Micro. Everything worked fine and it connects every time. I have built a second one, with the exact same processor schematic as the first one. It turns on, and I was able to bootload it with an Arduino Uno, just like the first one. But it will not connect to my computer.

When I plug it into my PC, the lights flash on but I get nothing. It does not show up in device manager anywhere, and its like I plugged nothing in, in the first place.

When I plug in my other Arduino Micro it works fine. But this one does not. I have tried switch PCB's (maybe the first one was bad) but nothing seems to work. I have even switched the ATMega32U4, but I still get the same issue.

When I connect my multimeter to the USB port and the corresponding D+ and D- pins on the processor, I get that there is resistance and there are no crossed connections.

I feel that at least the computer should say "Device not recognized," but I just get nothing. Is my Arduino bricked? Has anyone else had a similar problem?


texts: can we use Software serial and timer one at the same time or this software use also timer one?

texts:
i am using timer1 and software serial for gps data i need to see if we have a problem with connection .
So i made a timer1 that's start before the loop that will wait the gps sending and after 3s if we didn't receive data we will exit the loop of waiting and going to make diffrent thing .


texts:
i am trying to write a simple program that writes the outputs of an accelerometer (which comes down to 3 analog inputs) onto an SD-Card.

I got the hole thing working fine (sending the values as simple strings), however i wanted to increase the frequency at wich the data is taken and therefore tried to send the data to the SD card encoded in binary, and therefore i am doing some bitwise manipulation.

Unfortunately some (as i think) strange things happen. When i add a simple bitwise manipulation the data on the SD card is pretty messed up. (I was unable to detect a pattern but it seems some Bytes are missing or or are there twice without any regularity):

Here is an example of a working version:

// Get raw accelerometer data for each axis
unsigned int rawX = analogRead(A0);
unsigned int rawY = analogRead(A1);
unsigned int rawZ = analogRead(A2);

byte b1 = (byte) (rawX>>2);
byte b2 = (byte) (rawY>>4);
b2 = b2 + (byte) (rawX<<6);
byte b3 = (byte) (rawZ>>6);
b3 = b3 + (byte) (rawY<<4);
byte b4 = (byte) (rawZ);
b4 = (byte)b4*4;
//b4 = (byte)b4<<2;

// get pressure
//temp = BMP180_getTemp();
//float a = 0;
//float a = pressure.altitude(BMP180_getPressure(), baseline);

unsigned long t = millis();

byte writeB[] ={
    b1,
    b2,
    (byte) (rawZ>>6), //replacing this with '(byte) ((rawZ>>6)|(0b11110000 & rawY))' will cause the error
//also replacing with b3 creates the error as well
    b4,
    (byte) (t>>16),
    (byte) (t>>8),
    (byte)t, (byte)0};

dataFile.write(writeB,8);

dataFile.flush();

As mentioned as a comment in the code changing the way the byte is calculated messes up my data on the SD card. I tried several other things however it seems that the following operations are causing the error: | & << >>  (However i am using some of them to calculate e.g. b2)

What i don't get is how changing how a byte is calculated affect the data output.

Maybe (probably) i overlooked some easy mistake but i cant figure out what is happening. Any help would be greatly appreciated since im working on this since quite a while.

(I am aware that the program does currently not transmit all necessary data but i startet from scratch and programmed step by step to locate/identify the error)


texts:
I would like to micromize my Arduino project and move it to ATTiny85. The first step was using sleep functions because I just want it to run once a day. Now I need to connect the 433Mhz stuff but I'm getting into a fight with cores vs. libraries vs. missing functions.

No matter what core and library combination I pick, there always seems to be something missing.

/home/thijs/Documents/Arduino/libraries/VirtualWire/VirtualWire.cpp:260:18: error: 'WGM12' was not declared in this scope
     TCCR1B = _BV(WGM12) | _BV(CS10);

I have tried Tiny cores, high lowtech cores and Manchester and VirtualWire libraries. I don't want to dive into the libraries and make them 'suitable' for ATTiny because I have more than one project.

How do I approach this dependency problem?

[edit]
Found a better core here:
https://github.com/SpenceKonde/ATTinyCore


texts: Arduino TimerOne breaks the program when calling "digitalRead"

texts:
I'm trying to make this project.

But i have a problem running this code. It appears to be val = digitalRead(inPin); breaks entire program. just because i call this from the callback function which attached as an interrupt function Timer1.attachInterrupt(callback);

Here is the more simplified problem simulation program,

#include "TimerOne.h"

int inPin = 7;   // sensing digital pin 7

int val;

void setup() {
  pinMode(inPin, INPUT);      // sets the digital pin 7 as input to sense receiver input signal

  Serial.begin(9600);
  Timer1.initialize(8);  // initialize timer1, and set the frequency; this drives both the LC tank as well as the pulse timing clock
  // note: modify this as needed to achieve resonance and good match with the desired tags
  // the argument value is in microseconds per RF cycle, so 8us will yield RF of 125kHz, 7us --> 143kHz, etc.

  Timer1.pwm(9, 512);

  Timer1.attachInterrupt(callback);
}

void callback()
{
  val = digitalRead(inPin);//once you comment this line, it works fine
}

void loop() {
  Serial.print("Program running \n");

}

Any help is much appreciated.


texts: Beginner here. Which arduino revision should i buy?

texts:
I have no idea what difference is there between the revisions and how it affects me. I have a pdf and this pic was in there:

My questions

which arduino revision is this?
Does it matter which revision i    buy?


texts: Arduino Uno + Sim808 GPS dont work with GSM

texts:
I am trying to get GPS data and pass it through GSM (Http Get Request). The GPS codes part works fine alone, also HTTPRequest part lonely. But when i use them together , the module don't get GPS data to send with GSM!
I've commented parts for more understanding.

//Include Libraries
#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>

//Define module connect pins
#define PIN_TX    12
#define PIN_RX    13
SoftwareSerial mySerial(PIN_TX,PIN_RX);
DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,

//store response from website
char buffer[256];

//store Http request
char datas[83];

//store GPS latitude
float lat;

//store GPS longitude
float lon;

//store GPS latitude as text
char la[8];

//store GPS longitude as text
char lo[8];

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

//Temporary for prevent of connection error from network! added now
  delay(2000);
  sim808.close();
  sim808.disconnect();
  sim808.detachGPS();
  delay(2000);

  while(!sim808.init()) {
      Serial.print("Sim808 init error\r\n");
    }
    Serial.println("Sim808 init success");

  //************* Turn on the GPS power************
  if( sim808.attachGPS())
      Serial.println("Open the GPS power success");
  else
      Serial.println("Open the GPS power failure");
 while(!sim808.join(F("mcinet"))) {
      Serial.println("join network error");
  }
  Serial.println("join network success");

  //************ Successful DHCP ****************
  Serial.print("IP Address is ");
  Serial.println(sim808.getIPAddress());

  //*********** Establish a TCP connection ************
  while(!sim808.connect(TCP,"332b8a09.ngrok.io", 80)) {
      Serial.println("Connect error");
  }

}

//this function get latitude and longitude and put them in variable (datas) for http request

void http(float loni, float lati){
    dtostrf(lati, 6, 6, la);
    dtostrf(loni, 6, 6, lo);

    strcpy(datas,"GET /index.php?lat=");
    strcat(datas, la);
    strcat(datas, "&long=");
    strcat(datas, lo);
    strcat(datas," HTTP/1.1\r\nHost: 332b8a09.ngrok.io\r\n\r\n\r\n\r\n");
}

void loop() {
    if(sim808.getGPS()) {
//get GPS data
    lat = sim808.GPSdata.lat;
    lon = sim808.GPSdata.lon;

//send GPS data to http function for put them into http request
    http(lat,lon);

    //*********** Send a GET request *****************
    Serial.println("waiting to fetch...");
    sim808.send(datas, sizeof(datas));
    while (true) {
        int ret = sim808.recv(buffer, sizeof(buffer)-1);
        buffer[ret] = '\0';
        Serial.print("Recv: ");
        Serial.print(ret);
        Serial.print(" bytes: ");
        Serial.println(buffer);
        break;
      }
    }
    delay(3000);
    Serial.println("Another Attemp...");
}

I Use sim808 EVB-V.3.2.4 module and Arduino Uno.

And this is the serial prints of program:

Sim808 init success
Open the GPS power success
join network success
IP Address is
102.168.24.54
Another Attemp...
Another Attemp...
Another Attemp...
Another Attemp...
Another Attemp...
.
.
.
And goes on Infinity Another Attemp...

I must get printed string : "waiting to fetch..." and some other strings before each "Another Attemp..."


texts: Arduino Wifi/Wemos Wifi D1 adding &t=0 to simple GET request

texts:
I'm attempting to make a simple get request to my website from my arduino, but I'm unable to do so.

I keep getting the following error:

<html>
  <head>
    <meta http-equiv="refresh" content="0;url=http://dnserrorassist.att.net/search/?q=http://www.example.com/&t=0"/>
  </head>
  <body>
    <script>
      window.location="http://dnserrorassist.att.net/search/?q="+escape(window.location)+"&r="+escape(document.referrer)+"&t=0";
    </script>
  </body>
</html>`

Edit: Here's the important code.

const char http_site[] = "www.example.com";
const int http_port = 80;

// Perform an HTTP GET request to a remote page
bool getPage() {

  // Attempt to make a connection to the remote server
  if ( !client.connect('http://' + http_site, http_port) ) {
    return false;
  } else
  {
    Serial.println("Connected!");
  }

  // Make an HTTP GET request
  client.print("GET /");
  Serial.print("GET /");

  client.println(" HTTP/1.1");
  Serial.println(" HTTP/1.1");

  client.println("Host: xxx.xxx.xxx.xxx:1995");
  Serial.println("Host: xxx.xxx.xxx.xxx:1995");

  client.println("Connection: close\r\n");
  Serial.println("Connection: close\r\n");

  return true;
}

void loop(void){

  if ( client.available() ) {
    char c = client.read();
    Serial.print(c);
  }
}


texts: Is it possible to upload an arduino sketch through the serial port (RX) instead of USB

texts:
In another words, is it possible to develop a custom bootloader so sketches can be uploaded via serial connection made using the RX/TX pins and not via the USB connector (I am using Pro Micro boards)?
Thanks!


texts: number generator show wrong segments on 7 segment display

texts:
I created a program to show a random number on a 7 segment display. It shows a random number in the serial monitor but always shows the same segments 'a c d and g'. anyone know hopw to fix this without changing the base of the coding its for and exercise so i need to have most of the code like I wrote it.

int num_array[11][7] = {
  { 1, 1, 1, 1, 1, 0, 1 }, // 0
  { 0, 1, 1, 0, 0, 0, 0 }, // 1
  { 1, 1, 0, 1, 1, 1, 0 }, // 2
  { 1, 1, 1, 1, 0, 1, 0 }, // 3
  { 0, 1, 1, 0, 0, 1, 1 }, // 4
  { 1, 0, 1, 1, 0, 1, 1 }, // 5
  { 1, 0, 1, 1, 1, 1, 1 }, // 6
  { 1, 1, 1, 0, 0, 0, 0 }, // 7
  { 1, 1, 1, 1, 1, 1, 1 }, // 8
  { 1, 1, 1, 0, 0, 1, 1 }, // 9
  { 0, 0, 0, 0, 0, 0, 0 }
};  //OFF

int buttonState = 0;
const int button = 12;
int randVal;
bool pressVal;
void num_Write(int);
void setup() {
  Serial.begin(9600);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(button, INPUT);
}

void loop() {
  buttonState = digitalRead(button);
  if (buttonState == LOW) {
    turnOff();
    pressVal = false;

  }
  else
  {
    if (pressVal == false)
    {
      int pin = 2;
      for (int i = 0; i < 7 ; i++)
      {
        digitalWrite(pin++, num_array[11][i]);
      }
      randVal = rand() % 10;
      pressVal = true;
    }
    Serial.println(randVal);
    if (randVal == 0)
    {
      void zero();

    }
    else if (randVal == 1)
    {
      void one();

    }
    else if (randVal == 2)
    {
      void two();

    }
    else if (randVal == 3)
    {
      void three();

    }
    else if (randVal == 4)
    {
      void four();

    }
    else if (randVal == 5)
    {
      void five();

    }
    else if (randVal == 6)
    {
      void six();

    }
    else if (randVal == 7)
    {
      void seven();

    }
    else if (randVal == 8)
    {
      void eight();

    }
    else
    {
      void nine();

    }
  }
}

void zero()
{
  int pin = 2;
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin++, num_array[0][j]);

  }
  delay(250);
}

void one()
{
  int pin = 2;
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin++, num_array[1][j]);

  }
  delay(250);
}

void two()
{
  int pin = 2;
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin++, num_array[2][j]);

  }
  delay(250);
}
void three()
{
  int pin = 2;
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin++, num_array[3][j]);
  }
  delay(250);
}
void four()
{
  int pin = 2;
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin++, num_array[4][j]);

  }
  delay(250);
}
void five()
{
  int pin = 2;
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin++, num_array[5][j]);

  }
  delay(250);
}
void six()
{
  int pin = 2;
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin++, num_array[6][j]);

  }
  delay(250);
}
void seven()
{
  int pin = 2;
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin++, num_array[7][j]);

  }
  delay(250);
}
void eight()
{
  int pin = 2;
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin++, num_array[8][j]);

  }
  delay(250);
}
void nine()
{
  int pin = 2;
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin++, num_array[9][j]);

  }
  delay(250);
}
void turnOff()
{
  int pin = 2;
  for (int j = 0; j < 7; j++) {
    digitalWrite(pin++, num_array[10][j]);
  }
  delay(250);
}


texts: Arduino + L9637 K-Line reader - 10400 baud on SoftwareSerial?

texts:
I know this question has been asked many times before in different flavours, but all of the previous questions I have found seem to pre-date the current SoftwareSerial library, which afaik now (unlike when the previous questions were asked) allows any baud rate to be set as it calculates the values for the timings.

So I currently have the L9637 monolithic bus driver connected to pins D0 and D1 of my Arduino Uno. I am trying to create an ECU reader to communicate with my car over the KW1281 protocol, and from testing I have discovered I need to do the 5 baud init and then communicate at 10,400 baud.

First off I want to say I have successfully managed to run the 5 baud init. Now, I realise the pins (D0 & D1) are capable of hardware serial, however when trying to use the hardware serial I couldn't get any connection to the car. I think it's because the hardware serial doesn't like the pin modes to be changed after setup - however this is required to perform the 5 baud init. So I have decided to use the SoftwareSerial library for the following 10,400 baud communication.

With this library I successfully receive three (incorrect) response bytes from the ECU when setting a baud rate of 9600, however the response bytes - despite being correct in the number of them (3) - are wrong in terms of their value and seem to just be zero values.

Now as my car requires 10,400 baud communication, I instead setup the serial port to 10,400 baud. I know from experience that using 9600 baud will give incorrect response bytes and 10400 baud solves this. So I expected this would work and solve my problem, however it didn't. I still get 3 bytes containing 0. Just to be clear the three correct values should be: 55 01 8A

So I was wondering:

Am I right in assuming the SoftwareSerial library will work for any baud rate, even 10,400?
If yes to point 1, can anyone suggest why I might be getting data bytes containing 0 instead of the correct values?

As the full code is too long to post, the code for setting up the UART at 10,400, and then receiving the bytes is as follows:

#include <Wire.h>
#include <SoftwareSerial.h>

SoftwareSerial obd(pinKLineRX, pinKLineTX, false); // RX, TX, inverse logic
obd.begin(baudrate);

uint8_t data = 0;
int recvcount = 0;
char s[3];

while (obd.available())
{
   uint8_t data = obd.read();
   s[recvcount] = data;
   recvcount++;
}

And then to print the data I do the following:

#include <Adafruit_GFX.h>
#include <UTFTGLUE.h>

UTFTGLUE lcd(0x9488,A2,A1,A3,A4,A0);

char textout[30];
int xVal = 50;
cursorY = 10;
for (int i=0; i < size; i++)
{
  uint8_t data = s[i];

  sprintf(textout, "%i ", data);
  lcd.print(textout, xVal, cursorY);
  xVal += 10;
}

cursorY += 10;

The output on the LCD is

  0 0 0

When it should be

  55 01 8A


texts: What's the simplest way to get arduino functionality?

texts: I want to control a servo with the least amount of components. But generally, what is the simplest way to do this without actually using a fullblown arduino board?


texts:
I have set up an LED who's brightness is controlled by a sonar sensor.  The sonar works well and I can see the values coming from it through the serial monitor.  The LED fades until about 700 using analogWrite

#include <NewPing.h>

#define TRIGGER_PIN  12
#define ECHO_PIN     11
#define MAX_DISTANCE 5000

int LED_PIN = 3;

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

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

void loop() {
    delay(50);
    int uS = sonar.ping();
    long int max_uS = 8000;
    float brightness = (1-(((float)uS/(float)max_uS)))*1024;
    if(brightness < 0){
        brightness = 0;
    }
    Serial.print("Distance: ");
    Serial.print(uS / US_ROUNDTRIP_IN);
    Serial.print("\" ");
    Serial.print(uS);
    Serial.print(" ");
    Serial.println(brightness, 5);

    analogWrite(LED_PIN, brightness);
}

When I view the serial monitor, I've made it output a line that looks like this:

Distance: 10" 1500 830.00000

830 is the number I'm using for my analogWrite.  I can move my hand farther and closer to the distance sensor and when I do, the light fades, but after 13" (which is brightness = 774) the LED looks like it turns back on high.

Between 1"-13" it fades very smoothly, except at 13" the light is almost out, then at about 14" it turns on again almost at full brightness and is very hit or miss from there.  Even though the numbers in the serial monitor are holding steady.

Any reason for this?