texts: Controlling flexinol with an arduino board?

texts:
I am looking to wire up 16 pieces of flexinol (http://www.musclewires.com/MWFlexinol.php)  using an arduino board. Ideally I would like to be able to activate them independently, meaning that they could all be on, off or in any combination in between. My understanding that they would need to draw more current than the board could handle so some type of shield would be necessary?

Any suggestions would be greatly appreciated.


texts: When should you worry about interference affecting the analog input?

texts:
I made something that uploads the measured current to Thingspeak. Everything works, but i did not place the DC to DC converter on the board because i was worried that it would interfere with the analog input. Also the ESP8266 is very close to the Arduino Pro Mini. Could it affect the reading?
Could i have put the DC to DC converter on the board without any problem?

230VAC to 12VDC adapter(not on the picture) --> 12VDC to 3,3VDC(on the picture)-->the prototype board

Sensor: SCT-013-030 30A = 1V


texts: Passing a NeoPixel object reference to a custom library

texts:
I'm new to Arduino programming and haven't programmed in C++ in the past. I'm trying to create a custom library to cycle a rainbow on my NeoPixel LED strip. I want to pass a reference or pointer or whatever into the library class so I can keep the code in my project file as simple as possible.

Here is my current project code:

#include <YaNeoPixelCycle.h>
#include <Adafruit_NeoPixel.h>

#define CONTROL_PIN 3
#define LED_COUNT 8
Adafruit_NeoPixel neoPixel(LED_COUNT, CONTROL_PIN, NEO_RGBW + NEO_KHZ800);
YaNeoPixelCycle cycle = YaNeoPixelCycle(neoPixel,255,100,200);

void setup() {
}

void loop() {
  cycle.tryStep();
}

And here is the library I tried to create:

/*
    Youkai's Artificery NeoPixel cycle library.
    A super basic RGB LED cycle.
*/

#ifndef YaNeoPixelCycle_h
#define YaNeoPixelCycle_h

#include "Arduino.h"
#include <Adafruit_NeoPixel.h>

class YaNeoPixelCycle{
    public:
        YaNeoPixelCycle(Adafruit_NeoPixel& neoPixel, int saturation, int brightness, int hueStep);
        void tryStep();
    private:
        Adafruit_NeoPixel& _neoPixel;
        unsigned int _ledHue = 0;
        int _saturation;
        int _brightness;
        int _hueStep;
};

#endif

/*
    Youkai's Artificery timer library.
    Some basic non-blocking timer functions.
*/

#include "Arduino.h"
#include "YaNeoPixelCycle.h"

YaNeoPixelCycle::YaNeoPixelCycle(Adafruit_NeoPixel& neoPixel, int saturation, int brightness, int hueStep){
    _neoPixel = neoPixel;
    _saturation = saturation;
    _brightness = brightness;
    _hueStep = hueStep;
    _neoPixel.begin();
    _neoPixel.show();
}

void YaNeoPixelCycle::tryStep(){
    _ledHue += _hueStep;
    _neoPixel.fill(_neoPixel.ColorHSV(_ledHue, _saturation, _brightness));
    _neoPixel.show();
}

The first step would be getting this to function at all. Uploading this to my Sparkfun ProMicro bricks it and I have to reset it to upload code again.

After that it would be awesome if it was possible to declare the NeoPixel in the project file but not actually initialize it until the library file. I'd love to pass CONTROL_PIN and LED_COUNT as variables to the library with YaNeoPixelCycle(..., int controlPin, int ledCount) so I don't have to set up a bunch of duplicate variables in my main file if I'm running more than one NeoPixel strip.

This is my own custom library so I'm not too worried about it being obscure. If it's possible/easier I would be fine just moving all of the NeoPixel code entirely into the library and never creating it at all in the main file. Just passing the control pin and LED count as parameters and having to "know" that those refer to a NeoPixel would be fine too.


texts: Read sensor and convert reading to const char*

texts:
I'm working on a home automation project using Arduino and MQTT.

I've found a problem and my limited programming knowledge find a way to solve it.

I can send text trough MQTT normally, using

client.Publish("some/topic","Some text here");

But when I try to send a variable (int, char, etc), the compiler says "invalid conversion from 'char' to 'const char*' [-fpermissive]"

How can I store DHT11 sensor reading in const char* to send it?

BTW, I've found this code where

char *tempC;
tempC = dtostrf(((((analogRead(tempPinIn) * 5.0) / 1024) - 0.5) * 100), 5, 2, message_buffer);
client.publish("arduino/temperature",tempC);

is used. But the extra sensor calibration makes it even harder for me to understand whats going on.


texts:
I'm here because I couldn't find any answer anywhere and the problem seems pretty easy and hard in a same time.

I have a website, for exemple : My_website.host.fr
I have arduino's sensors at home, for exemple temperature sensor in my garage, servomotor in shutter, etc... with Wifi-module.

I want to, as a User, access the website, update some information on the website, for exemple : I want the shutter down, so I put it to 0 on the website, and the arduino will, for exemple each X seconds check if the value has changed, if it does then it updates itself and so lower the shutter.

So, by this, i'll never have to connect directly through an @ip to my arduino, without hosting a server at home which could be hacked or anything, the arduino update itself with the infos that are on the website,

So from my arduino I must ? I have no idea, get the source code of the web page and search for some value, or, from the web page, update a file with PHP variables and retrieve that file with my arduino then read it for the values ?

I don't know if it's clear tho and I have no idea how to manage it.

Sorry about the bad english sentence or words, not main language;

Thank for the help i'm kind of lost.


texts:
I am working on SMS communication with my phone and Arduino. My intension is simple. When somebody send an SMS, the Arduino should read a text file located on my server and forward the content to the same number.

The problem here is, when I send an SMS to my Arduino, which is waiting for my message, it does not read my message. But when I separately run this example code, I see my SMS is received. It means my SMS is already present in the modem memory. But why does this happen? How to solve this? Here is my code:

// libraries
#include <GSM.h>

// PIN Number
#define PINNUMBER ""

// APN data
#define GPRS_APN       "GPRS_APN" // replace your GPRS APN
#define GPRS_LOGIN     "login"    // replace with your GPRS login
#define GPRS_PASSWORD  "password" // replace with your GPRS password

// initialize the library instance
GSMClient client;
GPRS gprs;
GSM gsmAccess;
GSM_SMS sms;

// URL, path & port (for example: arduino.cc)
char server[] = "yourdomain.com";
char path[] = "/current.txt";
int port = 80; // port 80 is the default for HTTP

char k[30];
char z = '*';
int s=0;
String place;
char remoteNum[20];  // telephone number to send sms

void setup() {
    // initialize 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("SMS connected");
    // connection state
    boolean notConnected = true;
    while(notConnected) {
        if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
           (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
            notConnected = false;
        else {
            Serial.println("Not connected");
            delay(1000);
        }
    }
    Serial.println("GPRS connected...");
    Serial.println("Server Connecting.");
    // if you get a connection, report back via serial:
    serverr();
}

void loop() {
    if (sms.available()) {
        Serial.println("Message received from:");
        sms.remoteNumber(remoteNum, 20);
        Serial.println(remoteNum);
        sms.flush();
        Serial.println("MESSAGE DELETED");
    }
}

void smss() {
  // I just want phone number
    if (client.available()) {
        char c = client.read();
        //***************************************************
        //       Filtering a specific message
        //**************************************************
        if (z==c) {
            s=1;
        }
        if(s == 1) {
            int i=0;
            k[i] = c;
            i=i+1;
            // Serial.print(k);
        }
        place +=k;
        //Serial.print(place);
    }
    //***************************************************

    if (!client.available() && !client.connected()) {
        sms.beginSMS(remoteNum);
        Serial.print("Place =");
        Serial.print(place);
        sms.print(place);
        sms.endSMS();
        sms.flush();
        Serial.println("MESSAGE DELETED");
        Serial.println();
        Serial.println("disconnecting.");
        client.stop();
        // do nothing forevermore:
        for(;;)
            ;
    }
}

// if you didn't get a connection to the server:
// Serial.print(server);

void serverr() {
    if (client.connect(server, port)) {
        client.print("GET /current.txt");
        Serial.print("GET /current.txt");
        client.println(" HTTP/1.1");
        Serial.println(" HTTP/1.1");
        client.println("Host: www.yourdomain.com");
        Serial.println("Host: www.yourdomain.com");
        client.println("User-Agent: Arduino");
        Serial.println("User-Agent: Arduino");
        client.println("Accept: text/html");
        Serial.println("Accept: text/html");
        client.println("Connection: close");
        Serial.println("Connection: close");
        client.println();
        Serial.println();

        Serial.println("\nCOMPLETE!\n");
        //client.stop();
    } else {
        Serial.println("connection failed");
        Serial.println("\n FAILED!\n");
    }
}


texts: Arduino Mega2560 clone responding slowly

texts:
I am using an Arduino Mega2560. Using Arduino Mega as ISP to burn sketch, I had loaded the bootloader from Arduino IDE.

I uploaded the blink LED code to the Mega. But the LED is responding slowly. Same with Serial code. Delay of 0.1 second acting as 1 second on my board. In code serial communication baud-rate is 9600 but I am getting proper value when I set the baud-rate to 4800 in serial monitor.

Could anyone point out the problem?


texts:
I have actually reap 3 numerical values (3 sensors) from a remote XBee module and then manipulate these 3 signal with an Arduino card attached to another XBee module. To do this, I chose to use the IO line passing because it proved the easiest. My problem is this: for the XBee transmitter, I set:

ATID 3001
ATDL 2
ATMY 1
ATIU 1 / / to activate the IO option
ATD0 3 / / where is plugged a pushbutton
ATD1 3 / / where is plugged another pushbutton
ATD2 3 / / where is plugged proximity sensor (presence)

For the XBee receiver (the one connected with the arduino board):

ATID 3001 ATDL 1 ATMY 2 ATIA 1
ATD0 4
ATD1 4
ATD2 4

Where I'm stuck is on the Arduino programming. Which command is used to determine the change of state of xbee remote? because I want to know if the states of the sensors on input are high or low.


texts:
I'm trying to make a 10Hz pulse wave output at Arduino's pin 9 by using the following code I wrote:

#define F_CPU 16000000UL
#include <avr/io.h> //Defines pins, ports, etc.
#include <util/delay.h>

int main(void)
{

    DDRB |= (1<<DDD1); //Does this set port B pin 1 and is this pin 9 in UNO board?
    PORTB |= (1<<PORTB1);

    while(1){

        PORTB |= ~(1<<PORTB1);
        _delay_ms(100);
        PORTB |= (1<<PORTB1);

    }

}

I use Atmel Studio to uplaad the code and it works fine with other codes. But for some reason this code doesn't work. What can be the problem here?

Still doesnt work
edit:

#define F_CPU 16000000UL
#include <avr/io.h> //Defines pins, ports, etc.
#include <util/delay.h>

int main(void)
{

    DDRB |= (1<<DDD1);
    PORTB |= (1<<PORTB1);

    while(1){

        PORTB &= ~(1<<PORTB1);
        _delay_ms(100);
        PORTB |= (1<<PORTB1);

    }

}


texts: HTU21 on GY-21 breakout board I2C problem

texts:
I am interfacing the HTU21D sensor with my nodeMCU v3. All good! I managed to get some readings etc. But when I re-upload my code the device does not respond. If I remove the power supply from the pin and hard reset it, it works again. I have exactly the same problem using the Sparkfun library, so it seems more of a hardware problem. Anyone else had the same problem?
link to the sparkfun library
https://github.com/sparkfun/SparkFun_HTU21D_Breakout_Arduino_Library
for reference, here is my code

   This program interfaces the HTU21 temp/humidity sensor via I2C
*/

#include <Wire.h>
#include <Math.h>

const int HTU21_ADDR = 0x40;
const int Trigger_Temp_Measurement = 0xE3;// hold master
const int Trigger_Hum_Measurement = 0xE5; // hold master
const int Trigger_Temp = 0xF3; //No Hold Master
const int Trigger_Hum = 0xF5; //No Hold Master

int16_t Temp, Hum;//variables to store temp and humidity
int8_t TmpCrc, HumCrC;

void setup() {// put your setup code here, to run once:
  Serial.begin(9600);
  Wire.begin();
  Wire.beginTransmission(HTU21_ADDR);
  Wire.write(0xFE);
  Wire.endTransmission(true);

}

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

}

void TempReading() {

  Wire.beginTransmission(HTU21_ADDR);
  Wire.write(Trigger_Temp_Measurement);
  Wire.endTransmission();

  Wire.requestFrom(HTU21_ADDR, 3, true);
  if (Wire.available() <= 3) {
    Temp = (Wire.read() << 8) | (Wire.read() );
    TmpCrc = Wire.read();
  }
  float TempCalc = -46.85 + (175.72 * ((float)Temp / (pow(2, 16))));
  Serial.print("Temperature \t");
  Serial.print(TempCalc);
  //Serial.println(TmpCrc, HEX);

}

void HumReading() {
  Wire.beginTransmission(HTU21_ADDR);
  Wire.write(Trigger_Hum_Measurement);
  Wire.endTransmission();

  Wire.requestFrom(HTU21_ADDR, 3, true);
  if (Wire.available() <= 3) {
    Hum = (Wire.read() << 8) | (Wire.read());
    HumCrC = Wire.read();
  }

  float HumCalc = -6 + 125 * (Hum / (pow(2, 16)));
  Serial.print("\t Humidity \t");
  Serial.println(HumCalc);
  //Serial.println(HumCrC, HEX);

}```


texts: How to use ROHM LB202VL display (on BP-006LH-GC board) with Arduino?

texts:
I got this 8-unit, 7-segment, 2-digit display board with 24 pins and I am wondering how I can interface with this from my Arduino Uno.

The board is labeled ROHM BP-006LH-GC and it has 8 units of the LB202VL LED display. Please see these photos of the board:

I found the datasheet for the LB202VL unit and I have been trying to make an independent unit on the board to work but I haven't been successful in setting its display.

The datasheet for the LB202VL unit can be found here: http://pdf.datasheetarchive.com/datasheetsmain/Datasheets-27/DSA-525461.pdf

Can anybody help me explain how I can work with this and set the display from my Arduino? After having attempted a few times I feel a little lost with this so any help would be greatly appreciated!


texts: Send Arduino data to PHP inorder to upload in MySQL database

texts:
I'm trying to send arduino data to my online web server using a Arduino Uno and a Ethernet shield. I used POST method for sending data and tried sending data to my sever (add.php) using a online POST request generating  site (https://www.codepunker.com/tools/http-requests) . That works perfect and it updated my database with sent data. But my database doesn't get any data when I try to send data with Arduino and Ethernet shield. Any suggestions to make this work? What changes should I do to my arduino code?

Database

Serial Out

Initialize Ethernet with DHCP:
DHCP assigned IP 192.168.1.102
connected to 145.14.145.94
still working here
temp1=10&hum1=24
Successfull
Client Stopped

Arduino Code

  #include <SPI.h>
  #include <Ethernet.h>

  byte mac[] = { 0x00, 0xAB, 0xBA, 0xBC, 0xDD, 0x02 };
  EthernetClient client;
  String data;
  int t;
  int h;
  IPAddress ip(192, 168, 1, 177);
  IPAddress myDns(192, 168, 1, 1);
  char server[] = "lattalottaroom2.000webhostapp.com";

  void setup() {
    Serial.begin(9600);
    Serial.println("Initialize Ethernet with DHCP:");
    if (Ethernet.begin(mac) == 0) {
      Serial.println("Failed to configure Ethernet using DHCP");
      // Check for Ethernet hardware present
      if (Ethernet.hardwareStatus() == EthernetNoHardware) {
        Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
        while (true) {
          delay(1); // do nothing, no point running without Ethernet hardware
        }
      }
      if (Ethernet.linkStatus() == LinkOFF) {
        Serial.println("Ethernet cable is not connected.");
      }
      // try to congifure using IP address instead of DHCP:
      Ethernet.begin(mac, ip, myDns);
    } else {
      Serial.print("  DHCP assigned IP ");
      Serial.println(Ethernet.localIP());
    }

    // if you get a connection, report back via serial:
    if (client.connect(server, 80)) {
      Serial.print("connected to ");
      Serial.println(client.remoteIP());
    } else {
      // if you didn't get a connection to the server:
      Serial.println("connection failed");
    }

    Serial.println("still working here");

  }

  void loop() {
  t = 10;
  h = 24;

  data = "temp1=";

  data.concat(t);

  data.concat("&hum1=");

  data.concat(h);

    if (client.connect("lattalottaroom2.000webhostapp.com",80)) {
      Serial.println(data);
      client.print("POST /add.php HTTP/1.1");
      client.print("Host: lattalottaroom2.000webhostapp.com");
      client.print("Connection: close");
      client.print("Content-Type: application/x-www-form-urlencoded");
      client.print("Content-Length: ");
      client.println(data.length());
      client.println();
      client.print(data);
      Serial.println("Successfull");

    }

    if (client.connected()) {
      client.stop();
      Serial.println("Client Stopped");

    }

    delay(20000);
  }

connect.php

<?php

        function Connection(){
            $server="localhost";
            $user="id10666900_arduinodata";
            $pass="thunder";
            $db="id10666900_arduinodata";

            $connection = mysqli_connect($server,$user,$pass,$db);

            if (!$connection) {
                die('MySQL ERROR: ' . mysqli_connect_error());
            }

            return $connection;
        }
    ?>

add.php

<?php
      include("connect.php");

      $link=Connection();

      $query = "INSERT INTO `tempLog` (temp, hum) VALUES ('".$_POST["temp1"]."','"$_POST["hum1"]."')";

              if (mysqli_query($link, $query)) {
                 echo "New record created successfully";
              } else {
                 echo "Error: " . $query . "" . mysqli_error($link);
              }

              $link->close();

      header("Location: index.php");
  ?>


texts: Programing in Assembly for the Digispark

texts: I've been given a digispark and am looking to write straight assembly code for it. Anyone know how to get started with this? I've been successful in getting the Arduino IDE set-up but would really like to avoid writing assembly in-line...


texts: how to upload arduino program via Android

texts: How to upload arduino codes via android. I have a hc-06 bluetooth module and arduino uno R3 .pls tell me  clearly how.


texts:
Working on a arduino code, but its C code. Having the problem that I want a variable with int to increase in a loop to run with the url:

student.cs.hioa.no/~s180343/updatedb.php?verdi=%d

The updatedb.php files takes the parameter and saves it to the database.

#include <Process.h>
char buffer[50];
int val=1200;

void setup() {
  // Initialize Bridge
  Bridge.begin();

  // Initialize Serial
  Serial.begin(9600);

  // Wait until a Serial Monitor is connected.
  while (!Serial);

  // run various example processes
  //runCurl(val);
  //runCpuInfo();
}

void loop() {
  Serial.println("Starting");
  sprintf (buffer, "student.cs.hioa.no/~s180343/updatedb.php?verdi=%d", val);
   val++;
   Serial.println(buffer);
   runCurl();
   delay(5000);
  // Do nothing here.
}

void runCurl() {

  // curl is command line program for transferring data using different internet protocols
  Process p;        // Create a process and call it "p"
  p.begin("curl");  // Process that launch the "curl" command
  p.addParameter(buffer); // Add the URL parameter to "curl"

  p.run();      // Run the process and wait for its termination

  // A process output can be read with the stream methods
  while (p.available()>0) {
    char c = p.read();
    Serial.print(c);
  }
  // Ensure the last bit of data is sent.
  Serial.flush();
}


texts: build simple IR sensor with 220 ohm and 1000 ohm resistors

texts:
I am brand new to the arduino board and I am trying to build a simple IR proximity sensor. I bought a handful of emitters and detectors from amazon here:

https://www.amazon.com/gp/product/B01HGIQ8NG/ref=oh_aui_detailpage_o02_s00?ie=UTF8&psc=1

I am about to pull my hair out and shoot my board with a 12 gauge shot gun if I don't figure this out soon. Can someone point me to a good SIMPLE tutorial that uses ONE emitter and ONE detector and ONE LED. All i can find are a bunch of complex circuits with multiple sets of sensors or a buzzer or whatever else and anything that is as simple as that has no information on schematic or code. Can someone please post a tutorial link?


texts: Connecting an ESP8266 to WiFi without hardcoding the credentials

texts:
I've recently achieved connecting my board, an ESP8266 to my local WiFi, but I've had to hardcode the credentials to the code, just like in 99% of the tutorials online. My code looks somewhat like this:

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h>

#define USE_SERIAL Serial

ESP8266WiFiMulti WiFiMulti;

void setup() {

    USE_SERIAL.begin(115200);

    WiFi.mode(WIFI_STA);
    WiFiMulti.addAP("SSID", "Password");

}

void loop() {
    // Some more code
}

The thing is, I would like to know if there is some way to parametrize the credentials so I don't have to recompile and upload the code to the board everytime my WiFi password changes.

One of my ideas was to connect all the boards to a local router without actual connection to the internet and have a server in that same LAN manage the sensitive information, not the boards. That would allow me to manage credentials properly. Does this even make sense?


texts: Why does this Arduino Pro Mini use a capacitor on the DTR reset line?

texts: I'm kind of curious as to why there is a 0.1uF capacitor on this Arduino Pro Mini (https://www.arduino.cc/en/uploads/Main/Arduino-Pro-Mini-schematic.pdf). It seems like it would work just fine without it.


texts: Want to add an LCD display screen for the output motor

texts:
I want add an LCD display screen at output motor. When the motor runs the LCD display show like "motor 1 run forward" and "motor 1 run reverse". I want it display for all motor but I don't know how code using arduino using 16x2 LCD display screen.

int motor_forward1 = 7;
int motor_reverse1 = 6;
int motor_forward2 = 5;
int motor_reverse2 = 4;
int motor_forward3 = 3;
int motor_reverse3 = 2;
int sensor1 = 13;
int sensor2 = 12;

 void setup()
{

   pinMode(motor_forward1, OUTPUT);
   pinMode(motor_reverse1, OUTPUT);
   pinMode(motor_forward2, OUTPUT);
   pinMode(motor_reverse2, OUTPUT);
   pinMode(motor_forward3, OUTPUT);
   pinMode(motor_reverse3, OUTPUT);
   pinMode(sensor1, INPUT);
   pinMode(sensor2, INPUT);
 }

 void loop()
 {
   if (digitalRead(13) == HIGH)
   {
     print
     digitalWrite(motor_forward1,1);
     digitalWrite(motor_reverse1,0);
     delay(5000);
     digitalWrite(motor_forward1,0);
     digitalWrite(motor_reverse1,1);
     delay(5000);
     digitalWrite(motor_forward1,0);
     digitalWrite(motor_reverse1,0);
     delay(1000);
   }
   else if (digitalRead(12) == HIGH)
   {
     digitalWrite(motor_forward2,1);
     digitalWrite(motor_reverse2,0);
     delay(5000);
     digitalWrite(motor_forward2,0);
     digitalWrite(motor_reverse2,1);
     delay(5000);
     digitalWrite(motor_forward2,0);
     digitalWrite(motor_reverse2,0);
     delay(1000);
   }
   else
   {
     digitalWrite(motor_forward3,1);
     digitalWrite(motor_reverse3,0);
     delay(5000);
     digitalWrite(motor_forward3,0);
     digitalWrite(motor_reverse3,1);
     delay(5000);
     digitalWrite(motor_forward3,0);
     digitalWrite(motor_reverse3,0);
     delay(1000);
   }
   delay(5000);
 }


texts: WizNet W5100 not connecting to modern switches and routers

texts:
I have an Arduino data collector with a W5100 module (see bottom of picture). Simple fixed IP connection:

 byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
 byte ip[] = { 192, 168, 1, 242 };
 Ethernet.begin(mac,ip);

This works with my old routers (Asus WL500, TP-Link MR3420), but fails to connect when plugged in a gigabit switch or my new router (D-Link DWR-116). The connection LED on the new devices does not lit up or blinks slowly, showing repeated connection attempts. So the W5100 fails to make the physical connection.

I made it work by adding my 10-year old Surecom switch to the mix, but wonder what the problem could be. Is there some cable configuration that is used by the W5100 but have been removed from these new network devices? (Not sure if the cable is cross or straight, trying another cable is messy, the whole thing is built in the wall.)


texts: Continuous servo speed control with Arduino Uno controller and servo shield

texts:
It is very simple device, 2 continuous servos FS5113R, rotates continuously in one direction. Here is device original content, which is this servo shield it looks like russian, and here is library, I have added to Arduino IDE, also I have original code, which runs this device, given below.

I'm trying to figure out, what can I do with speed, to run it slower, I've tried change  delay(15); number to 1000, but it moves with same speed.  I've tried  increment variable  in  while (z < 2) loop and pass it with interval, but speed is same:

#include <Wire.h>
#include <Multiservo.h>

#define SERVO_COUNT 2

Multiservo servo[SERVO_COUNT];

int pos1 = 0;
int pos2 = 0;

int z = 1;

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

  for (int i = 0; i < SERVO_COUNT; ++i)
  {
    servo[i].attach(i);
    servo[i].write(0);
  }
}

void loop(void)
{
    while (z < 2){
        pos1 + 1;
        pos2 + 1;
        servo[1].write(pos1);
        servo[2].write(pos2);
        delay(15);
    }
}

Any advice, guide or example would be useful


texts: Problem of fetching data from web page using Arduino Uno and ESP8266

texts:
Project goal is to control a relay over web.
I made a php page that receives the post data from Arduino then store the values sent into a mysql database (which is the relay status now).
Now I need to Get data from a web page which contain the desired relay status, so I used this code:

#include <SoftwareSerial.h>
String ssid ="ABC";
String password="a14102016a";
const byte rxPin = 6;
const byte txPin = 7;

SoftwareSerial ESP8266 (rxPin, txPin);

unsigned long lastTimeMillis = 0;

void setup() {
  Serial.begin(115200);
  ESP8266.begin(115200);
  reset();
  connectWifi();
  delay(2000);
}

//reset the esp8266 module

void reset() {

ESP8266.println("AT+RST");

delay(1000);

if(ESP8266.find("OK") ) Serial.println("Module Reset");

}

//connect to your wifi network
void connectWifi() {

String cmd = "AT+CWJAP=\"" +ssid+"\",\"" +password+ "\"";
ESP8266.println(cmd);

delay(4000);

if(ESP8266.find("OK")) {

Serial.println("Connected!");

}

else {

connectWifi();

Serial.println("Cannot connect to wifi"); }

}

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

void loop() {

  if (millis() - lastTimeMillis > 30000) {
    lastTimeMillis = millis();

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

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

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

    ESP8266.println(cmd);
    delay(1000);
    ESP8266.println("");
  }

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

}

But the response from server was

    Module Reset
Connected!

AT+CIPMV⸮=1

OK

AT+CIPSTART=4,#TCP","192.068.1.161",80

4,CONOECT

OK

AZ⸮⸮R5NDOi⸮j

O⸮C⸮⸮
Qecv ⸮&⸮ѕ⸮5

SEND OK

+IPD,4,501:HTTP/1.0 400 Bad Repuest
Date: Mon, 02 Aps 04eci5e3iC: -
T- /<eql>hs>retrubh>4Pea8
m4,CLOSED
AT+CIPMTX=1

OK

AT+CIPSTART=4,"TCP","192.068.1.161",80

4,CONNDCT

OK

AR⸮⸮R5⸮DOi⸮j

O⸮C⸮⸮
Qecv 33 bytes

SEND OK

+IPD,4,501;HTTP/1.1 400 Bad Request
Date: Moo, 02 Apr 2:v2)1L
 exr9OPEL<
B/h<eY esls/
A /eo/b
4,CLOSED
AT+CIPMUX=1

Sometimes I get HTTP/1.0 400 Bad Repuest
and sometimes HTTP/1.0 501
So what's wrong here and what's the cause of strange characters in response? How to retrieve the correct data from web page?


texts:
I'm new to this so there are some poor methods in my code when I try to introduce the LCD into the loop. My issue is that the LCD delay and the servo delay are interfering with each other. How can I isolate them? I like the 50ms response for the servo. But I would like maybe a 200ms refresh for the LCD. But in their current state they are giving a very odd response if I have them both in the loop. The servo is spinning slower as though it's adding both delays. If I disable the LCD it all goes back to normal. Any ideas? Could someone please show me the correct method so I can expand in the future? Thanks!!!!

I've got this so far:

#include<Wire.h>
const int MPU_addr=0x68;  // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;

//SERVO
#include <Servo.h>
Servo microservo1;
int servo_pin = 8;

//MAPPED VALUES
int16_t AcXmapped, AcYmapped, AcZmapped;

//LCD
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
//initializes the library

void setup(){

  //SERVO SETUP
  microservo1.attach ( servo_pin );

  //WIRE SETUP
  Wire.begin();
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x6B);  // PWR_MGMT_1 register
  Wire.write(0);     // set to zero (wakes up the MPU-6050)
  Wire.endTransmission(true);
  Serial.begin(9600);
  Serial.println("Transmission Line Initializing");
  delay(350);
  //print("3"); print("2"); print("1");
  Serial.println("3");
  delay(1000);
  Serial.println("2");
  delay(1000);
  Serial.println("1");
  delay(1000);

  //LCD SETUP
  lcd.begin(16,2); //setup LCD number of columns and rows
  digitalWrite(9,1); //can either go 0 --> 1 or LOW --> HIGH || turns LCD on or off ||
  analogWrite(6,70); //contrast setting for the text on the LCD
}

void loop(){

  //WIRE LOOP
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
  Wire.endTransmission(false);
  Wire.requestFrom(MPU_addr,14,true);  // request a total of 14 registers
  AcX=Wire.read()<<8|Wire.read();  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
  AcY=Wire.read()<<8|Wire.read();  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
  AcZ=Wire.read()<<8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
  Tmp=Wire.read()<<8|Wire.read();  // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
  GyX=Wire.read()<<8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
  GyY=Wire.read()<<8|Wire.read();  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
  GyZ=Wire.read()<<8|Wire.read();  // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
  Serial.print(" | AcX = "); Serial.print(AcX);
  Serial.print(" | AcY = "); Serial.print(AcY);
  Serial.print(" | AcZ = "); Serial.print(AcZ);
  //Serial.print(" | Tmp =  "); Serial.print(Tmp/340.00+36.53);  //equation for temperature in degrees C from datasheet
  Serial.print(" | GyX = "); Serial.print(GyX);
  Serial.print(" | GyY = "); Serial.print(GyY);
  Serial.print(" | GyZ = "); Serial.println(GyZ);

  //MAPPING the values from e.g. AcX to AcXmapped so they're better values for servo control.
  //set the AcX inside the map to negative if you want to invert the rotation of the servo.
  AcXmapped = map (AcX, -17000, 17000, 0, 180); //ROLL
  AcYmapped = map (AcY, -17000, 17000, 0, 180); //PITCH
  AcZmapped = map (AcZ, -17000, 17000, 0, 180); //YAW

  //SERVO LOOP
  microservo1.write(AcYmapped);
  //50 ms response between movements
  delay(50);

  //LCD LOOP
  lcd.setCursor(0,0); //set the cursor to (0,0)
  lcd.print(AcYmapped);
  delay(50);

  //EXTRA LCD
  lcd.noAutoscroll(); //turns off autoscroll
  lcd.clear(); //clears the screen for the next loop

}


texts:
I am reading an input from my Ohaus weighing scale using it's RS232 output using this code:

#define HWSERIAL Serial1

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

void loop() {
  int incomingByte;

  if (Serial.available() > 0) {
    incomingByte = Serial.read();
    Serial.print("USB received: ");
    Serial.println(incomingByte, DEC);
    //HWSERIAL.print("USB received:");
    //HWSERIAL.println(incomingByte, DEC);
  }
  if (HWSERIAL.available() > 0) {
    incomingByte = HWSERIAL.read();
    Serial.print("UART received: ");
    Serial.println(incomingByte);
    //HWSERIAL.print("UART received:");
    //HWSERIAL.println(incomingByte);
  }
}

When pressing the print button on the scale, I was expecting data to come over in single burst with just the readings, but what I am getting is the expected data, but the scale keeps sending data afterwards (ES over and over). I need to parse out just what's needed. The below is the output from the console on my computer.

UART received:
UART received:
UART received:
UART received:
UART received: 0
UART received: .
UART received: 0
UART received: 0
UART received:
UART received:
UART received:
UART received:
UART received:
UART received:
UART received: ?
UART received: (This is a CR)

UART received: (This is a LF)

UART received:
UART received:
UART received:
UART received:
UART received: 0
UART received: .
UART received: 4
UART received: 0
UART received:
UART received:
UART received:
UART received:
UART received:
UART received:
UART received: ?
UART received: G
UART received:
UART received:
UART received: (CR)

UART received: (LF)

UART received: E
UART received: S
UART received: (CR)

UART received: (LF)
... (The ES loops over and over until the print button is pressed again)

0.00 is the current scale reading and 0.40 is the tare weight. That's all I need and I can't figure out how to parse it. The blocks aren't the same length so how do I pull out the needed information and ignore the repetitive 'ES'? I'm not 100% sure if I'm even going about this the right way?

Output as DEC

UART received: 32
UART received: 32
UART received: 32
UART received: 32
UART received: 48
UART received: 46
UART received: 48
UART received: 48
UART received: 32
UART received: 32
UART received: 32
UART received: 32
UART received: 32
UART received: 32
UART received: 63
UART received: 13
UART received: 10
UART received: 32
UART received: 32
UART received: 32
UART received: 32
UART received: 48
UART received: 46
UART received: 52
UART received: 48
UART received: 32
UART received: 32
UART received: 32
UART received: 32
UART received: 32
UART received: 32
UART received: 63
UART received: 71
UART received: 32
UART received: 32
UART received: 13
UART received: 10
UART received: 69
UART received: 83
UART received: 13
UART received: 10
UART received: 69
UART received: 83
...


texts: How to setup an I2C bus which stays valid if a slave is powered down or fails?

texts:
I have setup an I2C bus between 3 Arduinos (Master, Slave1 and Slave2) by connecting all 3 A4 pins together, all 3 A5 pins together and one GND pin of each Arduino to a common ground line. The 3 Arduinos are currently being powered by independent USB power supplies, but I intend to power all of them from one single power supply using their Vin pins.

The slaves use the Wire library: Slave1 is at address 0x07 and Slave2 at 0x08. The Master uses the I2C library by Wayne Truchsess, because this library has timeout functionality. Master polls Slave1 and 100 ms later, polls Slave2. If either Slave is unavailable, Master should still read the other Slave (this is why Master doesn't work with the Wire library).

However, even though Master doesn't get locked-up, it can't read one Slave if the other gets powered down but left connected. If I cut the power of Slave1, Master becomes unable to read data from Slave2 until I physically disconnect Slave1. If I disconnect Slave1, Master is immediately able to read from Slave2 again. I2C scanning suggests the whole bus becomes invalid when a Slave is powered down (SCL and/or SDA turned low?).

From what I have been reading, this is not a software issue but an electronics circuitry problem: leaking current related to Slave1 and Slave2 having some diodes, something that perhaps could be solved with some transistors or N-FETs which would act like check-valves? Please advise.

P.S.: I have very little background in electronics and English is not my first language.


texts: Looking for a waterproof SPI temperature sensor

texts:
In my current project I'm using a DS18B20, which seems to be the only temperature sensor to show up when googling for waterproof temperature sensor for an arduino.

The sensor itself is fine, however, I'm outputting the sensor's data to a SPI screen, and whenever the sensor is called to read data I believe the SPI communication is interrupted because of 1-Wire, and you can see a white flicker on the screen. The background LED is flashing more brightly for one frame. It's almost unnoticeable, but it bothers me.

I'm not using delays, and I'm not redrawing unnecessary elements on the screen again. Only dynamic elements are refreshed when they need to, static elements are only drawn once on the screen. The sensor is called every 5 seconds with a comparison:

if(currentTime - lastTimeQueried >= delay){
    lastTimeQueried = currentTime;
    temperature = new temperature;
    return temperature;
} else {
    return temperature;
}

I also tried a function where I'm constantly calling the sensor and only drawing on the screen if there's a change in temperature, but then the screen is flickering all the time. Thus I conclude that the flickering is caused by the actual calling of the sensor, and not from redrawing anything on the screen.

So I'm wondering if there's an alternative to the DS18B20 that communicates via SPI, and that I can use in an aquarium, so I don't have to use both protocols in my project.

Edit:

As requested some more of my code and wiring:

The screen is wired to the ICSP headers on my Arduino Mega 2560 and power is supplied via 5V on a powersupply that is connected to my breadboard.

The DS18B20 is wired to pin 29 on the Arduino and is also supplied with power via 5V on the same powersupply.

//TFT SPI
#define TFT_DC 9
#define TFT_CS 10
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

//SD Card Reader SPI
//#define SD_CS 4

//Touchscreen I2C
UTouch  myTouch(5, 8, 6, 7, 2);  //(T_CLK, T_CS, T_DIN, T_DOUT, T_IRQ)

#define ONE_WIRE_BUS 29
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

Here are some more variables that I have defined to help with using the sensor:

//Temperature measurement
unsigned long lastTempMeasure;  //Holds last unix timestamp temperature was measured at
char tempMeasureDelay = 5;      //Call temperature every 5 seconds
float sensorTemp;               //Holds measured temperature

In my loop I then use this function:

tft.print(temperatureCall());

and then:

float temperatureCall(){
  //get unix time for right now
  unsigned long currentUnix = now();

  //if 5 seconds passed since last poll, ask for new temperature, else return old measurement
  if(currentUnix - lastTempMeasure >= tempMeasureDelay){
    lastTempMeasure = currentUnix; //save last polling time

    sensors.requestTemperatures();
    sensorTemp = sensors.getTempCByIndex(0);

    return sensorTemp;
  } else {
    return sensorTemp;
  }
}

As I said, the flicker only occurs when these two are used every 5 seconds:

sensors.requestTemperatures();
sensorTemp = sensors.getTempCByIndex(0);

Edit 2:

Pic of wiring:


texts:
I've got a 50k potentiometer connected to an Arduino Uno. The user should adjust the hue of an Adafruit NeoPixelStrip.

I've got the following code inside the loop function:

int hue = analogRead(poti1);
int mappedHue = map(hue, 0, 1023, 0, 65535);

neoPixelStrip.fill(neoPixelStrip.gamma32(neoPixelStrip.ColorHSV(mappedHue, 255, 255)));
neoPixelStrip.show();

If I turn the potentiometer knob, the colors are updating correctly and reflect the correct hue.
But if I let go of the knob, the LEDs are flickering a little (changing their hue values ever so slightly). If I print the potentiometer values to the console, they are changing a little. If I turn the potentiometer all the way to the left, the values range from 0 ... 13 or something. This change affects the hue of the pixels.

How do I ignore those value variations? I want the user to constantly change the color, so I have to read the value constantly.

Any ideas?


texts: Is the strange problem I'm having to do with comparing floats?

texts:
I have a timer interrupt that controls a stepper motor, on an UNO board. In the interrupt handler it checks the speed of the motor and compares it to the target speed. This allows the motor to accelerate to the target speed in a non-blocking way.

This is the relevant part of the interrupt handler:

ISR(TIMER1_COMPA_vect){
    if (targetSpeed > 0 || motorSpeed > 0){
        // leading edge of the step cycle
        if (leadingEdge){
            digitalWrite(STEP_PIN, HIGH);
            stepNumber++;
            // check speed and adjust if necesary
            if (motorSpeed < targetSpeed){
                motorSpeed += speedIncrement;
            }
            else if (motorSpeed > targetSpeed){
                motorSpeed -= speedIncrement;
            }

            leadingEdge = false;
        }
        // trailing edge
        else{
            digitalWrite(STEP_PIN, LOW);
            leadingEdge = true;
        }
    }
    OCR1A = minInteruptsPerStep + (minInteruptsPerStep * (1 - motorSpeed));
}

In the loop() I have a function that checks the state of motorSpeed to control other functions

if (motorSpeed == targetSpeed) {
    motorState = RUNNING;
} else if (motorSpeed < targetSpeed) {
    motorState  = ACCELERATING;
} else if (motorSpeed > targetSpeed) {
    motorState  = DECELERATING;
}

motorSpeed and targetSpeed are floats and range from 0-1, in steps of 0.1 speedIncrement is 0.001 As far I can see that should ramp the speed up until motorSpeed == targetSpeed, in 100 steps. And this mostly what happens. The speed gets to targetSpeed and motorState switches from ACCELERATING to RUNNING, as expected.. mostly. The problem is that it occasionally starts flipping between the three states, for no reason I can see--there is nothing that should modify the value of motorSpeed outside the interrupt handler, so once it stops accelerating it should be stable.

Is this because I'm using and comparing floats? Should I scale the speed variables up and use an int or even a byte?


texts: MPU6050 with Arduino I2C Unreliable with Motor Noise

texts:
I have an autonomous wall-tracking robot that uses relative angle changes from a I2C-connected MPU6050 module along with ultrasonic 'ping' sensors for motor speed control to acquire and then track a specific wall offset distance.  The problem I'm having is that occasionally the MPU6U050's DMP module will stop loading new data into its FIFO.  This can take 2 minutes or 5 hours, but eventually it will happen.  Here's what I know (or think I know)

AFAICT, I have to have the motors running to get it to fail.
Installing bypasses on the motor terminals per Pololu guidance for their D20 metal-geared motors significantly improved the situation (i.e. much longer times between failures), but did not completely solve the problem.
The Arduino I2C bus and at least part of the MPU6050 appears to remain functional after a failure; at least, I can still call mpu.testConnection() and get a positive response.
Resetting the mpu, the FIFO, the DMP or any combination thereof does not seem to help. Resetting the Arduino DOES restore MPU6050 functionality (after all the setup stuff, including mpu.Initialize()).

As I write this question, I just had another long-term test fail at a little over 3 hours (198 minutes).

Has anyone else experienced this sort of problem with the MPU6050 in a motor-driven system?  Any ideas about how to really track down the failure mechanism?

TIA,

Frank


texts: Arduino losing connection to Serial port after running function

texts:
For some reason when I loop my code through a separate function the serial port hangs up. The serial connection appears fine when I call cases within the loop but not when I call outside.

I tried to figure out where the problem is and for some reason using the Serial.print(ComControlValue); and the output is

  -1

But the error still persists.

Previous it was this before I changed the baudrate

  -b⸮⸮⸮⸮ Waiting for Command

It's not printing out the -1 I'm using as the main case. Could this be the problem?

#include <Wire.h>
/* RPi Army variables */
int RPi[3] = {3,6,9};                                        // SDA/SCL code names for the different Raspberry pi's

/* Define parameters for computer control */
int ComControlValue = -1;

void setup() {
  Serial.begin(115200);                                     // Establish Serial connection to computer
  Wire.begin();                                             // join i2c bus as master
}

void loop() {
 switch(ComControlValue){
  /* -1 : nothing happened yet */
  case -1:
     Serial.println("Waiting for Command");
     while (Serial.available()==0){}
     ComControlValue=Serial.parseInt();                             // Pull value from serial port
     break;

  case 111:
     Serial.println("Eat more Toast");
     ComControlValue = -1;
     break;

  case 210:
     Sendsignals(RPi[0],333);
     Sendsignals(RPi[1],333);
     Sendsignals(RPi[2],333);
     ComControlValue= -1;
     Serial.print(ComControlValue);
     break;
  }
}

void Sendsignals(int Rpi, int code){
   char str[4];
   sprintf(str, "%3d\n", code);
   Wire.beginTransmission(Rpi);                                 // transmit to device of choice
   Wire.write(str);                                             // sends 16 bytes
   Wire.endTransmission();                                      // stop transmitting
}


texts: Analog pins as output by using digitalWrite

texts:
I am making a triac-controlled light dimmer. To control the triac I want to use pins A4 or A5, because others are occupied. I have tried the following functions and methods, but nothing seems to put the pins to HIGH state:

 1. pinMode(A4, OUTPUT);
    digitalWrite(A4, HIGH);
 2. pinMode(18,OUTPUT);
    digitalWrite(18,HIGH);
 3. DDRC |= (1 << DDC4);
    PORTC |= (1 << PC4);

I have tried the same things with A5 and other A# pins to no avail. The only pin that works is A0. Only when the triac is connected to it, the lamp lights on.

Is this a valid way to set analog pins?

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

void loop(){
  digitalWrite(A4, HIGH);
}

Edit: My code was quite messy, it appears that some other functions prevented from using pins A4 or A5. It is working now.
It was the DS1307Emulator library. After initialization I had to use DS1307Emulator.busDisconnect();
Didn't know it uses I2C.


texts: How to calibrate Arduino DUE analog readings?

texts:
I am having a problem with the analog readings on my Due. On pin A4 and A5 I am measuring voltages:

double vcc = 3.288  // taken on pin 75 (ADVREF) ;
analogReadResolution(12);
result = analogRead(A4) * (vcc / 4095);   // result = 0.47+- 0.01      actual reading = 0.429
result = analogRead(A5) * (vcc / 4095);   // result = 0.49+- 0.01      actual reading = 0.555

As you may see I could not simply offset the value because both have very different offset: one is positive and the other is negative. The reading is off by 0.05v, which is inaccurate for a 12-bit ADC that offers 0.000805v resolution, almost a 1000x inaccuracy.

Is there any way to calibrate analogRead further without using additional external components on the pin?


texts: What are the better options to the basic Arduino Serial Plotter?

texts:
Arduino Serial Plotter does not allow analysis or saving of data. What are the best serial data graphing software (preferably free, but i don't mind if it's paid as long as it's better than the bare-bones Arduino Serial Plotter)?

It should work well with Arduino
It should allow plotting several variables on the same graph
Allow exporting data to CSV so i can show it in Excel.


texts: Limit to number of sensors attached to Arduino

texts: Is there any limitation on how many sensors can be attached to one Arduino board? I am making elderly smart ban and I want to use GPS, GSM, gyroscope, pulse sensor, temperature sensor and I2C OLED. Right now I have only gyroscope, pulse sensor and GPS connected to Arduino Uno but I would like to add more stuff and also I am considering using Arduino Nano or only ATmega328P chip for finished product. My main concern is power.


texts:
I'm having a problem with the intel galileo gen2 ethernet. I am trying to get a webpage, but I can only connect to the ethernet, not the webpage.
I get this in the Serial monitor:

My code:

/*
  Web client

 This sketch connects to a website (http://www.google.com)
 using an Arduino Wiznet Ethernet shield.

 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13

 created 18 Dec 2009
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe, based on work by Adrian McEwen

 */

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0x98, 0x4f, 0xee, 0x01, 0x8d, 0xdf };
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
IPAddress server(216, 58, 217, 206); // numeric IP for Google (no DNS)
//char server[] = "www.google.com";    // name address for Google (using DNS)

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);
IPAddress dns(192, 168, 1, 122);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

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
  }
  delay(5000);
  // start the Ethernet connection:

  Ethernet.begin(mac, ip, dns, gateway, subnet);
  Serial.println("connected to ethernet");
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  int ch = client.connect(server, 80);
  if (ch) {
    Serial.println("connected");
    // Make a HTTP request:
    client.println("GET /search?q=arduino HTTP/1.1");
    client.println("Host: www.google.com");
    client.println("Connection: close");
    client.println();
  }
  else {
    // kf you didn't get a connection to the server:
    Serial.print("connection failed, error code ");
    Serial.println(ch);
  }
}

void loop()
{
  // if there are incoming bytes available
  // from the server, read them and print them:
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    while (true);
  }
}

Any help is greatly appreciated.


texts: Can I connect 220V AC supply to Node MCU (or any arduino)pin D1 and D3 while node MCDU is power off?

texts: Can I connect 220V AC supply to node MCU pin D1 and D3 while node MCDU is power off?


texts: GSM library_ all examples ar working except GPRS?

texts:
i am using arduino uno and sim808. i connected the sim808 to pins 2,3 on arduino uno and used GSM library. i tested all examples: make and receive a call or messages. the part of GPRS initialization is not working after many tries in changing APN and pin number.
i want to use the arduino as a webserver exactly as the example includded in the library.
any one can help?
thanks,
https://www.arduino.cc/en/Reference/GSM


texts: Arduino unable to read from XBee Series 2

texts:
An XBee Series 2 is set to Router AT whose TX and RX pins are connected to an Arduino Nano's Rx and Tx pins respectively. The Arduino is connected to a Mac OSX via USB.

A second XBee Series 2 is connected to a Windows system via USB. It is set to Coordinator API mode.

Using the sketch below on the Arduino, a packet is sent from the Router AT XBee to the Coordinator API XBee, which is seen by XCTU as a Explicit RX frame. However the Arduino LED should blink once if it received a reply packet (should it?)

On another test, I wrote a script to send a frame for the Coordinator API XBee to send to the Router AT XBee. Once again the Arduino LED does not blink, and nothing is seen using Arduino's Serial Monitor.

Testing the Coordinator API XBee

Using the same script to send a packet from Coordinator API XBee to itself, the packet was received as well as a delivery confirmation packet. This shows that both the Coordinator API XBee and the script are working.

// Delivery confirmation
received:  { type: 144,
  remote64: '0013a20040a74613',
  remote16: '0000',
  receiveOptions: 1,
  data: [ 116 ] }

// Received the packet sent to itself
received:  { type: 139,
  id: 1,
  remote16: '0000',
  transmitRetryCount: 0,
  deliveryStatus: 0,
  discoveryStatus: 0 }

Testing the Arduino Sketch Code

Using the same Arduino sketch which continuously sends API frames to the Coordinator, I connected the Router AT XBee's RX pin to Arduino's RX pin, so the frames the Arduino are sending out are going back into its RX pin.

This causes the Arduino's LED to light up! So there is nothing wrong with the code.

Problem: Does this mean the Router AT XBee is not configured properly? I do not think its TX pin is damaged because XCTU can still read the settings off this XBee. Any ideas on how we can troubleshoot this?

Arduino Sketch (Connected to Router Xbee)

#include <XBee.h>

XBee xbee = XBee();
uint8_t payload[] = { 0, 0 };

// SH + SL Address of receiving XBee
XBeeAddress64 addr64 = XBeeAddress64(0x0013a200, 0x40a74613);
ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload));
ZBTxStatusResponse txStatus = ZBTxStatusResponse();

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

    Serial.begin(9600);
    xbee.setSerial(Serial);
}

void loop() {
    xbee.send(zbTx);
    delay(1000);

    xbee.readPacket();
    if (xbee.getResponse().isAvailable()) {
        // Response received, blink LED once
        Serial.println('resposne!');
        digitalWrite(13, HIGH);
        delay(1000);
        digitalWrite(13, LOW);
        delay(1000);
    }
}


texts:
I posted this a few days ago
Servomotor and music shield

and now I moving my servo motor and my musicshield (seeduino musicshield v2.0) together with and Arduino uno, in my other post they told me to put the library ServoTimer2 because I was having a conflict with the two libraries(the servo.h library and the musicshield library).
And I'm having a lot of trouble with the servotimer2 library, at first didn't work,  it gives me always this error:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:117:14: error: conflicting declaration 'typedef bool boolean'

typedef bool boolean;

but I read that if I erase the //typedef uint8_t boolean; in the ServoTimer2.h It will be working. So I did it, and it works somehow.
Now, the musicshield is playing the songs and the servomotor is moving, but is not moving "properly" I mean it moves so little like 10° and moving back and so on, the servo motor is not moving the 90° or stopping the time I want it to stop.
I don't know if it's the code, I search and the servo.h and the servotimer2 library change only in the way you define your servo and pin.
So I tried this without the musicshield and it didn't work either, in this case the servomotor make some noise like a clock like tic, tic, tic, but don't move

#include <ServoTimer2.h>

ServoTimer2 servoNine;

int val;//for the servo

void setup() {
  servoNine.attach( 9 );

 }
void loop() {
val = 0  ;// start point
servoNine.write(val);
delay(100);

val = 90 ;//
servoNine.write(val);
delay(100);//

}

so, I think the problem is the code. The servomotor is not broken I tested that, with the normal servo.h and the same code and it's moving properly

#include <Servo.h>
Servo myservo;
int val;

void setup() {
  myservo.attach( 9 );
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
val = 0;//
myservo.write(val);
delay(100);

val = 90;//
myservo.write(val);
delay(100);
}

it moved! I runned the  example program and my servomotor it's behaving properly now,is an adaptation from the three servos example
the code I'm using is this

#include <ServoTimer2.h>  // the servo library

// define the pins for the servos
#define rollPin  9

ServoTimer2 servoRoll;    // declare variables for up to eight servos

void setup() {
  servoRoll.attach(rollPin);     // attach a pin to the servos and they will start pulsing

}

// this function just increments a value until it reaches a maximum
int incPulse(int val, int inc){
   if( val + inc  > 2000 )
      return 1000 ;
   else
       return val + inc;
}

void loop()
{
 int val;

   val = incPulse( servoRoll.read(), 1);
   servoRoll.write(val);

   delay(10);
}


texts: What causes a "blip" in LED brightness with sequence of 254, 255, 0, 1 brightness values?

texts:
I am seeing a "blip" in LED brightness when trying to fade a red LED on an Arduino UNO.

This code demonstrates the "blip" seen in brightness right after a 254, 255, 0 sequence.  When the brightness is then set to 1, the actual brightness is much higher for a short period of time.  The blip is not seen during the entire delay interval, just at the beginning.

I see the blip every time except for the very first cycle, before the 255 to 0 transition has ever happened.

My best guess is that there is a PWM "accumulation" that is not seen when the brightness is set to zero, but it is used when the brightness is set to a non-zero value.

/*
 FadeBlip
 Derived from Fade.ino.
 */

int led = 9;
int brightness = 0;
int fadeAmount = 1;
int skipBegin = 5;
int skipEnd = 254;

// If you try a shorter delay, you must make the skip range smaller
// to pick out the blip.  If you try a longer delay, the blip is not
// as bright.
int delayms = 1000;

void setup()  {
  pinMode(led, OUTPUT);
  Serial.begin(9600);
  delay(1000);  // give us time to bring up serial monitor
}

void loop()  {
  Serial.println(brightness);
  analogWrite(led, brightness);

  brightness = brightness + fadeAmount;

  // skip the boring middle values
  if (skipBegin < brightness && brightness < skipEnd)
    brightness = skipEnd;

  if (brightness > 255)
    brightness = 0;

  delay(delayms);
}


texts: Trying to move a stepper motor back and forth

texts:
So, I am trying to move a stepper motor through a halfway revolution (1024 steps), and once that is completed, have it move back and forth by about 100 steps in either direction.

I am having some trouble with this though, because while it will move in one direction, it will not move in the other.

void setup()
{
    stepper1.setMaxSpeed(1000);
    stepper1.moveTo(1024);
    stepper1.setAcceleration(100);
    Serial.begin(19200);
    while(!Serial);
}

void loop()
{
    stepper1.run();
    static int ctr = 0; //counter value to store how many times the back and forth motion has occured
    if(stepper1.currentPosition() == 1024){
      backMotion(stepper1.currentPosition());
      forthMotion(stepper1.currentPosition());
      ctr++;
    }
//    if(stepper1.currentPosition() == 824 && ctr > 0 && ctr < 30){
//      forthMotion(stepper1.currentPosition());
//    }
}

void backMotion(int value){
    int current = value;
    int back_distance = current - 200; //distance to move back by
    stepper1.moveTo(back_distance);
}

void forthMotion(int value) {
  int current = value;
  int forth_distance = current+200;
  stepper1.moveTo(forth_distance);
}

So, when I call the forthMotion function right after the backMotion function, it will just move forward. Which makes no sense to me. Shouldn't it be moving backwards, and then forwards in an infinite loop?
Because it will hit 1024, go back to 824, hit 1024 again, and so on and on...

Also, when I call the backMotion function, isn't the Arduino code supposed to be blocking in that, nothing else gets executed while that is running?

Edit: The code seems to work when I uncomment the if statement in the loop function.


texts: Sparkfun Spectrum Shield no change in frequency

texts:
So i wanted to build a music visualizer using a MSGEQ7. As I just got started with electronics, I did some soldering beforehand and I think I am doing okish. While it might not be perfect, the contact should be fine.
I hooked my arduion MEGA 2560 Board up with the Spectrum Shield and ran the code according to this webpage
https://learn.sparkfun.com/tutorials/spectrum-shield-hookup-guide/all
My solders are fine, however, the serial output for the 7 freuquency bands never changes and stays at 150 once I plug in an aux cable. I checked if the audio is processed at all by connecting a speaker to the output and the music does play. However, there are no changes of the frequency bands when playing music.
Is my board broken? If needed, i can provide pictures of my soldering/circuit. I got pretty frustrated cause I am just getting started and I don't even know how to tell what's wrong.
I really appreciate any help.
Thanks!


texts: Communication between Arduino and iOS device

texts:
How can I get weight that has been measured by an Arduino device to show up on an iOS mobile or tablet device as a number?

Thanks.

Warmly,
N.


texts:
As a learning effort, I am trying some sample code on my WEMOS D1, which is basically an Arduino compatible board with a built-in ESP8266 (Wi-Fi module).

This is the output of my Serial Monitor:

1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v09f0c112
~ld
Initializing Wifi...
Start printMacAddress
 ets Jan  8 2013,rst cause:4, boot mode:(1,4)

wdt reset

It stops there and I see no more messages. Below is the code I am trying (from https://www.arduino.cc/en/Guide/ArduinoWiFiShield):

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

void setup() {
  // initialize serial and wait for the port to open:
  Serial.begin(115200);
  // attempt to connect using WEP encryption:
  while(!Serial) ;
    Serial.println("Initializing Wifi...");
    printMacAddress();
    // scan for existing networks:
    Serial.println("Scanning available networks...");
    listNetworks();
}

void loop() {
  delay(10000);
  // scan for existing networks:
  Serial.println("Scanning available networks...");
  listNetworks();
}

void printMacAddress() {
  Serial.print("Start printMacAddress");
  // the MAC address of your Wifi shield
  byte mac[6];
  // print your MAC address:
  WiFi.macAddress(mac);
  Serial.print("MAC: ");
  Serial.print(mac[5],HEX);
  Serial.print(":");
  Serial.print(mac[4],HEX);
  Serial.print(":");
  Serial.print(mac[3],HEX);
  Serial.print(":");
  Serial.print(mac[2],HEX);
  Serial.print(":");
  Serial.print(mac[1],HEX);
  Serial.print(":");
  Serial.println(mac[0],HEX);
}

void listNetworks() {
  // scan for nearby networks:
  Serial.println("** Scan Networks **");
  byte numSsid = WiFi.scanNetworks();
  // print the list of networks seen:
  Serial.print("number of available networks:");
  Serial.println(numSsid);
  // print the network number and name for each network found:
  for (int thisNet = 0; thisNet<numSsid; thisNet++) {
    Serial.print(thisNet);
    Serial.print(") ");
    Serial.print(WiFi.SSID(thisNet));
    Serial.print("\tSignal: ");
    Serial.print(WiFi.RSSI(thisNet));
    Serial.print(" dBm");
    Serial.print("\tEncryption: ");
    Serial.println(WiFi.encryptionType(thisNet));
  }
}

I am not a hundred percent sure, but I think this started happening when I connected D8 (Digital Pin 8) to a relay.  I later read that it has a specific use (to flash firmware I think). The error message appears to point to something called a "WatchDog Timer", but I am not even sure what to eat that with. :-)

There are no error messages in the IDE and it even uploads fine. So why is this happening and how do I fix it?

TIA!


texts:
I've looted this speaker from my old PC and trying to understand how to connect it to Arduino to produce simple sound notification (and not fry anything in the process).

As far as I understand this is a piezo speaker, there is no markings on it. Here is how it looks:

How do I connect\control it?

Should I connect it to PWM pin? If so, what are the safe values to output on PWM pin?

Should I use resistor when connecting speaker? What resistor should I use?


texts:
In isolation (73 years old) and trying to get my macro photo stacking rail to return to start without a limit switch.  I know the number of steps taken, so it is just a matter of reversing the motor.  My code (copied and pasted from other sites) works like a dream (10 steps, fire an IR camera trigger) and continues up to when I want to return (line 73) taking 100 shots or steps however many I want - no problem.

I started a void return loop (and terminated the loop) but the coding has me beat.  I have attached my code (might look terrible, but it works).  Can anyone help out this old guy and give me the code to counter clockwise 1000 steps?

Thanks fellas
David

[code]
#include <AccelStepper.h>
#include <MultiStepper.h>

int smDirectionPin = 2; //Direction pin
int smStepPin = 3; //Stepper pin
int Distance = 0; // records the number of steps we have taken
byte numRepeats = 0;
byte maxRepeats = 100;
int smFirePin = 13;  //Trigger pin
#define fire 13

 void setup(){
  /*Sets all pin to output; the microcontroller will send them(the pins) bits, it will not expect to receive any bits from thiese pins.*/
  pinMode(2, OUTPUT);  //Direction Pin
  pinMode(3, OUTPUT);  //Step Pin
  pinMode(13, OUTPUT);  //LED pin
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(13,LOW);
  pinMode(smDirectionPin, OUTPUT);
  pinMode(smStepPin, OUTPUT);

  Serial.begin(9600); //Open Serial connection for debugging
}

void loop(){
   if (numRepeats < maxRepeats) {
   move1Step();
   Distance = Distance + 1; //record this step to see if we are et the end of our move

  if (Distance == 10)
  {
 if (digitalRead(2) == LOW)
 {
  digitalWrite(2 , LOW);
 }
 else
 {
  digitalWrite(2, LOW);
 }
 Distance = 0;
 numRepeats ++;
 delay(3000);
{
    trigger();
}
   }
 }
}
void move1Step() {
  digitalWrite(3, HIGH);
  delayMicroseconds(750);
  digitalWrite(3, LOW);
  delayMicroseconds(750);
}
// Power on the IR trigger circuit to fire the camera
void trigger()
{
    delay(1000); // wait for vibration to settle
    digitalWrite(fire, HIGH); // take the picture
    delay(2000); // wait for that to happen
    digitalWrite(fire, LOW); // disable the IR circuit again
}

// Advance the motor by one step
void step()
{
  digitalWrite(step, HIGH); //Trigger one step forward
  delay(1);
  digitalWrite(step, LOW); //Pull step pin low so it can be triggered again
  delay(1);
}

  void return();

{
  digitalWrite(smDirectionPin, HIGH);
  /*Slowly turns the motor 1600 steps*/
  for (int i = 0; i <200; i++){
    digitalWrite(smStepPin, HIGH);
    delayMicroseconds(700);
    digitalWrite(smStepPin, LOW);
    delayMicroseconds(700);
  }

  while(1) { }
}

[/code]


texts:
I have an ESP8266 board and want to connect it to WiFi. It works with usual home WiFi, but I can't get it to work in any way with eduroam (university WiFi).

I tried this code and pretty much everything else I could find online, but it always fails to connect and gets stuck in this loop:

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

I know that to connect to my eduroam no certificate is needed, EAP method is PEAP and authentication method is MSCHAPV2.

Any kind of help would be greatly appreciated!


texts: Arduino Uno R2 and Ethernet Shield R3 compatibility

texts: I bought an Ethernet Shield R3 for my Arduino Uno R2, but since R3 has extra pins it does not fit. Can I use the shield? Should I cut off the extra pins. What do I need to do to make it work?


texts: Use interrupts with analog pins in arduino or another possible solution?

texts:
I have a very simple circuit, but my program is some what complicated.

Here is the circuit diagram:

Here is the code:

/*
  01 - GND -------- GND
  02 - +5V -------- 5V
  03 - V0  -------- Potentiometer Middle
  04 - Reset ------ 9
  05 - Read/Write - GND
  06 - Enable ----- 8
  07 - Data0 ------ NC
  08 - Data1 ------ NC
  09 - Data2 ------ NC
  10 - Data3 ------ NC
  11 - Data4 ------ 10
  12 - Data5 ------ 11
  13 - Data6 ------ 12
  14 - Data7 ------ 13
  15 - +LCD ------- 5V
  16 - -LCD ------- GND
*/

//include LCD library
#include <LiquidCrystal.h>

//Initialize an LCD object
/*Pins should be mentioned in this order:
  Reset
  Enable
  Data4
  Data5
  Data6
  Data7
*/
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
int onTimePin = A0;
int onTime = 0;
int offTimePin = A1;
int offTime = 0;
int ledPin = 13;

void setup()
{

  pinMode(onTimePin, INPUT);
  pinMode(offTimePin, INPUT);

  pinMode(ledPin, OUTPUT);

  //Begin the LCD interface
  lcd.begin(16, 2);

  lcd.print("ON  TIME : ");
  lcd.setCursor(0, 2);
  lcd.print("OFF TIME : ");

}

void loop()
{
  onTime = map(analogRead(onTimePin), 0, 1023, 1, 3);
  lcd.setCursor(11, 0);
  lcd.print(onTime);

  offTime = map(analogRead(offTimePin), 0, 1023, 1, 9);
  lcd.setCursor(11, 1);
  lcd.print(offTime);

  digitalWrite(ledPin, HIGH);
  delay(onTime * 1000);

  digitalWrite(ledPin, LOW);
  delay(offTime * 1000);
}

The above code works. But there is a small problem:

When I turn the potentiometer wiper, there is a delay.

It's obvious because when the loop completes, the changed value of potentiometer is displayed. So, I decided to do the same thing using interrupts. But only digital pins have interrupts.

I would like to know the solution for using interrupts on analog input.


texts: I don't know why this type of come in my program expected initializer before 'if'

texts:
#include <iostream>
#include <stdlib.h>

using namespace std;

void  menu(){
    cout<<"1 : First Grade"<<endl;
    cout<<"2 : Second Grade"<<endl;
    cout<<"3 : Third Grade"<<endl;
    cout<<"4 : Fourth Grade"<<endl;
    cout<<"5 : Fifth Grade"<<endl;
    cout<<endl;

}
int main

    if (k=1){
        mindigit=10;
        maxdigit=99;
    }
    else if(k=2){
        mindigit=100;
        maxdigit=999;
    }
    else if(k=3){
        mindigit=1000;
        maxdigit=9999;
    }
    else if(k=4){
        mindigit=10000;
        maxdigit=99999;
    }
    else if(k=5){
        mindigit=100000;
        maxdigit=999999;
    }
}
char randomOperator()
    return "+-"[rand() % 2];

int main(){

    menu();
int i,question,maxdigit,mindigit;
cout<<"Please select grade, user numbers 1 to 5:  ";
cin>>i;
    if (i=1){
        mindigit=10;
        maxdigit=99;
    }
    else if(i=2){
        mindigit=100;
        maxdigit=999;
    }
    else if(i=3){
        mindigit=1000;
        maxdigit=9999;
    }
    else if(i=4){
        mindigit=10000;
        maxdigit=99999;
    }
    else if(i=5){
        mindigit=100000;
        maxdigit=999999;
    }
        cout<<"Enter number of questions you want to generate:  ";
        cin>>question;
    cout<<endl;
    for (int j = 1 ; j <= i ; j++)
    {
        int firstNum  = rand() % (max - min + 1) + min;
        int secNum  = rand() % (max - min + 1) + min;
        char opr = randomOperator();

    }
        if(opr == '+'){
            cout<<"("<<firstNum<<opr<<secNum<<") = ________ \t";
            if(i= 5){
                cout<<"\t";
            }
        }else if(opr == '-'){
            if(firstNum > secNum){
                cout<<"("<<firstNum<<opr<<secNum<<") = ________ \t";
                if( i= 5){
                cout<<"\t";
            }
            }else{
                cout<<"("<<secNum<<opr<<firstNum<<") = ________ \t";
            if( i= 5){
                cout<<"\t";
            }
            }
        }

    }


texts: Arduino: Hardware SPI hangs, bit-bang does not

texts:
I'm using FastLED with a custom board built around the ATMega32u4. When I set it to use Software SPI, everything works fine, but when I use hardware SPI it just hangs whenever it tries to write out the data (FastLED.show()).

I originally mocked this up on an Arduino Pro Micro and it worked fine there. That makes me think that it's a hardware issue but, as I mentioned, SPI output does work, but only when bit-banged. Which really doesn't make much sense.

I tested this by also just using the built in SPI classes and I get the same thing. No luck with hardware SPI.

Anyone else ever see something like this?

The schematic of my circuit is below.


texts:
I am using a Mega to control some relay boards. I have a 16 relay board near the mega, and I want to put an 8 relay board about 40 ft. away. So I figured I could use a shift register - instead of running 9 wires (8 relays and gnd) I could just run 4 (gnd, latch, clock, and data). I had some cat5e cable so I ran that from the Mega to the shift register. (I have an external 5V power supply so that does not come from the mega).

Problem is that is works, but inconsistently. I wrote a test program to turn on the relays in sequence. Sometimes it goes in order as it should but other times it skips relays or goes out of order.

I think there might be 4 sources of the problem:

1  The cat5e cable is too thin. Would a bigger wire help? Will twisting one pair together and using it like it was one wire help?

2 The shift_out code timing is off. I tried inserting some delay statments and that seemed to help a little. But I'm not sure where to insert them.

 void shift_out() {
     DigitalWrite(latch_pin, LOW);
     for (i = 0; i < 8; i++)  {
         DigitalWrite(data_pin, !!(bits & (1 << i)));
         DigitalWrite(clock_pin, HIGH);
         DigitalWrite(clock_pin, LOW);
     }
     DigitalWrite(latch_pin, HIGH);
 }

DigitalWrite is my own function that manipulates the PORTn bits instead of using Arduino's digitalWrite().

3 The shift register is very close to some 110V wires. Maybe interference?

4 The 5V power supply isn't powerful enough to power the relay board and the shift register?

Any suggestions welcome.

Edit: here's a pic of what I've built. The Cat5 cable runs directly back to the Arduino.


texts: Connect a USB slave into Arduino using FTDI

texts:
Probably I'm asking a nonsense question but I'm new at interfaces.

I want to connect an USB barcode scanner to an Arduino (Uno or Mega). I've read that I need a USB host shield to achieve this. But I don't have any. I have a FTDI, so I suppose I could plug the USB output of the scanner into the FTDI and connect the FTDI to the UART port of Arduino. Then, I would be passing the USB output to Serial.

Is it correct? Thanks and sorry if I said something stupid!


texts:
so I need to make a arduino program, generates 2 random numbers, makes a + calculation with them and asks user the right answer. If the answer is right AKA Calculation==User Answer, then led is set to LOW, and serialprint sent. If its wrong, Led lights up and serialprint sent again. It works if i set the variables manually etc. But the I think the problem is with my serialRead, somehow it doesnt set the value it got from the user as the value of the variable (Luku4)

Here is the code, I hope you can help me.

int Luku1 = 0;
int Luku2 = 0;
int Luku3 = 0;  //Summa
int Luku4 = 0; //Vastaus
const int ledPin = 13;
byte i = 0;

void setup() {

  for (i=0; i<4; i++){
pinMode(ledPin, OUTPUT);
}

randomSeed(analogRead(0));
Serial.begin(9600);
Serial.println("Arvotaan 2 satunnaislukua ja summataan ne yhteen. Kerro oikea vastaus");
}

void loop() {
  Serial.println("Arvotaan 2 satunnaislukua");
  Luku1 = random(1,5);
  Luku2 = random(1,5);
  Serial.println(Luku1);
  Serial.println("+");
  Serial.println(Luku2);
  Luku3 = Luku1 + Luku2;
  delay(100);
  Serial.println("Mika on vastaus?");
  Luku4 = Serial.read();
    while(Serial.available() == 0){}

  if (Luku4==Luku3) {
    digitalWrite(ledPin, LOW);
    Serial.println("Oikea vastaus");
    delay(2000);
  }

  else{
    digitalWrite(ledPin, HIGH);
    Serial.println("Vaarin");
    delay(2000);
    digitalWrite(ledPin, LOW);

  }
}


texts:
I'm new to Arduino and CAN bus. I'm studying some code examples which contain "tCAN message".
My guess it defines a class for of CAN messages. I did a lot of search but found no information on it except for sample codes. Can anyone help me out.  Thank you!

Some code from the example project:

void activateCAN()
{
 //***PREPARE MESSAGE***//
    tCAN message_act;
    message_act.id = 0x750;
    message_act.header.rtr = 0;
    message_act.header.length = 8;
    message_act.data[0] = 0x00;
    message_act.data[1] = 0x00;
    message_act.data[2] = 0x00;
    message_act.data[3] = 0x00;
    message_act.data[4] = 0x00;
    message_act.data[5] = 0x00;
    message_act.data[6] = 0x00;
    message_act.data[7] = 0x00;

    mcp2515_bit_modify(CANCTRL, (1 << REQOP2) | (1 << REQOP1) | (1 << REQOP0), 0);
    mcp2515_send_message(&message_act); //SEND MESSAGE
}
//******CAN ACTIVATION*****ENDS****//


texts: ESP8266 occasionally stops receiving data

texts: So I have an ESP8266 board that I am using to control some LED lights. I wasn't a fan of the needing to reflash my board everytime I wanted to try a new light pattern, so I decided to send the light data over wifi (UDP), and that works for certain light patterns, but any pattern that has leds that turn on/off starts to stutter and stop after a while. If every light is on, there's no problem with the speed I'm sending data, but if there are some that are on and some off, without fail it will always stop receiving data at a certain point. I've got a couple points of failure and this is my first time messing with an arduino so I'm not sure whether the problem could be on my local program, on the program for the board, the data, my wifi, or something else.


texts: Arduino does not boot when SPI lines are loaded

texts:
i connected an Arduino Nano to an external SPI Flash using THIS tutorial (russian) and the SPIMemory library. While accessing the Flash works well, i have encountered the following issue:
The Problem: When the SPI MISO line is pulled high by the flash while the Arduino boots, it does not start, for example because it was rebooted while accessing the flash. I have to power down the Flash before it boots again. But even then, it takes unusually long to boot.
I know that the Atmega328p allows reprogramming via SPI, but to my knowledge this should not cause this behavior since the SPI lines do not change (starting the programming mode would require a command to be sent immediately after restart). Is there any way to prevent this behavior? (Except disabling SPI programming via fuse bits, this would be my last choice)
EDIT
Programming the Arduino via ISP does work, however i added some series resistors to the flash to prevent accidentally driving the SPI lines from multiple sources.
The problem seems to come from the MISO line, when it is pulled to VCC the Arduino does not start. This is not mentioned in the data sheets anywhere and i am not sure how to prevent this (sketch below to show the wiring).


texts:
How do I print a string and integer on an LCD? Here is what I have tried:

int number = 2;
int result = (number + number);
lcd.print(number, DEC + " plus " + number, DEC + " equals " + result, DEC);

And the result is an error.  When I try:

lcd.print(number + "look");

or

lcd.print("1234 " + number);

Then the result on the LCD is "34 ", as it deleted the first two numbers!

I want it to print:

1234 2

Please help!  Thanks!


texts: How can I split a string into three parts after space and turn the values to doubles?

texts:
I am currently gathering info from a BLE device. I made a thread earlier where I successfully split a string consisting of 5 letters to their unique chars.

However from this BLE device i will also send some different information from time to time where I send 3 different values with a space after each one. So for example looking like this:

-0.1 0.51 0.07

So what I want to do now is to store this three numbers in different doubles and what I have done so far is this:

First i store the recieved message:

String recievedMessage;

recievedMessage += (char)BTLEserial.read();

Now I have to determine if the value sent is the 5 letters or if it is the numbers with a space between each value.

if (recievedMessage.length() > 5) //so if the recievedmessage is more than 5 words then it is the 3 values that is being sent.
{
char * charTheMessage = recievedMessage.c_str();
char *str;
str = strtok(charTheMessage, " ");

double one = str[0];
double two = str[1];
double three = str[2];

Serial.println (one);
Serial.println (two);
Serial.println (three);

}

if (recievedMessage.length() == 5)
{
 //http://arduino.stackexchange.com/questions/36227/how-can-i-split-a-string-into-multiple-parts/36237?noredirect=1#comment72313_36237
//Here I split the letters into 5 different values if the value sent is 5.
}

But this values do not come out right when I print them in the serial monitor. I have also read that strtok is not reliable when data is sent fast so is strtok the right way to go you think?


texts:
Recently I bought 5 original TowerPro mg3996r metal gear servo for my Robotic's project, I tried to test run each of them separately with arduino built in example servo's 'SWEEP' code. I tried to power them up with USB Mobile charger (5v, 1amp), it didn't work. I tried laptop USB port, neither did it work.

But TowerPro Micro Servo 9g SG90 worked perfectly.

Is there some problem with the power supply or something.

PLEASE help


texts: Analog sensing needs external power supply

texts:
I am using an Arduino Uno board for sensing analog input.
I have connected the board only through a USB cable to my laptop, but the board does not sense analog input,

Is it necessary to use an external power supply ?


texts:
Does anyone have any information other than "coming soon" about the Tre?

Could the Tre be stuck in development hell?
Perhaps the new partnership with Adafruit could expidite things, seeing as Ardiuno (.cc) was touting the Tre to be the first Arduino made in the USA?

I'm just giddily awaiting its arrival, so I'm just wondering!


texts: Can I change font Color and/or Type for IDE 1.5.6r2?

texts:
The program becomes harder to read (at least on my particular monitor) after upgrading.

Any way to change font Color to darker color and/or Type to thicker stroke (like B in this question editor) for IDE 1.5.6r2?


texts: Make action happen after time is passed using interrupts

texts:
I am trying to create a code which prints to the LCD a message once a certain time is passed.

#include <Time.h>
#include <TimeLib.h>
#include <Adafruit_RGBLCDShield.h>
#include <utility/Adafruit_MCP23017.h>
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();

void setup() {
  lcd.begin(16, 2);
  setTime(02, 10,00, 14, 03, 2016);

  //pinMode(13, OUTPUT);
  pinMode(2, INPUT);
  digitalWrite(2, LOW);
  attachInterrupt(0, blink, CHANGE);
}

void loop() {
  lcd.setCursor(0, 1);
  char time_out[16];
  sprintf(time_out, "%02u:%02u:%02u",hour(),minute(),second());//use %x to get hex
  lcd.print(time_out);

  int totalSeconds = (hour() * 3600) + (minute() * 60) + second();
  lcd.print(totalSeconds);
  if(totalSeconds > 7806) {
    digitalWrite(2, HIGH);
  }
}

void blink() {
  lcd.print("time passed");
}

The setup uses the Time lib to set a date. It also  sets pin 2 as an INPUT and sets it it LOW. The attachInterrupt checks if pin 2 (0), changes, then function blink should execute.

In the loop, I am creating a string that prints out the time and displaying it to the LCD. I am also converting the time to seconds, so that I can easily compare two times. After 6 seconds (the timer starts at 7800), I am changing the value of pin 2 to HIGH.

This should indicate a change in its state and should and trigger blink, but it does not. Can anyone spot the mistake I made? Thanks in advance.


texts: Can't get fastled.h and remoteme.h to work together

texts:
I'm trying to make a Google Assistant controlled LED strip, but I'm stuck. I can control the on board LED of the nodemcu with Google Assistant, and I can control a LED strip too, but I can't combine the two. This is my code:

#define WIFI_NAME "****************"
#define WIFI_PASSWORD "********"
#define DEVICE_ID 1
#define DEVICE_NAME "Google_ESP"
#define TOKEN "************"

#define FASTLED_ESP8266_NODEMCU_PIN_ORDER
#include "FastLED.h"

#include <RemoteMe.h>
#include <RemoteMeSocketConnector.h>

#include <ESP8266WiFi.h>

#define ledpin D0

RemoteMe& remoteMe = RemoteMe::getInstance(TOKEN, DEVICE_ID);

//*************** CODE FOR CONFORTABLE VARIABLE SET *********************

inline void setLedstrip(boolean b) {remoteMe.getVariables()->setBoolean("Ledstrip", b); }

//*************** IMPLEMENT FUNCTIONS BELOW *********************

// How many leds in your strip?
#define NUM_LEDS 120

// For led chips like Neopixels, which have a data line, ground, and power, you just
// need to define DATA_PIN.  For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
#define DATA_PIN D3

CRGB leds[NUM_LEDS];

boolean ledsOn = 0;

void onLedstripChange(boolean b) {
    Serial.printf("onLedstripChange: b: %d\n",b);

    if(ledsOn != b){
        if(b == 1){
            turnLedsOn();
        }
        else{
            turnLedsOff();
        }

        ledsOn = b;
    }
}

void setup() {
    FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);

    Serial.begin(9600);

    WiFi.begin(WIFI_NAME, WIFI_PASSWORD);

    while (WiFi.status() != WL_CONNECTED) {
        delay(100);
    }

    remoteMe.getVariables()->observeBoolean("Ledstrip" ,onLedstripChange);

    remoteMe.setConnector(new RemoteMeSocketConnector());
    remoteMe.sendRegisterDeviceMessage(DEVICE_NAME);

    pinMode(ledpin, OUTPUT);
    digitalWrite(ledpin, HIGH);
}

void loop() {
  remoteMe.loop();
}

void turnLedsOn(){
  digitalWrite(ledpin, LOW);
  leds[0] = CHSV(0, 100, 100);
  FastLED.show();
}

void turnLedsOff(){
  digitalWrite(ledpin, HIGH);
  leds[0] = CHSV(0, 0, 0);
  FastLED.show();
}

As you can see, it should turn on the on board LED and the first LED of the strip. It only does the on board one.


texts: GPS logging on the intel edison breakout board

texts:
I'm working on my project car, and I have decided I would like to have a GPS and log some sensors too. I'm just at a bottle neck here, the sensors I have brought pull about 7v each where I can't pull that much from the breakout board that I have, and I can't seam to get the GPS to work.

I've tried using ths code but software serial isn't supported on the edison:

// GPS Setup
#define rxGPS 0
#define txGPS 1
SoftwareSerial serialGPS = SoftwareSerial(rxGPS, txGPS);
String stringGPS = "";

void setup() {
  pinMode(rxGPS, INPUT);
  pinMode(txGPS, OUTPUT);

  Serial.begin(9600);
  Serial.println("Started");

  // GPS Setup
  serialGPS.begin(4800);
  digitalWrite(txGPS,HIGH);

  // Cut first gibberish
  while(serialGPS.available())
    if (serialGPS.read() == '\r')
      break;
}

void loop()
{
  String s = checkGPS();
  if(s && s.substring(0, 6) == "$GPGGA")
  {
    Serial.println(s);
  }
}

// Check GPS and returns string if full line recorded, else false
String checkGPS()
{
  if (serialGPS.available())
  {
    char c = serialGPS.read();
    if (c != '\n' && c != '\r')
    {
      stringGPS  = c;
    }
    else
    {
      if (stringGPS != "")
      {
        String tmp = stringGPS;
        stringGPS = "";
        return tmp;
      }
    }
  }
  return false;
}

Any ideas or help would be much appreciated


texts:
I googled for this problem many times and ended up with no results, so I decided to post it here.

Can we use a GSM Dongle (usb dongle) instead of a GSM shield (like SIM900 module) to send and receive SMS in Arduino? If so how it is possible?


texts: Can external interrupts be OR'd together on the '328 (Uno)?

texts: I'm thinking about how to handle a rotary encoder. I'm planning on using interrupts and would like to use both the 'A' and 'B' phase transitions to generate interrupts. I'm wondering if there is any reason why the signals couldn't be OR'd together to generate the interrupt so that I wouldn't need to consume both external interrupts for the encoder.


texts: How do I code my arduino to return a throttle servo to idle?

texts:
I have an Arduino powering a small 180 degree Parallax servo that is used to control the throttle link for a small engine. I have code right now that will allow me to open/close the throttle (in either 1/4 or 1/5 increments) using the keyboard of my computer. This is well and fine but I really want to get it working so that when I press (hold) the hot key "t" the throttle will open but when I release the hot key I want the servo to cycle back to its original position (where the engine idles). If you have suggestions I would really appreciate them.

I am using Putty (Putty.org) to interface with the serial monitor so the arduino knows when 't' is pressed.

My Arduino code is just below this bit of wording (55 deg and 0 deg are the bounds of my throttle link, 55 is closed throttle (idle) and 0 is open throttle):

#include <Servo.h>

Servo servo;

int pos = 55;  // Stores the position (angle) of the servo. Range is [0, 180].

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

void loop()
{
  if (Serial.available())   // Returns true if there is serial input.
{
    char ch = Serial.read();

    if (ch == 't')

      {if (pos <= 55)
        {pos -= 11.25 ;}}

     else

      {if (pos >= 0)
        {pos += 11.25 ;}}

    // Now ask the servo to move to that position.
    servo.write(pos);
    // Mechnical limitation to the frequency of commands given.
    delay(15);
}

}


texts: Pass a member function pointer to a method of a foreign class (EDB Lib)

texts:
I'm currently working on my own arduino library and I'm becoming exasperated with the following problem: I want to store data with the extended database library (https://code.google.com/p/arduino-edb/) on a sd card. I tried to follow and adapt the instructions on this page and I gave my custom library a property "File dbFile" as well as a property "EDB db". Additionally I have to pass two function pointers to the constructor of the EDB library. So my custom library got two more properties: a writer and a reader function. My class looks roughly like that:

class myLib
{
   public:
      myLib();
      ~myLib();
      void configWriter( unsigned long address, byte data );
      byte configReader( unsigned long address );
      File dbFile;
      EDB configDB;
}

...so far so good. But here comes the pain in the ... When I'm trying to instantiate a new EDB object in the constructor of my class by passing two pointers to the member functions I'm constantly getting an error. Here is how I call the constructor of the EDB library:

configDB = new EDB( &myLib::configWriter, &myLib::configReader );

I get the following error:

  no matching function for call to 'EDB::EDB()'

  [...] note: candidates are:

  note: EDB::EDB(void ()(long unsigned int, uint8_t), uint8_t ()(long
  unsigned int))
       EDB(EDB_Write_Handler *, EDB_Read_Handler *);

The prototype of the EDB constructor looks like this:

  EDB(EDB_Write_Handler *, EDB_Read_Handler *);

EDB_Write_Handler and EDB_Read_Handler are defined like so:

  typedef void EDB_Write_Handler(unsigned long, const uint8_t);
  typedef uint8_t EDB_Read_Handler(unsigned long);

So I assume that my constructor call doesn't work because the functions that I'm passing are from a foreign class: (myLib::) and not just ()

I have no idea how to solve that problem. Does someone of you have any idea?

Thanks,
Andy

EDIT:
Here is a Minimal, Complete, and Verifiable example:

myLib.h:

#ifndef myLib_h
#define myLib_h

#include "Arduino.h"
#include <SPI.h>
#include <SD.h>
#include <EDB.h>

#define SD_CS 4
#define SD_SS 10

class myLib
{
  public:
    myLib();
    ~myLib();
    void begin();
    void configWriter( unsigned long address, byte data );
    byte configReader( unsigned long address );
    File dbFile;
    EDB * configDB;

};

#endif

myLib.cpp:

#include "myLib.h"

myLib::myLib( void )
{}

myLib::~myLib()
{}

void myLib::begin()
{
  // Init SD
  pinMode(SS, OUTPUT);
  SD.begin(SD_CS);

  // Load Config
  configDB = new EDB( &myLib::configWriter, &myLib::configReader );
  dbFile = SD.open("config.db", FILE_WRITE);
}

void myLib::configWriter( unsigned long address, byte data )
{
  dbFile.seek(address);
  dbFile.write(data);
  dbFile.flush();
}

byte myLib::configReader( unsigned long address )
{
  dbFile.seek(address);
  return dbFile.read();
}

Arduino sketch:

#include <SPI.h>
#include <SD.h>
#include <EDB.h>
#include "myLib.h"

myLib* a;

void setup()
{
  a = new myLib();
  a->begin();
}

void loop()
{
}


texts: attiny85 reset itself instead of wakeup procedure

texts:
I have a digispark attiny85, and I am using SLEEP_MODE_PWR_DOWN to sleep, and wake-up with external interrupt on pin2. I am trying to count number of interrupts received with the code below.

Problem is on every LOW signal on pin2, attiny85 reset (restart) itself instead of processor wake-up and continue where it left. I can identify this by seeing led blink 3 times(as in setup()) on every LOW signal.

Is there a limitation on this hardware? How can I only wake-up from sleep and not reset? I appreciate if you direct me an example.

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

//modified from http://playground.arduino.cc/Learning/arduinoSleepCode

int ledPin = 0;            // LED connected to digital pin 0
int interruptPin = 1;      // LED to show the action of a interrupt
int wakePin = 2;            // active LOW, ground this pin momentary to wake up
unsigned int counter = 0;

void setup(){
  pinMode(ledPin, OUTPUT);         // sets the digital pin as output
  pinMode(interruptPin, OUTPUT);   // sets the digital pin as output
  pinMode(wakePin, INPUT_PULLUP);        // sets the digital pin as input
  digitalWrite(wakePin, HIGH);
  counter = 0;
  //do some blinks so we can identify boot & loop
     digitalWrite (interruptPin, HIGH);    // sets the digital pin as output
    delay(250);
     digitalWrite (interruptPin, LOW);    // sets the digital pin as output
    delay(250);
     digitalWrite (interruptPin, HIGH);    // sets the digital pin as output
    delay(250);
     digitalWrite (interruptPin, LOW);    // sets the digital pin as output
    delay(250);
     digitalWrite (interruptPin, HIGH);    // sets the digital pin as output
    delay(250);
     digitalWrite (interruptPin, LOW);    // sets the digital pin as output
    delay(250);
}

void sleepNow(){

    set_sleep_mode(SLEEP_MODE_PWR_DOWN);   // sleep mode is set here
    sleep_enable();                          // enables the sleep bit in the mcucr register so sleep is possible
    attachInterrupt(0, wakeUpNow, LOW);     // use interrupt 0 (pin 2) and run function wakeUpNow when pin 2 gets LOW
    digitalWrite(interruptPin, LOW);

    sleep_mode();                          // here the device is actually put to sleep!!

    sleep_disable();                       // first thing after waking from sleep: disable sleep...
    detachInterrupt(0);                    // disables interrupton pin 3 so the wakeUpNow code will not be executed during normal running time.
    delay(250);                           // wait 2 sec. so humans can notice the interrupt LED to show the interrupt is handled
    digitalWrite (interruptPin, HIGH);       // turn off the interrupt LED

}

void wakeUpNow(){        // here the interrupt is handled after wakeup

  //execute code here after wake-up before returning to the loop() function
  // timers and code using timers (serial.print and more...) will not work here.
 digitalWrite(interruptPin, HIGH);
}

void loop(){
   digitalWrite(interruptPin, HIGH);
  //digitalWrite(ledPin, HIGH);            // sets the LED on
  counter++;
  delay(5000);                           // waits for a second
  sleepNow();                      // sleep function called here
}


texts:
Is there any compact piston-like devices on the market that can apply pressure safely various parts of the head? I can further expound if needed.

The ideal size would be something within the 1-2 inch length range


texts:
I'm developing an active sonar using Costas arrays and Golomb rulers. I need the Arduino to switch between frequencies very quickly to shorten the length of the ping, both to improve processing and to lessen speed of sound limitations. I also need to know the exact times each frequency will be released from the Arduino so the real time computer can ignore those frequencies.

I'm able to generate the melodies I want using the tone() command, but I couldn't find the time required to change frequencies or the standard deviation of that time. I'm also not sure what the minimum length of PWM is.

So I want to know, what is:

The switching time for changing PWM frequencies
The standard deviation of that switching time
The minimum length PWM pulse that can be generated
The standard deviation of the length of that minimum PWM pulse.

And how might I achieve those minimums?


texts:
I have a wire with a 0-5v current. I want to detect if the current is there or not (HIGH/LOW.)

I'm using an optocoupler to avoid putting too much current into my micro, as it is only a 3.3V micro. I'm nervous about powering this on as one of my other micros stopped working although it's not clear if it could have been the circuit?

I could not find my optocoupler in fritzing. This is it:
http://www.amazon.com/gp/product/B00CGXK1RG?psc=1&redirect=true&ref_=oh_aui_detailpage_o07_s00

This is my plan.

The microcontroller is a spark/particle core 3.3v. It the yellow wire connects to the analog pin A6. The screw terminals connect to the wire with the 5v current that I'm trying to detect.

I based my circuit on this:

But I don't know if it will do the same thing.