texts: Is my Arduino board defect? No matter what program I upload the pin 13 turns on and off 3 times and that's it

texts:
Just trying to find out if my Arduino UNO R1 board is broken or not.

First of all, everything seems normal, Arduino board shows "on" (green) when I plug it on my computer, I also can verify and upload programs to my Arduino board. But, no matter what program I upload the pin 13 turns on and off 3 times and that's it. I'm checkin it by using a LED.
Eg. if I want to use another pin (ex. 7, 8, 12) it doesn't work, or even to write a program for turning on/off 9 times pin 13 doesn't work...

Note: I noticed that pin 8 turns the LED for less than a 1/2 a second.

I already tried to restart board by bridging the reset pin and also by pushing reset directly on the board, I also reinstalled Arduino Genuino Application. I thought to update Atmega8U2 firmware but accordingly to Arduino site I don't need to update since I have firmware rev. 0.01.

It would be also great not to have to buy a new Arduino UNO. Thanks for your help

Edit:
Here is how I'm trying to make pin 12 work

int ledPin = 12;

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

void loop()
{
    digitalWrite(ledPin, HIGH);
    delay(2000);
    digitalWrite(ledPin, LOW);
    delay(2000);
}


texts:
Take a look at this picture:

I think most of use agree that the "big silvery" thing on the board (red) is the famous 16 MHz crystal of the Arduino. That's what I've believed until very recently.

I was bored so I looked at my Arduino Uno, and saw that it has what seems like another crystal (yellow). It looks like the one that is on the Pro Mini. It's also located near the XTAL pins. After I inspected the schematic a second time, it also appears that there are two crystals on the board.

Which one out of those two is actually connected to the XTAL pins and why are there two?


texts: ATtiny85 communication with computer through USB

texts: I am trying to receive and send some data from a computer to an ATtiny through USB. Can an ATtiny85 IC communicate with a computer through USB? If yes, how should it be connected?


texts: Problem with deploying matlab simulink mode to Arduino UNO

texts:
I encounter a problem when deploy matlab simulink model to Arduino UNO

Following shows the error

*The call to realtime_make_rtw_hook, during the after_make hook generated  the following error:
The build failed with the following message: The system cannot find the path specified
The build process will terminate as a result.
The build failed with the following message: The system cannot find the path specified。
Component: Simulink | Category: Block error*

When type >> getenv('path')

ans =

C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;E:\MathWorks\runtime\win64;E:\MathWorks\bin;E:\MathWorks\polyspace\bin;C:\Program Files\MATLAB\R2014b\runtime\win64;C:\Program Files\MATLAB\R2014b\bin;C:\Program Files\MATLAB\R2014b\polyspace\bin;C:\Program Files\Microsoft Windows Performance Toolkit\

I did not see anything wrong with the path. I tried to solve the problem following the "http://www.mathworks.com/matlabcentral/answers/168555-what-does-the-path-in-the-system-cannot-find-the-path-specified-refer-to". However it does not work.

Anyone know how to solve it?

OS:Win8.1 Matlab 2014b 64bit


texts: Specific formatting of floats and converting them to an array of chars

texts:
I have an oled display which can only display 4 digits + decimal point.
I need a way to format the number into 4 significant figures;
Then I need to convert that into an array of 5 chars (4 digits and one dp) before I can display them.

Not sure how to format to correct number of digits or how to convert into a char array. I searched a bit and printf seems to be the solution(?) but I've had no luck with it so far as it spits out all sorts of errors. if you know how to make it work, please can you provide a code snippet which compiles without errors? thanks.


texts: Is there alternative to arduino IDE program ESP8266 and ESP32 with arduino toolchain?

texts:
I use ESP8266 and ESP32 with arduino toolchain rather than pure arduino hardware.
Arduino IDE is standard and proven but what are the other IDE and advantage/disadvantage ?


texts: How to get full response json SIM900 + Arduino?

texts:
void toSerial(int delay_ms)
  {
    delay(delay_ms);

    while(mySerial.available())
    {
       Serial.write(mySerial.read());
    }
  }

  Serial.begin(9600);
  mySerial.begin(9600);

  mySerial.println("AT+HTTPINIT");
  toSerial(500);

  mySerial.println("AT+HTTPPARA=\"CID\", 1");
  toSerial(500);

  mySerial.println("AT+HTTPPARA=\"URL\", \"www.example.test\"");
  toSerial(500);

  mySerial.println("AT+HTTPPARA=\"CONTENT\", \"application/json\"");
  toSerial(500);

  mySerial.println("AT+HTTPACTION=0");
  toSerial(4000);

  mySerial.println("AT+HTTPREAD");
  delay(3000);

  while(mySerial.available())
  {
    Serial.write(mySerial.read());
  }

  Serial.println("");
  mySerial.println("AT+HTTPTERM");
  toSerial(500);

Result:

AT+HTTPREAD

+HTTPREAD:39
{"pinRed":0,"pinGreen":1,"pinYello

I expect messages:

{"pinRed":0,"pinGreen":1,"pinYellow":0}


texts: How do I make the HC-05 bluetooth module take data from the HC-SRO4, and then send it to my Android app?

texts:
Currently, I have an Arduino Uno set up, with a HC-SRO4 ultrasonic sensor printing distances of objects in front of it on a scale from 1-15 to the serial monitor. I want to attach the HC-05 bluetooth module and do the following:
First, it will read the values from the serial monitor. Then, I would like the HC-05 module to take these numbers and continuously send it to my Android app, which will then process what to do with the numbers.

I understand the Android part may be out of scope of this forum, but please try to help me with taking data from the serial monitor and have it transmit the data.

Here is the code I have for the ultrasonic sensor:

const int trigPin = 9;
const int echoPin = 10;
// defines variables
long duration;
int distance;
void setup() {
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input
  Serial.begin(9600); // Starts the serial communication
}
void loop() {
  // Clears the trigPin
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  // Calculating the distance
  distance = duration * 0.034 / 2;
  // Prints the distance on the Serial Monitor
  Serial.print("Distance: ");
  Serial.println(distance);
}


texts: Control a 5 volt water pump with an Arduino

texts:
I want to control (only on/off) a small water pump (5 V, 200 mA max.) with my Arduino.

I read something about NPN transistor, because the output pins of the Arduino can't supply enough current to the pump. However, I don't know how to choose the right transistor and how to connect it with my Arduino and my water pump.


texts: How to switch program in arduino using android app?

texts:
I have 2 programs made for my arduino.The first one is for solving a maze automatically and the second one is for controlling the robot with a android app.I wanted to control the robot with the app I made as soon as it has finished solving the maze.
                   Is it possible to upload both the program in the arduino and run it one at a time?If so can you tell me how?


texts: Arduno Uno voltage in via VIN pin or DC power?

texts:
I have an Arduino UNO. It has VoltageIN on a pin. Is there any difference between powering my UNO through VIN or powering it through the DC port?

The docs only say this,

  5V.This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don't advise it.

So it seems to imply VIN/USB/DC in all go through the voltage regulator? Is there any difference then?

Is there any advantage to running a variable power supply through an adapter like this:

Or should I just go through VIN?


texts: Recently I stumbled myself on a fairly old blood sugar test strips canisters. Inside them, I found this what they called "Code Card" which inside, an EEPROM Microchip 93LC46B a 1K Microwire compatible serial EEPROM. I want to salvage them for my Arduino project. Is possible to read/write data to them? and how to determine the capacity? I only see 16 bit word size on the datasheet and 1K on the title.


texts:
I have just bought the CC3000, and it looks great.
However, I want to use my new WiFi connectivity with Teleduino service, but the Teleduino examples and code only support Ethernet connection.
I have been trying for a while to patch a combination of the two but it is more complicated than I thought.

Does anyone knows how to use Teleduino with the CC3000 WiFi module?

Thanks


texts: Can I connect esp32 to a phone USB charger?

texts:
I have a USB charger. Is it ok to connect it as a power supply for esp32?

Edit: i have a dev board esp32


texts: Arduino mega reads ps/2 keyboard in C without arduino library

texts:
I want to read the input of an ps/2 keyboard. I connect the keyboard by a connector to arduino mega 2560. Clk to pin 2 and data to 30. Now my question how can i program in C that when I click any key get the data and safe them. The major issue is that I haven't any clue how to get the data and store in a array without using the PS2keyboard.h library. With this it is easy i do this before :
setup(){
keyboard(data, iqrPin);
if keyboard.available()){
  char in = keyboard.read();
}
}

Something like this works perfectly but how can I do this without all the keyboard library stuff. So in clear C without arduino library's?


texts: How to compile a sketch using arduino-builder?

texts:
How do you compile a sketch with a custom library path using arduino-builder? The docs are a little light.

I have my source code organized like this:

lib
    SomeLib
        somelib.h
        somelib.cpp
src
    otherfile.h
    main.ino

I've installed Arduino 1.8.1 into /usr/share/arduino.

I'm trying to compile this for an Arduino Uno from my project root directory with:

arduino-builder -compile -hardware /usr/share/arduino/hardware -tools /usr/share/arduino/hardware/tools -libraries lib -fqbn arduino:avr:uno -build-path .build src/main.ino

But it returns this error:

fork/exec {runtime.tools.ctags.path}/ctags: no such file or directory

What's causing this error?


texts:
i've got a seven-segment-display on my arduino-nano and want to write some numbers on it. The problem is that HIGH and LOW seems to be reversed.
If the output should be

0

it displays

-

I could solve this, replacing all HIGH and LOW through HIGHX and LOWX, and defining them reversed:

 #define HIGHX 0x0
 #define LOWX 0x1

but this is reversed and not a good solution...

The wiring is correct like this (just GND not connected):

But if i connect the GND, the hole display isn't showing something anymore.


texts: How can i use a TFT Screen shield along with other sensors and transmitters

texts:
I want to use Arduino as described in this instructable:

http://www.instructables.com/id/Uber-Home-Automation-w-Arduino-Pi/

But i thought i would give it a little twist by adding a TFT monitor to some devices. I have bought and got the following tft shield to work:
http://www.banggood.com/UNO-R3-ATmega328P-Board-2_4-Inch-TFT-LCD-Screen-Module-For-Arduino-p-945755.html

But now it strikes me:
How can i combine the screen on an arduino where i also have a sensor and a radio transmitter?


texts:
i use this simple code for arduino :

const int buttonPin = 2;
const int ledPin =  13;

int buttonState = 0;

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

void loop() {
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH) {
    digitalWrite(ledPin, HIGH);
    Serial.println ( buttonState ) ;
  } else {
    digitalWrite(ledPin, LOW);
    Serial.println ( buttonState ) ;
  }
}

it's so basic program, I've seen some people work with Resistors when they use buttons, so i wanted to know why, i plugged in one side of the button to the pin 2 , no matter if i plugged in the other side of the button or no to the 5 volte source, the arduino started giving me some ones and zeroes therefore the blinking of the led, so basically that means there's a certain voltage comming from the button to the pin 2, I wonder why and what's the reason for this ?


texts:
How can I use bitRead() to toggle between 3 LEDs?
I have 3 LEDs - red, green, blue - and I have these 4 stages:

Red ON and green, blue OFF
Green ON and red, blue OFF
Blue ON and red, green OFF
All OFF

and repeat.


texts: Arduino Nano with Arduin Nano Ethernet shield ENC28J60

texts:
I have connected the Arduino Nano with the Arduino Nano ENC28J60, and then I connect the Ethernet cable with the laptop and also the Arduino nano with my laptop to load the code and it works just fine.

I was wondering if I want to disconnect the Arduino Nano with the laptop and run the same code then, how should I put the external power supply on ENC28J60 and what should be, and in general, what should be the right wiring?


texts: Sending Serial Hex Command from Pin 1 (Tx)

texts:
Using Arduino Uno with 3.5mm Jack connected to ground and pin 1 for TX

Need to send two commands
I want to send
0XAA13FE010113 for Mute on, and
0XAA13FE010012 for Mute off.

Simple Serial Command to turn Monitor Mute on and off every 5 seconds....

tried everything byte character, array, write with hex, print :(

Thx for a helping a rookie
I want to impress my team

Ideal quick answer below. thx to @martynas

uint8_t muteON[] = { 0xAA, 0x13, 0xFE, 0x01, 0x01, 0x13 };
uint8_t muteOFF[] = { 0xAA, 0x13, 0xFE, 0x01, 0x00, 0x12 };
....
void loop() {
 Serial.write( muteON, sizeof(muteON) );
 delay(5000);               // wait for 5 second
 Serial.write( muteOFF, sizeof(muteOFF) );
 delay(5000);               // wait for 5 second
}


texts: What are the environmental requirements of an Arduino?

texts: I'd like to use an Arduino Yún in a somewhat outdoor environment (in a metal box on a truck).  I think I've seen that the temperature requirements of the Uno are -40 °C to +85 °C, but I can't find that information about the Yún.  It would be nice to know where to find information about the temperature and humidity safe working requirements for every Arduino model.


texts:
I am making a temperature circuit with arduino.
is there any way to plot the value of the temperature in a graph using arduino?
thank you very much in advance


texts:
I'm doing an Arduino-based project in which I want this feature:
Whenever I cut the power or turn off the Arduino it should reset every pin, meaning that if I have a servo motor, and in some part of the code the Arduino turns off the servo motor, it should return to its base state, which is write(0).
Is this possible with code or physically adding something to the circuit or is it not possible?
Please help


texts: Use potentiometer to control motor's speed

texts:
Following the arduino starter kit, one of the projects uses a push button to on/off a motor.

In the end they suggest to try to use a potentiometer to control the speed of the motor.
I already did it, but I am not sure how I should use the capacitors(I placed one with the pot).

In one of the previous examples they used 2 100uF capacitors(one for the pot. and another for a servo motor) and I was wondering if this would be the same case.

This is my circuit:

The code:

const int POT_PIN = A0;
const int MOTOR_PIN = 9;
int motorSpeed = 0;
int potVal = 0;

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

void loop()
{
  potVal = analogRead(POT_PIN);

  motorSpeed = map(potVal, 0, 1023, 0, 255);

  analogWrite(MOTOR_PIN, motorSpeed);
}

Previous example with capacitors:

Code:

#include <Servo.h>

Servo myServo;

int const POT_PIN = A0;
int potVal;
int angle;

int alpha = 0.8;
int rawReading;

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

  Serial.begin(9600);
}

void loop()
{
  rawReading = analogRead(POT_PIN);
  potVal = alpha*potVal + (1-alpha)*rawReading;
  Serial.print("potVal: ");
  Serial.print(potVal);

  angle = map(potVal, 0, 1023, 0, 179);
  Serial.print(", angle: ");
  Serial.println(angle);

  myServo.write(angle);
  delay(15);
}


texts: Is there any reason not to solder power leads to the lugs for the power in socket on the reverse side of a mega 2560 rev 3 board?

texts: I have a very tight space for a project that requires a mega board , the "power in" plug takes it over the space available. Are there safety or other concerns soldering to the lugs for the "power in" socket on the reverse of a mega 2560 rev 3 board board? the board is fitted with an elctrofreaks TFT LCD MEGA SHIELD v2.2 and a TFT_320QVT LCD screen. (the elctrofreaks mega shield uses vin pin)  1 other PWM  pin is used  and an esP8266 board on a uart channel The power  is from a regulated power supply. If  I do this, am I correct that the regulator and polyfuse will still be used?


texts:
I have written a library for Arduino, my_library, consisting of my_library.h and my_library.cpp, both included in my_library folder. Actually the library is recognized from IDE Arduino and works fine.

I want to add some examples, let's say Example1 and Example2. How is that possible?

Should the examples be included in my_library folder?

or should be included in another folder inside my_library folder?

I tried several combinations but none worked. Do I miss something?


texts: How to connect MPU6050 with Arduino Uno without using A0-A5 pins?

texts: Connecting MPU6050 with Arduino without using A0-A5 pins.


texts: Trouble in acquiring NEO6M GPS data through S-Function builder at Matlab simulink using Arduino libraries

texts:
I have connected a NEO6M GPS module to an Arduino Mega 2560 and programmed using TinyGPS++ library's "Device Example". I am getting proper data at serial port.

NEO6MGPS to ArduinoMega2560
Vcc           3.3volts
GND           GND
TX            Pin10
RX            Pin9

I have created S-function for NEO6M-GPS for ArduinoMega2560 at Matlab to output latitude longitude alone from TinyGPS++ "Device Example" code with following:

Initilization:

No of discrete states:1
Sample mode: Discrete
Sample time value: 0.1

Data Properties:

Two "Output ports" are defined latitude & longitude of data type int32

Libraries:

#ifndef MATLAB_MEX_FILE
#define ARDUINO 100
#include <Arduino.h>
#include "TinyGPS++.h"
#include "TinyGPS++.cpp"
#include "SoftwareSerial.h"
#include "SoftwareSerial.cpp"
TinyGPSPlus gps;
SoftwareSerial ss(10, 9);
#endif

Outputs:

    if(xD[0] == 1)
    {
      #ifndef MATLAB_MEX_FILE
      while (ss.available() > 0)
      gps.encode(ss.read());
      if (gps.location.isValid())
      {
        latitude[0]=gps.location.lat();
        longitude[1]=gps.location.lng();
      }
      else
      {
        Serial.print("0");
      }
      #endif
    }

Discrete Update:

    if(xD[0]!=1)
    {
      # ifndef MATLAB_MEX_FILE
      Serial.begin(115200);
      ss.begin(9600);
      # endif
      xD[0]=1;
    }

Note: I am successful in building the s function and changing the wrapper name to .cpp and editing with addition of extern "C" at appropriate lines. And able to deploy on target hardware.

"### Done invoking postbuild tool."  "### Successfully generated all
binary outputs." AVR Memory Usage
---------------- Device: atmega2560 Program:   11082 bytes (4.2% Full) (.text + .data + .bootloader) Data:       1066 bytes (13.0% Full)
(.data + .bss + .noinit)

During live simulation run I don't observe any output in the scope/display.

My question is do I have any logical errors in writing code at "output" part of s-function or misplacing the code at other fields of s-function ?

I am okay to change my library, all I need is latitude and longitude displayed at simulink. Please do suggest necessary changes to be made.


texts: My push button code doesn't work properly

texts:
I'm using an OLED display connected to a push button.  I am trying to get my display to show two different values independently  by using the push button to switch between them. Here is a snap of my code from the loop function:

    if (buttonState == HIGH) {
    x=x+1;
  }
  if (x == 1) {
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  display.setTextSize(2);
  display.print(T);
  display.print(" degree");
  display.display();
  display.print(x);

}
    else if (x == 2) {
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  display.setTextSize(2);
  display.print(perventage);
  display.print(" %");
  display.display();
  display.print(x);
}
    else  {
      x=1;
      }

  delay(10);
}

x is defined as 1 initially out side the loop.
What happens is that when the circuit is turned on, the screen displays the value of T then what should happen is when I push the button it switches to the second value which is percentage, and I push again to go back to T. My issue is that the Arduino doesn't response to the push button all of the time sometimes it takes 1 click and other times it takes 6 or 8 fast clicks to switch between them and it doesn't stick to a specific number of pushes to switch.
What would you suggest me to change to fix it.

Edit: here is pic of my wiring diagram


texts: Gas Sensor output voltage to concentration

texts: I am using figaro tgs gas sensor (2600, 2602 and 2620) to sense breath from human. What I obtained is the output voltage. However, I would like to convert the voltage to concentration in ppm? Since these gas sensors can sense more than one gas. Is there any way?? Thanks.


texts:
I'm doing a program that receives data from a web page every so often, but only receives the data once and then receives everything blank. I need help to receive the data every time indefinitely. I am using arduino uno with arduino etherner shield

My code:

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

IPAddress ip(192, 168, 0, 177);
EthernetClient client;

int REDLed= 2;
int GREENLed= 3;
int BLUELed= 4;

void setup()
{
  pinMode(REDLed, OUTPUT);
  pinMode(GREENLed, OUTPUT);
  pinMode(GREENLed, OUTPUT);
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
  Serial.println("power up" );
  delay(3000);
}

void loop()
{
  Serial.println("SubmitHttpRequest - started" );
  SubmitHttpRequest();
  Serial.println("SubmitHttpRequest - finished" );
  delay(10000);
}

void SubmitHttpRequest()
{
  if (client.connect(server, 80))
  {
    Serial.println("connected");
    client.println("GET /arduino/getstate.php?color=All HTTP/1.1");
    client.println("Host: cybertodo.mx");
    client.println("Connection: close");
    client.println();
  }
  else
  {
    Serial.println("connection failed");
  }
  delay(100);
  changeLed();
}

void changeLed()
{
  String content = "";
  Serial.println(client.available());
  while(client.available()!=0)
  {
    content = content + String(char (client.read()));
  }
  Serial.println(content);
  if(content.substring(30,31)== "1")
  {
    digitalWrite(REDLed, HIGH);
  }
  else if (content.substring(30,31)== "0")
  {
    digitalWrite(REDLed, LOW);
  }

  if(content.substring(31,32)== "1")
  {
    digitalWrite(GREENLed, HIGH);
  }
  else if (content.substring(31,32)== "0")
  {
    digitalWrite(GREENLed, LOW);
  }

  if(content.substring(32,33)== "1")
  {
    digitalWrite(BLUELed, HIGH);
  }
  else if (content.substring(32,33)== "0")
  {
    digitalWrite(BLUELed, LOW);
  }
  content = "";
}


texts: Serial.println using too much memory (not Strings)

texts:
I want to feed thousands of analog vibration sensor readings into an array as fast as possible, and then analyze them. Here is my sketch:

const int pSensor1 = A0;
const int aSize=10000;

int a[aSize];

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

void loop()
{
  for (int i = 0; i < aSize; i++) a[i] = analogRead(pSensor1);

  int RMS = 0;
  for (int i = 0; i < aSize; i++) RMS += pow(a[i], 2);
  RMS = sqrt(RMS/aSize);

  Serial.println("Hello");
}

This compiles and runs fine. My problem arises when I try to change the last line to:

Serial.println(RMS);

I get the error:

  Arduino: 1.8.12 (Windows 10), Board: "Arduino Nano, ATmega328P"

  Sketch uses 3270 bytes (10%) of program storage space. Maximum is
  30720 bytes. Global variables use 20188 bytes (985%) of dynamic
  memory, leaving -18140 bytes for local variables. Maximum is 2048
  bytes. data section exceeds available space in board Not enough
  memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for
  tips on reducing your footprint. Error compiling for board Arduino
  Nano.

Why does attempting to Serial print a single floating point variable use 985% of dynamic memory?


texts: Is it possible to create an electromagnetic wave using PWM?

texts: What would be the simplest way of making an Arduino emit EM waves using PWM (or without)? Theoretically, oscillating a current through a wire would result in an electromagnetic wave, but I don't know if this is possible using an Arduino and if so, how?


texts: I need to restart Arduino IDE after each compilations

texts:
I'm using the Arduino Due and testing an I2C Scanner, the I2C Scanner works correctly but each time I want to upload a newer version of the code I get this error message :

No device found on COM11
Send auto-baud
Set binary mode

What I need to do in this case is : remove USB, restart the Arduino IDE, reconnect USB, then it works again, one time...

It seems related to this problem : Serial port on mac only works after restarting arduino IDE

I'm not sure but What's maybe also symptomatic is I need to systematically push the restart Button of my board in order to receive something in the Serial Monitor, could it be related ?

Here is the I2C Scanner code I'm using :

// --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// Version 6, November 27, 2015.
//    Added waiting for the Leonardo serial communication.
//
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#include <Wire.h>

void setup()
{
  Wire.begin();

  Serial.begin(9600);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}

void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknown error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(1000);           // wait 5 seconds for next scan
}


texts: Reading a simple sensor with Modbus RTU on Arduino Uno

texts:
I'm integrating a wind direction- and speed sensor with an Arduino. It communicates over RS485 Modbus RTU, which I don't have any experience with.

The documentation is very short, and it just says:

9600bps, 8 bit, stop bit: 1, check bit: no
Slave address is FFH.

Host Scan Order( slave address 0xFF)
FF 03 00 00 00 02 D1D5

Slave Response
FF 03 04 00 09 00 3A 0401

The bold parts are fixed, the last two bytes are for checksum.  So the data of the response is direction in the two first bytes (00 09), and then speed in the two after that.

So basically I gotta send that exact byte sequence to the sensor, and then decode what I get. I'm not gonna need to do anything more advanced with this, and so I'm trying to figure out what the most easy way to do this is.

There are different modes, like single, mutliple registry, discrete values, coils, I don't know which one I'm supposed to pick, would be grateful if someone could take the time to explain to me how to do it.


texts: The Mysterious Case of the Mostly-Vegetable Servo

texts:
Story:

I was playing around with my Uno along with a servo.

To my stupidity (or more appropriately: ignorance), I set the voltage to my servo with analogWrite(), rather than servo.write(). It worked for a bit; but once it reached it's limit, it kept trying to move, to no avail.

Realizing what I had done, I pull the power source from my Uno.

Then, I went to change the code, and tested my servo once more.

The servo's casing is transparent (there is a sticker blocking the motor and circuit; but I can see 4 of the gears).

The bottom 2 gears are ticking ever so slightly (and the top 2 even less so), resulting in the propeller to move at most 5 degrees. At this threshold, none of the mentioned gears are ticking, but something is heard (probably a whirring gear not in sight).

At this point, I would've come to the conclusion that a tooth of the third gear had broken.

However, after I pull the power plug and put it back in, it spins (backwards) into it's initial position and begins the process mentioned above again.

Mystery:

Is my servo indeed broken?

What's not functioning correctly?

Can it easily be repaired?


texts:
I have a Nextion 7 inch enhance type display.
I have enabled sleep using thsp = 120 and thup = 1 line of code. Now display become sleep mode after 2min, if there is no any touch event.

But, this sleeping is completely turn off the display.

I have several pages and I want to reset to a specific page, if there is no any touch event in any page instead of sleep function.

Greatly appreciate if someone can give a solution for this.


texts:
I'm looking for a simple way to send a signal from my arduino to a vga monitor.

What would be the easiest method, and what components would be needed?

I don't need to display an image, just a solid colour.


texts:
I have a linear actuator that I want to be able to slow down. Right now, the shaft moves too quickly. I'm not sure how to do this. I was looking into varSpeedServo.h library but couldn't implement it.

//Includes
#include <Servo.h>

//Defines
#define LINEARACTUATORPIN 9        //Linear Actuator Digital Pin

const int button1Pin = 4;     // the number of the pushbutton pin

// variables will change:
int button1State = 0;         // variable for reading the pushbutton status

Servo LINEARACTUATOR;  // create servo objects to control the linear actuator

int linearValue = 10000;   //current positional value being sent to the linear actuator.

void setup()
{
  //initialize servo/linear actuator objects
  LINEARACTUATOR.attach(LINEARACTUATORPIN, 1050, 2000);      // attaches/activates the linear actuator as a servo object

  // initialize the pushbutton pin as an input:
  pinMode(button1Pin, INPUT);

  //use the writeMicroseconds to set the linear actuators to their default positions
  LINEARACTUATOR.writeMicroseconds(linearValue);

}

void loop()
{

  // if the pushbutton is pressed set the linear value
  button1State = digitalRead(button1Pin);
  if (button1State == HIGH) {
    // set the position value
    delay(2000);
    linearValue = 1050;

  }

    if (button1State == LOW) {
    // set the position value
    linearValue = 2000;
  }

  //use the writeMicroseconds to set the actuator to the new position
  LINEARACTUATOR.writeMicroseconds(linearValue);
delay(3000);
}


texts: Writing C Program outside of Arduino IDE?

texts:
I like the idea of using the Arduino IDE for simple projects and for getting started with Arduino, but the consensus I've gotten so far is that it is for those who are new to Arduino and/or programming in general.

My understanding is that it is possible to write a C program from scratch, completely outside of the Arduino IDE, and then use a tool like AVRDUDE to upload it to an Arduino MCU. This option, albeit appealing and interesting, leaves me with a few concerns:

What Arduino libraries would need to be imported/linked by such a "raw C" program? I assume that when an Arduino IDE-based program executes a digitalWrite(...) it is really calling a C lib, probably provided by Arduino, under the hood. I am concerned about making sure all these "underlying libs" get included with my C program. Thoughts?
Is anything else "lost" by flying solo and venturing outside the Arduino IDE? Any capabilities/features that I would now have to "roll my own"?


texts: Arduino Keyboard starts lower case (but it shouldn't)

texts:
So I flashed the KeyboardMessage example to my Arduino SS Micro ATmega32U4.
When I open an editor and push the button, I would assume the output to be

Zou pressed the button XX times.

(The "Z" is because I use a German keyboard)
In some editors (Arduino IDE, LibreOffice) this assumption is fulfilled.
However, in several other editors (Linux Shell, gedit), most of the times the output is

zou pressed the button 1 times.

starting with a lower case "z".
I use a Debian Testing computer. The only thing I changed in the sketch was the buttonPin as my button is soldered to pin 11.
I noticed, that this problem doesn't occur when the button is pressed a second time shortly after the first message. To investigate this, I coded a little sketch to find the threshold.
This is what I got (in gedit)

As line 8 shows, even after 70 millis, the upper case start is not reliable, however, somewhere after 250 millis, the error occurs every time.
My questions are:

What could be the cause for this issue?
How can it be fixed (if necessary, I also welcome a workaround)?

Please tell me if you need any additional information.
[edit]
After slightly altering the script, I noticed, that the problem doesn't only occur on the start of a line, but also (although less often) later in the output. See lines 24, 31 and 52 for example


texts: How to light up digits at the same time?

texts:
I'm measuring inclination with MPU6050, then transmitting data from the accelerometer to second Arduino, where I want to display the number on a 4 digit 7 segment display. I'm using one shift register 74HC595 with the display. The display is showing probably the right numbers, but only one digit is on at a time. What I mean is that the fourth digit lights up, then stops and lights up third digit, then stops and so on.
Here is the code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8);
const byte addresses[][6] = {"00001", "00002"};

float angley;

const int digitPins[4] = {
  A1,A2,A3,A4};                 //4 common anode pins of the display

const int clockPin = 10;    //74HC595 Pin 11
const int latchPin = 9;    //74HC595 Pin 12
const int dataPin = 6;     //74HC595 Pin 14

const byte digit[10] =      //seven segment digits in bits
{
  B00111111, //0
  B00000110, //1
  B01011011, //2
  B01001111, //3
  B01100100, //4
  B01101101, //5
  B01111101, //6
  B00000111, //7
  B01111111, //8
  B01101111  //9
};
int digitBuffer[4] = {
  0};
int digitScan = 0, flag=0,  soft_scaler = 0;
;

void setup(){
  Serial.begin(115200);
  radio.begin();
  radio.openWritingPipe(addresses[1]);
  radio.openReadingPipe(1, addresses[0]);
  radio.setPALevel(RF24_PA_LOW);

  for(int i=0;i<4;i++)
  {
    pinMode(digitPins[i],OUTPUT);
  }

  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);

}

//writes the temperature on display
void updateDisp(){
  for(byte j=0; j<4; j++)
    digitalWrite(digitPins[j], LOW);

  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, B11111111);
  digitalWrite(latchPin, HIGH);

  delayMicroseconds(100);
  digitalWrite(digitPins[digitScan], HIGH);

  digitalWrite(latchPin, LOW);
  if(digitScan==2)
    shiftOut(dataPin, clockPin, MSBFIRST, ~(digit[digitBuffer[digitScan]] | B10000000)); //print the decimal point on the 3rd digit
  else
    shiftOut(dataPin, clockPin, MSBFIRST, ~digit[digitBuffer[digitScan]]);

  digitalWrite(latchPin, HIGH);
  digitScan++;
  if(digitScan>3) digitScan=0;
}

void loop(){

  radio.startListening();
  if (radio.available()) {
    radio.read(&angley, sizeof(angley));
    delay(100 * sizeof(angley));
  angley = int(angley*100);
  Serial.println(angley);
  digitBuffer[3] = int(angley)/1000;
  digitBuffer[2] = (int(angley)%1000)/100;
  digitBuffer[1] = (int(angley)%100)/10;
  digitBuffer[0] = (int(angley)%100)%10;
  updateDisp();
  delay(2);
  }
}

What could be the problem?


texts:
I worked on the starterkit project #9 motorized pinwheel, and the motor worked just fine.

I then tried to add a potentiometer, and now the motor won't rotate at all any more (neither in the current nor in the project's baseline configuration). I also tried connecting the motor to the 9V battery directly, to no avail.

I did check the battery by briefly connecting a LED right away. The motor apparently also still generates current if I turn it manually (checked with a directly connected LED either).

What else can I do to check what's wrong with the motor? Is it possible that I somehow accidently killed it with my attempts with the potentiometer?


texts:
I want to create a structure called CarSpeed it has 4 int FR,FL,BR,BL (FrontRight,..) ; and i would like to create a function that returns this structure :

ActualSpeed Readspeed(void)
{
   code to read the speed of the car(already done)
}

Can someone help me define a function that returns this structure  ? only the way how I should define it, the usual C way doesnt work :

typedefstruct CarSpeed{...}

and then

CarSpeed ActualSpeed;
ActualSpeed Readspeed(void){.. }


texts: Upload sketch remotely through a serial-IP-serial connection

texts: I tried different times to use socat and ser2net in order to upload a sketch to an Arduino Uno (connected to a PC) from my laptop, unsuccessfully. Can anyone teach me how to achieve this goal? I use Linux.


texts:
So I am learning arduino code by going through examples and playing with them, and I came across something interesting. I am not fluent in any coding language but I am fully familiarized with computer logic and function so I can read what you suggest just fine.

What I want to know is, why are these two code pieces different?

const int ledPin =  13;

int ledState = LOW;

long interval = 1000;

void setup() {

pinMode(ledPin, OUTPUT);
}

void loop()
{

  unsigned long currentMillis = millis();

  if(currentMillis > interval) {

    currentMillis = 0;

    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;

    digitalWrite(ledPin, ledState);
  }
}

This is my code, or rather modification to this code:

const int ledPin =  13;

int ledState = LOW;
long previousMillis = 0;

long interval = 1000;

void setup() {

  pinMode(ledPin, OUTPUT);
}

void loop()
{

  unsigned long currentMillis = millis();

  if(currentMillis - previousMillis > interval) {

    previousMillis = currentMillis;

    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;

    digitalWrite(ledPin, ledState);
  }

}

How is it that the first code works, and the second code turns the led on and either terminates or never turns the LED off? The code is designed to blink the LED once every 1 second.


texts: What is the purpose of it and on what bases its value is calcuated in ohms ?


texts: Does int array[100] = {0} contruct work on Arduino?

texts:
I'm compiling my code in Arduino IDE. I have an array that I want to 0-initialize. I know memset works on Arduino, but I'm used to this way from my desktop C++ programming practice:

int array[100] = {0};

I couldn't find any info on whether or not this construct works on Arduino. I think it should since it uses GCC compiler. Even though it may be modified, I still expect it to remain C and C++-compliant. Still, can you confirm for me that this standard-compliant C/C++ construct works on Arduino?


texts: Unable to load programs onto Arduino Pro Mini Using FTDI?

texts:
I'm pretty new to this, so forgive me if I get some things wrong. I am working with a piece of equipment that uses an Arduino Pro Mini. When I first got to it, I realized that some of the code was incorrect and wanted to fix it. Unfortunately, my Pro Mini is soldered into the board with the labels and pins down, so the only accessible pins are the top six, and even those aren't labeled. The reset button is also upside down. I tried using a FT232H FTDI
hooked up (using a pinout because of the aforementioned no labels)

D0-> TX

D1-> RX

which I was told should work, but when I plug in the micro-usb into the FT232H and try to upload the sketch, it gives me the error

avrdude: stk500_getsync(): not in sync: resp=0x00

and also blinks green but has a constant red light (from what I can see from looking under the board). Because this Pro Mini controls my equipment, I'm wary of doing anything too intense. Any ideas of how to fix this without breaking my apparatus?

Update!
I changed the pinning, and the IDE told me that it uploaded, but it still won't run the program! Help!


texts: Arduino Due: Measuring the time between pulses

texts:
I have a 'pulse train' generated from a photo interrupter and slotted disc mounted on a rotating shaft. My goal is to measure the time between each rising edge.

I have looked at the data sheet for the SAM3X8E and figured out that I need to configure a timer in 'capture mode' to do this.

My problem is that I am new to Arduino Due / this level of programming so I do not know how to set-up all the prerequisites before this (PIO, PMC, SYSCLK? etc.)

I have spent an extensive period trying to find help/ example code to no avail. Anything I do find is on Arduino Uno or Mega and therefore is of little help because of the different architecture.

Can anyone help or has anyone else done this/ similar problem?

(I am using Atmel Studio 7 as it seems to be the go-to for advanced SAM3X8E programming)

Thanks


texts:
when I go to upload the code, I get

 Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\taran\Documents\Arduino\dice in progress\dice in progress1\diceinprogress\diceinprogress.ino:1:25: fatal error: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.10.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/"DFRkeypad.h": Invalid argument
#include <"DFRkeypad.h">
                     ^
compilation terminated.
exit status 1 Error compiling for board Arduino/Genuino Uno.

and the code is

#include <"DFRkeypad.h">
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
const char* DFRkeypad::sKEY[]=                          { "---",       "Right",   "Up", "Down", "Left", "Select", "???" };
const int DFRkeypad::iARV_VALUES[DFRkeypad::eNUM_KEYS]= { 1023,        0,         143,  328,    504,     740,      -1   };
int btnSELECT;

void setup() {
  lcd.begin(16, 2);
  lcd.setCursor(1, 0);
  lcd.print("Roll the dice!");
}

void loop() {
while (btnSELECT == 0){

  delay (50);
  buttonState = analogRead(btnSELECT);
}

 case btnSELECT:
     {
     lcd.print("Rolling dice");
       diceOne = random(1, 7);
       diceTwo = random(1, 7);
     break;
    }
}


texts:
So I got this air quality sensor running, and it's outputting some numbers.
I've read some tutorial online and it looks like the smaller the number the better the air quality.
But I don't understand what is the meaning of those number. Like what is the unit of measurement? For example, the temperature sensor gives you numbers in Celcius degree.

http://wiki.seeed.cc/Grove-Air_Quality_Sensor_v1.3/


texts: Arduino Yun Serial Terminal Overflow Issues?

texts:
EDIT: after reading up on some stuff and with the help of the comments people left, I'm certain that it's an overflow issue, but I'm not sure how to solve that...

So I just got an Arduino Yun today and have been figuring out how to use it.  I seem to have run into a problem though and haven't been able to solve it...

I stripped down the YunSerialTerminal sketch that allows accessing the yun linux terminal over a usb com port:

void setup() {
  Serial.begin(9600);      // open serial connection via USB-Serial
  Serial1.begin(250000);   // open serial connection to Linux
}

void loop() {
  if (Serial.available()) {             // got anything from USB-Serial?
    int c = Serial.read();              // read from USB-serial
    Serial1.write(c);                   // write to Linux
  }
  if (Serial1.available()) {            // got anything from Linux?
    int c = Serial1.read();             // read from Linux
    Serial.write(c);                    // write to USB-serial
  }
}

It works for the most part, but has some odd differences from connecting via ssh over wifi.

It seems to be dropping random characters from the screen (due to buffer overflow):

As you can see, it's messed up some of the text such as md5um which should be md5sum and the formatting is all off.

It gets even worse when launching elinks terminal web browser (which works beautifully when connecting via ssh over wifi):

I've also tried different programs (other than putty), including the arduino ide serial monitor, and they all produce the exact same result (and yes I'm setting them to the correct port speed as well).

Does anyone have any idea what I'm doing wrong?  I've tried many different port speed combinations and they all produce the same result.  It seems that the atheros-atmel link is set to 250000 baud (Which is why I have to use that speed on Serial1 in my sketch), but can that be changed?  I've read some things about how 250000 is way too fast when the atmel is involved, but is there a way to change that speed without losing the Bridge library functionality?

Also, could someone else with a yun try this sketch and verify that it works? Load it, and connect with putty via serial (using whatever com port arduino bound to) and double tap tab key to see if the command listing is missing letters.


texts: A question about the possible limits of an Arduino Uno

texts:
I've searched the web but could not find a straightforward answer to my query.

I am building a control board for one of my models and this time have decided to also include a computer interface, so I have incorporated an Arduino Uno into my project instead of just analog circuits. I'm not an electronics expert of any sort but I manage by applying basic logic and a lot of trial and error.

Anyway, I have a single Arduino. It is operating the following:

An LCD display,
a 4 button operation panel I made using an LS148 ic,
an L293 operating 2 small motors,
a servo,
a dark sensor,
a temperature sensor,
and it also does serial communication.

Everything is working great, but slow (or so it appears to me).

If i push a button it takes the board about a second to pick up on the signal while an external LED indicator shows the circuit using the LS148 is working as it should. (I basically chained the 1-4 inputs and checking the truth table on the board to determine which button was pressed). Or pick up on a signal sent from the dark sensor for example. It appears as if the whole code in the Arduino runs at a cycle of once per second. Also sending instructions from the computer.

When I disable the LCD code everything works fast(er) and so goes when I remove other parts. So my question is, have I overloaded it?

I am on the verge of ordering another board (which I am going to do anyway), but in this case it is purely due to my belief that if I connect the LCD with the whole display code onto one board and the rest of the sensors and chips to another it will solve my problem.

I haven't figured out yet if it's possible to link the two boards or how to do that, but once I'll get to that bridge I'll cross it as well.

Thanks for your advice.


texts:
I am using an L298N motor control. I want to use my 2*16 LCD. Can I use the code like this?

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd(12, 9, 4, 5, 6, 7);

// Motor Control
#define enableA  3
#define enableB  11
#define in1 4
#define in2 5
#define in3 6
#define in4 7


texts: I've included  in my sketch and am trying to run a simple sketch that just does EEPROM.write(0,4); followed by a println of EEPROM.read(0);  However, it won't compile.  It keeps telling me there is an error, and that I'm making a "request for member 'write' in something that is not a structure or a union".  I'm using the Mega ADK.  What am I doing wrong?  I've also tried to go to sketch->include libraries and include the EEPROM library directly, still no joy.  This is Arduino 1.6.13 on Windows 8, if it matters.


texts: What's the fastest way to periodically communicate via serial?

texts:
I will be using an Arduino as a bridge between a computer high-level Java client and some low-level hardware computing units (e.g. other Arduinos). I need to find a solution to periodically communicate in both ways. It should be possible to send digital, analog inputs to the PC and receive digital, analog outputs from the PC via serial.

I have very specific requirements for my project to work:

Lowest possible latency in both ways. High latency would cause
instability of controlled systems.
Extremely constant, possibly user-defined update period. Varying
sample rate would cause inaccuracies in the control.

I need a very fast solution possible for update frequency of 100 Hz and higher.

So far I have tried to send data via Firmata to my java client using time interrupt.

ISR(TIMER1_COMPA_vect) {
  Firmata.sendAnalog(analog, analogRead(analog));
}

The messages however don't come at a very constant rate and are sometimes held up for twice the sample period or more which is unnaceptable. For higher frequencies this happens even more often. I suspect some kind of a buffer. Do you have any idea where should I look for bottlenecks? Would it be benefiting to design my own communication protocol and ditch Firmata?

EDIT: Look at the attached diagram . Blue lines are "inputs", green lines "outputs". Right now I am trying to design the "Arduino (Bridge)"


texts:
I have just got a new pair of HC-05 Bluetooth modules. I am working on a simple project. I'm trying to move two servo motors using two potentiometers. I followed a simple tutorial to move one servo, and it worked successfully.

How to make the same thing with 2 potentiometers and two servos?

UPDATE:

I have successfully managed to write down something that get to read values from two potentiometers, but I'am still facing problems with the slave part.
Can't figure out the problem.

(Master)

//Master
int potValuePins[] = { A0, A1 };
void setup() {
  Serial.begin(9600); // Default communication rate of the Bluetooth module
   for (auto pin : potValuePins) {
     pinMode(pin, INPUT);
   }
}

void loop() {
 for (auto pin : potValuePins) {
   Serial.write(pin); // Send the pin number
   Serial.write(analogRead(pin)); // Send the pin value with a trailing
 newline as a delimiter
   int value=analogRead(pin);
   Serial.print(" Pin is: ");
   Serial.print(pin);
   Serial.print("\t");
   Serial.print("Value is: ");
   Serial.println(value);
   }
 }

(Slave)

//Slave
#include <Servo.h>
Servo myServo1;
Servo myServo2;

void setup() {
Serial.begin(9600);
myServo1.attach(9);
myServo2.attach(10);
}

void loop() {
if (Serial.available()) {
 char input[3];
 Serial.readBytes(input, 2);
 int pin = input[0];
 int angle = input[1];
 Serial.print("the pin:");
 Serial.print(pin);
 Serial.print("\t");
 Serial.print("the angle:");
 Serial.println( angle);

 switch (pin) {
  case A0:
    myServo1.write(angle);
    break;
  case A1:
    myServo2.write(angle);
    break;
  default:
    Serial.println("Unknown value");
    break;
   }
  }
 }


texts: Can the Arduino (Nano) bootloader be updated via itself and the Arduino IDE or is an ISP required?

texts:
I ran into the following error with a recent Arduino IDE version (1.8.9) when trying to upload to an "Arduino Nano" clone (ATmega328P):

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x18
...
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x18
Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

The problem could be resolved by choosing "ATmega328P (Old Bootloader)" as Processor in the Tool menu - as now suggested to me and solved in Arduino Nano uploading gives error: avrdude: stk500_recv(): programmer is not responding.

The change was made in August 2018 with the release of Arduino IDE 1.8.6: https://github.com/arduino/Arduino/releases/tag/1.8.6

Details about the different bootloaders are described in
Arduino Nano ATmega328P bootloader difference.

It seems the fuses have to be changed in order to make full use of the newer, smaller bootloader, so an ISP will have to be used anyway.

But is the bootloader able to update itself (via Tools > Burn bootloader) or is there an intermediate "bootloader update sketch" available?


texts: NodeMcu Communication to RS485 Device using TTL to RS485 converter

texts:
Good day everyone,
           I am facing a problem when trying to use nodemcu  (Nodemcu ESP8266 Lolin V3) to communicate with an RS485 device. I sent an enquiry frame to the device and got the response in bytes. However, the response is not meaningful as it cannot be converted to readable ASCII characters.

           I used the built in Serial for this purpose. Hence i debug the program by sending the program flow state and data received to a server as shown in the Web UI below :-

The response that i expect is the ASCII bytes:-

AFC54D48355CC030B14ED8D4B459

which is completely different than what is shown in the Web UI above.

Here is the connection and the code that i have tried so far:-

The code :-

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

int enable_pin = 5; //DE and RE pin is jumped together to Nodemcu D1 pin.

String link = "http://someserver.ngrok.io"; //the server

void setup() {
  pinMode(enable_pin,OUTPUT);
  sendActivity("baud_rate_is_set");
  Serial.begin(9600);
  delay(2000);
  digitalWrite(enable_pin,HIGH); //mcu - master : meter - slave
}

void loop() {
  int timeout = 5000;
  int delay_unit = 100;
  byte request[] = {0xb7,0xb7,0xaf,0x3f,0x30,0xb7,0xb4,0xb4,0x36,0x33,0x35,0xb1,0x21,0x8d,0x0a};
  sendActivity("send_enquiry_frame");

  //write
  Serial.write(request,sizeof(request) / sizeof(request[0]));
  digitalWrite(enable_pin,LOW);

  //delay & timeout
  sendActivity("start_waiting_5s");
  int current_delay = 0;
  while(current_delay <= timeout)
  {
    current_delay = current_delay + delay_unit;
    delay(delay_unit);
  }
  sendActivity("done_waiting_5s");

  //get the response part
  if(Serial.available())
  {
    sendActivity("serial_data_available");
    byte serial_receive_buff[200];
    Serial.readBytes(serial_receive_buff,200);
    char buff[200];
    array_to_string(serial_receive_buff,200,buff);
    sendResponse(buff);
  }
  else{
    sendActivity("serial_data_not_available");
  }
  delay(3000);

}

void sendActivity(String act)
{
  HTTPClient http;
  http.begin(link+"/api/activity/"+act);
  int code = http.GET();
}

void sendResponse(String data)
{
  HTTPClient http;
  http.begin(link+"/api/data/"+data);
  int code = http.GET();
}

void array_to_string(byte array[], unsigned int len, char buffer[])
{

    for (unsigned int i = 0; i < len; i++)
    {
        byte nib1 = (array[i] >> 4) & 0x0F;
        byte nib2 = (array[i] >> 0) & 0x0F;
        buffer[i*2+0] = nib1  < 0xA ? '0' + nib1  : 'A' + nib1  - 0xA;
        buffer[i*2+1] = nib2  < 0xA ? '0' + nib2  : 'A' + nib2  - 0xA;
    }
    buffer[len*2] = '\0';
}

Can anyone point out what i messed up ? I am stuck on this problem for few days. Thanks a lot.


texts: Press on pressure sensor, then wait 5 seconds, turn on LED

texts:
I'm having some trouble wrapping my head around timers in Arduino. I've got a FSR Pressure Sensor and I want it to turn on my NeoPixel LED after pressing on it for 5 seconds. Any help is much appreciated!

My goal:
FSRReading > 1022 then wait 5 seconds, turn on NeoPixel
FSRReading < 1022, then reset timer, turn off NeoPixel

This is what I currently have for my code, I can detect and act on sensor readings, but no timer:

#include <Adafruit_NeoPixel.h>
#define PIN 6
#define NUMPIXELS 16
#include "Timer.h"

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int fsrPin = 9; // FSR is connected to analog 0
int fsrReading; // the analog reading from the FSR resistor divider int LEDbrightness;
int LEDbrightness;
Timer t;

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

void loop(void) {
fsrReading = analogRead(fsrPin);
Serial.println(fsrReading);
Serial.print("Analog reading = ");

// we'll need to change the range from the analog reading (0-1023) down to the range // used by analogWrite (0-255) with map!
LEDbrightness = map(fsrReading, 0, 1023, 0, 255);

if (fsrReading < 10) {
Serial.println(" - No pressure"); } else if (fsrReading < 200) {
Serial.println(" - Light touch"); } else if (fsrReading < 500) {
Serial.println(" - Light squeeze"); } else if (fsrReading < 800) {
Serial.println(" - Medium squeeze"); } else {
Serial.println(" - Big squeeze"); }
delay(50);

for(int i=0;i<NUMPIXELS;i++){

  // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
  if (fsrReading>1022){
  pixels.setPixelColor(i, pixels.Color(0,255,0));
  } else if (fsrReading<1022) {
  pixels.setPixelColor(i, pixels.Color(0,0,0));
  }

  pixels.show(); // This sends the updated pixel color to the hardware.
 }
 }


texts:
I need to send one transmission and record multiple distances with 4 receivers, but everytime I use more than 2 receivers, the serial data does not print. What can I do?

P.S. I'm using 5 SRF-02 Sensors, 1 transmitter and 4 receivers all via I2C.

#include <Wire.h>

#define cmdByte 0x00                                 // Command byte
#define rangeByte 0x02                             // Byte for start of ranging data

byte highByte = 0x00;                                // Stores high byte from ranging
byte lowByte = 0x00;                                // Stored low byte from ranging
int range = 0;
int rangeData;

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

void loop() {
   D0_1= getRange(0x70, 0x71);
   Serial.println(D0_1);
   D0_2= getRange(0x70, 0x72);
   Serial.println(D0_2);
   D0_3= getRange(0x70, 0x73);
   Serial.println(D0_3);
   D0_4= getRange(0x70, 0x74);
   Serial.println(D0_4);
}

 int getRange (uint8_t send_address, uint8_t rec_address)
 {
  Wire.beginTransmission(rec_address);
  Wire.write((uint8_t)cmdByte);
  Wire.write((uint8_t)0x56);
  Wire.endTransmission();

  Wire.beginTransmission(send_address);             // Start communticating with SRF02
  Wire.write((uint8_t)cmdByte);                         // Send Command Byte
  Wire.write((uint8_t)0x5C);        // Transmit an 8 cycle 40khz burst - no ranging takes place
  Wire.endTransmission();

  delay(80);                                                           // Wait for ranging to be complete

  Wire.beginTransmission(rec_address);       // start communicating with SRFmodule
  Wire.write((uint8_t)rangeByte);                 // Call the register for start of ranging data
  Wire.endTransmission();

  Wire.requestFrom(rec_address, 2);            // Request 2 bytes from SRF module

  while(Wire.available() < 2);                    // Wait for data to arrive
  highByte = Wire.read();                           // Get high byte
  lowByte = Wire.read();                           // Get low byte

  range = (highByte << 8 ) + lowByte;              // Put them together

 delay(120);

 return(range);                                                    // Returns Range
 }


texts:
I've only started using Arduino in the last week, and I'm having a problem with the servo supplied with the kit I purchased. It's a SG90 microservo. I'm trying to connect the servo as shown on the Arduino tutorial site:

But when I connect the power and ground pins to the board, the board powers down and disconnects from the USB. I've had the servo working before without a problem.

Yesterday I was trying out another tutorial without any luck, and I noticed the servo getting hot (not too hot to touch though).

Could I have accidentally fried the control board in the servo?


texts: ESP32: Share I2C bus among multiple freeRTOS tasks - do I have to expect synchronization issues?

texts:
I recently inherited some firmware with weird problems in regards to the duration of reading sensor values. The board is based on the ESP32 Wrover MCU and has multiple sensors connected via the I2C bus. The firmware makes use of the port of the FreeRTOS task library and uses the main loop to read two sensors as well as an extra task on the same core to read some more sensor via a DS2482 I2C to OneWire bridge. Usually I would expect the reading of the sensors to take at most one second (assuming the 'worst' case under normal conditions) via the bridge, but it takes a multitude of that, usually around 30 or more seconds for one sensor. Not only the reading but any communication over the bridge takes a very long time. One more detail: The sensors behind the bridge are connected one per channel of the bridge and the one wire channel is reset each time before a sensor is read.

My current suspicion is that using multiple tasks on the same I2C bus may screw up the timings of the communication and thus cause communication errors leading to the increased read times.

Does that suspicion sound reasonable at all or what would you suggest to investigate on the described system (knowing well, that I didn't provide too many details)?

Any ideas are welcome.

Thanks!


texts:
I'm using the Registers of the Arduino micro to get a signal for Electronic Speed Controllers (ESC) for brushless motors.
As far as I read, ESCs interpret everything they can, while just ignoring too fast update rates. If somebody knows better, this would be a great time to yell.

The goal is to get a digital signal, where a timespan between 1 and 2 ms is HIGH and the rest low. Ideally I want this at 50-400Hz, since 488Hz is the fastest possible frequency, and 50 Hz the standard Servo frequency.

I try to use Phase Correct Mode to count up and down continuously. As the value in the counter reaches my set OCRnx on the way up, it sets the output pin LOW, as it reaches the same value on the way down, after reaching TOP(value), it sets the output HIGH. In ATmega documentation terms, this is NON-inverted Phase-Correct-PWM.

So I set the Registers DDR (to set the pin as output), TCCR1A and TCCR1B and ICR1 (TOPvalue = between 20000 and 2500).

Now using OCR1A = 1000 should give me a pulse width of 1000ms. This is the expected or target behaviour.

My testing code is:

// using a 16-bit timer to generate PWM signals for ESCs

// Phase Correct Mode counts from Bottom to Top and back to Bottom
// with a prescaler of 8
// motor signal (OCRnx) uses values of 1000 (idle) - 2000 (max)
// which directly corresponds to microseconds HIGH-time
// setting the range to (BOTTOM) 0 - TOPvalue sets the frequency

// two important formulas are:
// frequency(PWM) = F_CPU / (2*Prescalar*TOPvalue)
//
// PulseWidth [s] = High-tick-count / (F_CPU/Prescalar)
// High-tick-count = 2 * OCR-value

// n = number of timer (1,3)
// x = A,B,C

#include "Arduino.h"
// #include <Arduino.h>
// #define DEBUG
// #include <Moto.h>

#define PRESCALAR 8
#define PWM_FREQUENCY 50
#define TOP_VALUE F_CPU/(2*PRESCALAR*PWM_FREQUENCY)

uint16_t dutytime = 1000; // this gives idle throttle signal

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

  // TIMER 1
  // TIMSK1 = 0; // disable Interrupts for timer1
  DDRB |= (1<<DDB5); // D9 Output
  DDRC |= (1<<DDC6); // D5 Output

  // set 1000ms to start motors in idle mode
  OCR1A = 1000L;
  OCR3A = 1000L;

  // bits 7,5,3 PWM Output on pins A,B,C respectively
  // bits 1,0 WGM_1,0: phase correction mode
  // TCCR1A |= B10000010; // in hex: 0xAA for all 3 = B 1010 1010
  TCCR1A |= (1<<COM1A1)|(1<<WGM11);
  // bit 4,3 WGM_3,2: phase correction mode
  // bits 2,1,0 Prescalar: 8
  // TCCR1B |= B00010010; // in hex: 0x12; B 0001 0010
  TCCR1B |= (1<<WGM13)|(1<<CS11);
  ICR1 = TOP_VALUE;

  // TIMER 3
  // TIMSK3 = 0; // disable Interrupts for timer3
  // bit 7 PWM Output on pin A
  // bits 1,0 WGM_1,0: phase correction mode
  TCCR3A |= B10000010; // in hex: 0x82; // B 1000 0010
  // bit 4,3 WGM_3,2: phase correction mode
  // bits 2,1,0 Prescalar: 8
  TCCR3B |= B00010010; // in hex: 0x12; B 0001 0010
  ICR3 = TOP_VALUE; // TOPvalue = 2048

}//setup

void loop(void) {

  // Serial.println(TOP_VALUE);
  // delay(500);
  while (dutytime < 2000) {
    dutytime += 150;
    OCR1A = dutytime;
    OCR3A = dutytime;
    Serial.println(dutytime);
    delay(1500);
  }
  while (dutytime > 1000) {
    dutytime -= 150;
    OCR1A = dutytime;
    OCR3A = dutytime;
    Serial.println(dutytime);
    delay(1500);
  }

}//loop

I repeated the settings for timer3 to get something to compare to. Both do give the same: if i delete the loop and just write loop{} nothing happens. The pins are high and seem to stay so. With the while loops activated, my multimeter gives me 1Hz (which are the changes of course) and between 99.9% duty cycle and 96%.
An led, which i connected to it blinks every second a very short time.

What am I doing wrong?


texts: How to Connect Dc motor with encoder (pololou) with motor shield and Arduino Mega 2560?

texts: I tried to search a bout how to connect plolou motor with encoder to arduino mega and the motor control shield as in those pics  if any one knows how to connect those to each other please tell me


texts: Testing of voltage level converter with arduino

texts: I am having a problem I am testing logic level shifter https://ewall.com.pk/product_view/IIC-I2C-Logic-Level-Converter-Bi-Directional-Module-5V-to-3.3V/910. I have followed the procedure as given in this post Test level shifter with Arduino and some data. But I am getting opposite result when I connect LV1 to LV2 arduino stop uploading and give error and nothing displays on serail monitor. Kindly help me.


texts:
How do you confirm a pin has been damaged and is unable to work as a digital input?

I tried detecting a pushbutton (connecting ground to pin 11 with a pullup resistor enabled) on a fresh Arduino Uno and digitalRead() always registers 0, regardless of the pushbutton state.

To confirm it wasn't my pushbutton's wiring, I tested it on some other pins, and they register the button press perfectly. I then tested pin 11 as an output, and it was able to blink and LED just fine.

The Arduino's pretty new, and I don't remember doing anything with it that would have damaged anything, much less pin 11, but is it fair to say that pin has somehow been damaged? As far as I can tell, everything else on the Arduino works perfectly.


texts: Arduino powered from motor shield and USB issue

texts:
I am using an Arduino (Elegoo) Mega with Motor shield to drive a digital train set. The Motor shield is powered from a 12v 1.1 amp dc power supply and I have the Arduino plugged into my laptop via USB. I have an app which sends commands via serial to the mega which are then turned into commands for the train set and sent down the line.

When using this all of a sudden the main chip on my Arduino blew up and my Laptop seemed to blow a re-settable fuse shutting off instantly (It was dead for about 10-20 minutes then worked again).

Would this be because something caused power to get back through the Arduino to my laptop?

The railway will short from time to time if a locomotive derails for example.

I know there is a trace on the Motor Shield which prevents the shield powering the Arduino. I have now cut this although it says you only need to cut it if using over 12v.


texts: Arduino Uno does not detect the GPS module

texts:
I am trying to start the GLONASS NEO-7M-C module using TinyGPS++ liblary, but in the serial monitor I receive a message all the time that the module is not detected.

My connection:

PPS - None
RX - 4
TX - 3
GND - GND
VCC - 5V


texts: Why can't I use an optocoupler to drive an AC circuit using the arduino digital pins?

texts: So, when I searched for ways to drive AC circuits from Arduino, everyone suggested relays with a transistor switching circuit to channel an external 5V. I was wondering what would happen if I used an optocoupler like 4n35 to drive an AC circuit. Will the phototransistor inside the chip burn out?


texts: Cannot bootload again after changing the board?

texts:
We are so tired and would like to get help with this. We are trying to bootload using the arduino Uno.

We have an atmega 328p smd , that we are trying to bootload. We have connected all the right pins, added to the boards.txt the  "Atmega328 on a breadboard(8mhz internal clock)".

Then I have chosen from the "board" menu, this option (internal clock), and uploaded the program. it worked .

Later, I wanted to try and bootload for external clock so I chose from the boards menu the pro mini with 5v board.(is it wrong?)

Not only that I got an error, now, I can't bootload the internal clock again !!

Why can't we bootload again? Did we damage something? Can it be reset again?
How can you bootload for external 16Mhz ??

error :

avrdude: Yikes!  Invalid device signature.
         Double check connections and try again


texts: 4-digit 7 Segment LED displaying numbers in the wrong order

texts:
I am a novice Arduino programmer and am currently having trouble with a SH5461AS 4-digit/7-segment LED when using it with an Arduino Uno. I have struggled to find an accurate datasheet/tutorial of any kind for this particular model (It is the LED without the colons in between digits 2 and 3) but I believe I have it figured out.

I currently have it going through a HC595 shift register but when I removed the register and connected the LED directly to the board the problem remained. My code below is with the shift register; I am displaying it this way because it is simpler to view and I thought it would make it easier to debug.

I can display a single digit at a time correctly. However, when I try to display 2+ digits at one time, they are in the incorrect order.
For example, I can count 1-9 on the first digit, then 1-9 on the 2nd digit, and so on and everything displays correctly (other digits are off). But as soon as I try to display multiple digits they are in the wrong order. So if I try to display 12__ with the last 2 digits off, 21__ is displayed with the last two digits off. If I try to display 23, 32 is displayed. If I try to display 1234, 4123 is displayed.

I am at a loss because the code seems like it should be simple.

const int DATA = 0;
const int LATCH = 1;
const int CLOCK = 2;

const int DIGIT_ONE = 3;
const int DIGIT_TWO = 4;
const int DIGIT_THREE = 5;
const int DIGIT_FOUR = 6;

//digits[0-9] corresponds to the patterns for numbers 0 -> 9.
//Add 1 to the digits[X] to turn on the dot.
byte digits[] = {B11111100, B00011000, B01101110, B00111110, B10011010, B10110110, B11110010, B00011100, B11111110, B10111110};

void setup() {
  pinMode(DATA, OUTPUT);
  pinMode(CLOCK, OUTPUT);
  pinMode(LATCH, OUTPUT);

  pinMode(DIGIT_ONE, OUTPUT);
  pinMode(DIGIT_TWO, OUTPUT);
  pinMode(DIGIT_THREE, OUTPUT);
  pinMode(DIGIT_FOUR, OUTPUT);

  digitalWrite(DIGIT_ONE, HIGH);
  digitalWrite(DIGIT_TWO, HIGH);
  digitalWrite(DIGIT_THREE, HIGH);
  digitalWrite(DIGIT_FOUR, HIGH);
}

void loop() {
  writeDigit(DIGIT_TWO, 2);
  writeDigit(DIGIT_THREE, 3);
}

/*
 * Write a digit to the 4-digit 7-segment LED
 * - digitPin corresponding to the pin on the LED to light up the correct digit.
 * - number 0-9 to display on the LED
 */
void writeDigit(int digitPin, int number) {
  digitalWrite(digitPin, LOW);

  digitalWrite(LATCH, LOW);
  shiftOut(DATA, CLOCK, LSBFIRST, digits[number]);
  digitalWrite(LATCH, HIGH);

  digitalWrite(digitPin, HIGH);
}

So in this instance, I am expecting 23 but 32 is displaying instead.

I am also having trouble with some bleeding (I don't know what the correct term is) where some segments are very faintly glowing even though I am not doing it intentionally. This is a much smaller issue, however, than digits randomly in the wrong order.

If it would help, I can try to post the circuit diagram as well.


texts: How much voltage and amps for 2 SG90 servos?

texts: Question is pretty straight forward: How much amps and voltage do I need for 2 SG90 servos? I want to use 4 but you might already know that Arduino Uno only has 2 5V ports.


texts:
First I need to say, I'm a complete electrics newbie, so I need your help.

I have got a standalone Atmega 2560, which I want to program. I connected MISO, MOSI, SCK, RESET, 5V and GND to an Arduino Uno.
In addition a 16MHZ oscillator is connected to XTAL1 and XTAL2 plus I pull all VINs of the Atmega with a 100nF to GND. Plus I connected a separate VIN and GND to the 2560.

I programmed the Arduino Uno as an "Arduino as ISP". Afterwards I connected the 2560 as mentioned above, changed the board to "Mega 2560" and tried to upload a sketch through the Arduino and I get the error message:
avrdude: stk500v2_getsync(): timeout communicating with programmer

Is there something I missed?

Cheers
jb


texts:
I am trying to use one of the hardware timers on the arduino uno to generate a short pulse some number of microseconds after receiving a pulse on an input.

Currently my code looks like this:

uint16_t pulse_delay = 12000; //half-microseconds
uint16_t pulse_length = 20;

void setup(){
  pinMode(8, INPUT);
  pinMode(9, OUTPUT);
  TCCR1A = 0;
  TCCR1B = _BV(ICNC1)  //input capture noise cancel
      | _BV(ICES1) //positive edge
      | _BV(CS11); // /8 prescaler
  TIMSK1 = _BV(ICIE1); //enable input capture interrupt
}
void loop(){}
ISR(TIMER1_CAPT_vect){
  TCCR1A = _BV(COM1A0) | _BV(COM1A1); //set OC1A on match
  TIMSK1 |= _BV(OCIE1A); //enable match interrupt
  OCR1A = pulse_delay; //pulse begin time

  TCNT1 = TCNT1 - ICR1; //TCNT1 now contains time since input pulse, even if
                        //the interrupt isn't run immediately
}
ISR(TIMER1_COMPA_vect){
  TIMSK1 &=~ _BV(OCIE1A); //disable match interrupt
  TCCR1A = _BV(COM1A1); //clear OC1A on match

  OCR1A = pulse_delay + pulse_length;
}

This code should theoretically do the task, but it doesn't produce any output at all - to my oscilloscope it looks like the output pin just stays low.

However, if I replace the last line (OCR1A = pulse_delay + pulse_length;) of the compare match interrupt with the following two lines, it outputs a pulse just fine. The issue with this is that it uses significantly more CPU time, and it can only count time from when the interrupt starts so if the interrupt is executed late the pulse will be longer.

  delayMicroseconds(pulse_length);
  TCCR1C = _BV(FOC1A); //manually trigger match event

All that the first version is doing differently is triggering the match event via an 'alarm' set on the timer, rather than waiting to trigger the match manually.

Why does the first version not work, and how can I make it work??


texts: Weird stepper motor behaviour on RAMPS in arduino

texts:
Following this tutorial:

http://www.instructables.com/id/Complete-newbie-step-by-step-3D-printer-with-all-p/?ALLSTEPS

I connected DVD stepper motor to RAMPS 1.4 on arduino with Marlin software with this settings:

 //#define DEFAULT_AXIS_STEPS_PER_UNIT   {80,80,4000,500}  // default steps per unit for Ultimaker

 #define DEFAULT_AXIS_STEPS_PER_UNIT {215.12,215.12,8034.69,196.52}

 // #define DEFAULT_MAX_FEEDRATE          {300, 300, 5, 25}    // (mm/sec)

 #define DEFAULT_MAX_FEEDRATE {100, 100, 2, 25}

 // #define DEFAULT_MAX_ACCELERATION      {3000,3000,100,10000}    // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for Skeinforge 40+, for older versions raise them a lot.

 #define DEFAULT_MAX_ACCELERATION {200,200,50,5000}

 #define DEFAULT_ACCELERATION          100    // X, Y, Z and E acceleration in mm/s^2 for printing moves

 #define DEFAULT_RETRACT_ACCELERATION  100    // E acceleration in mm/s^2 for retracts

 #define DEFAULT_TRAVEL_ACCELERATION   100    // X, Y, Z acceleration in mm/s^2 for travel (non printing) moves

I put a video at vid.me (hopefully with sound) showing stepper behaviour when I press +1mm,-1mm,-1mm,-1mm,-1mm,-1mm,-1mm,+1mm,+1mm,+1mm,+1mm  on Pronterface software.


texts: Connect Arduino with fischertechnik TX Controller

texts: Is it possible to cinnect the Arduino with a fischertechnik TX Controller? Maybe with I²C, but i want to use I²C for something else on the arduino. So are there multiple I²C Ports on the Arduino (I haven't got one yet)?


texts: Adafruit Circuit Playground Express interrupt not working

texts:
I have interrupts attached to pins 4 and 5 which correspond to the left and right inbuilt buttons on the circuit playground express (https://learn.adafruit.com/adafruit-circuit-playground-express/pinouts). For some reason the right button interrupt works perfectly however the left interrupt doesn't even trigger. Here's the code:

#include <Adafruit_Circuit_Playground.h>
#include <Adafruit_CircuitPlayground.h>

volatile bool leftState = false, rightState = false;

void left()
{
    if (CircuitPlayground.leftButton())
        leftState = !leftState;
}

void right()
{
    if (CircuitPlayground.rightButton())
        rightState = !rightState;
}

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

    attachInterrupt(digitalPinToInterrupt(4), left, CHANGE);
    attachInterrupt(digitalPinToInterrupt(5), right, CHANGE);
}

void loop()
{
    Serial.print(leftState);
    Serial.print("\t");
    Serial.print(rightState);
    Serial.print("\n");
}


texts: Communicating with Arduino Mega 2560 Serial ports through x2 RS232

texts:
I am trying to driver a stepper motor using an Arduino Mega 2560. There will ideally be two RS232 signals being read into / written from the Arduino, each using male USB 3.0 connectors; one of these is for configuring and controlling the driver of the motor and the other is simply getting an output torque measurement from a torque meter connected to the motor's shaft. I am simply wondering if Arduino would be able to handle these two functions, and how I might go about connecting each of the two streams of data. I have looked into this question through Arduino documentation, tutorials, and forums for hours, and finally figured I would contribute to the posts on my own.

Thank you!
- a confused college student


texts: "no matching function for call to 'SimpleDHT11::read(byte*, byte*, NULL)'" error for arduino code

texts:
My code isn't working and shows up with this error message. "no matching function for call to 'SimpleDHT11::read(byte*, byte*, NULL)'"
How do i fix this? This is my complete code.
#include <SimpleDHT.h>

int pinDHT11 = 2;
SimpleDHT11 dht11;

void setup()
{
    Serial.begin(9600);
    pinMode(9, OUTPUT);
    int err = SimpleDHTErrSuccess;
}

void loop()
{
    // start working...
    Serial.println("=================================");
    Serial.println("Sample DHT11...");

    // read without samples

    byte temperature = 0;
    byte humidity = 0;

    int err = SimpleDHTErrSuccess;
    if ((err = dht11.read(&temperature, &humidity, NULL)
       != SimpleDHTErrSuccess)
    {
        Serial.print("Read DHT11 failed, err=");
        Serial.println(err);
        delay(1000);
        return;
    }
    Serial.print("Sample OK: ");
    Serial.print((int)temperature);
    Serial.print(" *C, ");
    Serial.print((int)humidity);
    Serial.println(" *H, ");

    if (humidity > 70 )
    {
        Serial.println("Humidity is above 70%");
        digitalWrite(9, HIGH);
    }
    else
    {
        Serial.println("Humidity is below 70%");
    }
    // DHT11 sampling rate is 1HZ.
    delay(1500);
}


texts: What is wrong with my code? (HC-SR04 using 433 mhz module);

texts:
I asked a question about this last time but I still couldn't make it work but it somehow gave me an overview about my project. Now I've created an another project that is similar to the last one, the only different thing is that I used a VirtualWire library. So I connected an HC-SR04 to an arduino board(BOARD1) with a transmitter; and a receiver to another board(BOARD2). I Followed a code in the internet similar to my project but he has an lcd display but I just want to make my sensor readings displayed in my Serial monitor what should I do?
HERE IS THE CODE FOR THE TRANSMITTER
#include <VirtualWire.h>
const int trig= 9;
const int echo= A1;

float sensorval;
float distance;
char msg[6];

void setup() {
  vw_set_tx_pin(12);
  vw_setup(2000);
  pinMode(trig,OUTPUT);
  pinMode(echo,INPUT);
  Serial.begin(9600);

}

void loop() {
  digitalWrite(trig,LOW);
   delayMicroseconds(10);
   digitalWrite(trig,HIGH);
   delayMicroseconds(10);
   digitalWrite(trig,LOW);
   delayMicroseconds(10);
   sensorval=pulseIn(echo,HIGH);

   distance = (sensorval*.0343)/2;

   Serial.print("Distance: ");
   Serial.println(distance);
   dtostrf(distance, 6,2,msg);
   vw_send((uint8_t *)msg, strlen(msg));
   vw_wait_tx();
   delay(500);

}

AND HERE IS THE CODE FOR THE RECEIVER
#include<VirtualWire.h>
#include <Wire.h>

int i;
void setup() {
  vw_set_rx_pin(12);
  vw_setup(2000);
  vw_rx_start();

}

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

  if (vw_get_message(buf, &buflen)){
    Serial.print("distance is: ");
   Serial.print((char *)buf);
      Serial.print(buf[i]);
    }

  }


texts: RFID/NFC Tag get data from wordpress MySQL

texts:
I have a local workshop for students to teach them 3D printing/woodworking
I want to know if its possible to create RFID/NFC tags using wordpress data from MySQL or HTTP/HTTPS.
Web Scenario :
I have a wordpress website where I setup a gamefication plugin.
Each time a student takes a quiz/posts on forum he gets a "x" number of points that are accumulated on his profile.
I want to know if I can get a RFID/NFC tag to get that number of points.
Each member has a RFID/NFC tag card and with that card he can get access to different things around the workshop .
Workshop Scenario :
For each tool there will be a lock , RFID/NFC reader and a LCD display screen.
When a student want to access that tool he needs a number of points on the wordpress gamefication script that are transfered to the RFID/NFC card.
If he has the needed points a text on the LCD screen will appear with something like " You have access to this tool" and the tool will be unlocked .
Else if the user doesn't meet the needed points the LCD screen will show "You don't have the needed points for this tool, please visit [URL] to get more info" and the tool will stay locked.

I need only info if this is possible, not the way to do it.
[ In case you are kind to hand me some guides on where to start to will be great! ]

Thanks and waiting to see if this is possible!


texts: Problem with String& argument of a function

texts:
I am trying to send SMSs using a GSM module with Arduino Mega. I have followed a tutorial and downloaded the SIM908IDE100 library. I am using the function

SendSMS(String&, const char [27]);.

It works fine when I type:

sms.SendSMS("1234567890","Text message");

where "1234567890" is the telephone number I want to send the SMS to and "Text message" is the text of the SMS.

If I instead try to pass to the function a String containing the telephone number

String number = "1234567890";
sms.SendSMS(number,"Text message");

I get the following error:

exit status 1
no matching function for call to 'SMSGSM::SendSMS(String&, const char [27]);'

I don't understand what String followed by an ampersand means. What am I supposed to pass the function as its first argument?


texts:
I am using a A1324 hall effect sensor for a distance measuring.

The voltage output keeps changing even if the distance between the magnet and sensor does not change. The output changes +-0.200V and I am trying to measure the distances at steps of 0.01V.


texts: Why is my DHT22 sensor reading 1.00% humidity?

texts:
I have a seemingly simple problem but I haven't found a solution yet. I recently got a DHT22 temp/humidity sensor and I wired it according to the guide from Adafruit.

I downloaded and installed the library. I loaded the "DHTtester" example sketch. I also included the Adafruit Unified Sensor library to be safe, because the guide said I might need to. But when I upload the sketch and check the serial monitor the humidity value is always "1.00%". The temperature also seems to be off by about 4 degrees F.

I don't know what is going wrong here. I've removed the 10K resistor but nothing changed. Does anyone know why this might be happening? Any help would be appreciated. Thanks!


texts:
I am controlling 2 motors from my Arduino Pro Mini and L293D motor driver module. Problem is, I have to set a pin high and after 1 second set it to LOW. But that doesn't happen... The pin just stays HIGH and is never LOW.

Here's my Code -

    int IN2Left = 10;
    int E1 = 12;
    int E2 = 7;
    int IN3RevRight = 6;
    int trigPin1 = A0;
    int echoPin1 = A1;
    int distance1 = 0;
    int IN4Right = 5;
    int IN1RevLeft = 11;

    void setup()
    {
      pinMode(IN2Left, OUTPUT);
      pinMode(E1, OUTPUT);
      pinMode(E2, OUTPUT);
      pinMode(IN3RevRight, OUTPUT);
      pinMode(IN4Right, OUTPUT);
      pinMode(IN1RevLeft, OUTPUT);
      pinMode(trigPin1, OUTPUT);
      pinMode(echoPin1, INPUT);
      pinMode(13, OUTPUT);
      Serial.begin(9600);
    }

    void loop() {
  digitalWrite(13, HIGH);
  digitalWrite(E1, HIGH);
  digitalWrite(E2, HIGH);
  digitalWrite(IN2Left, HIGH);
  digitalWrite(IN4Right, HIGH);
  delay(3000);
  digitalWrite(IN4Right, LOW);
  digitalWrite(IN3RevRight,HIGH);
  delay(500);
  digitalWrite(IN3RevRight, LOW);
  digitalWrite(IN4Right, HIGH);
  delay(1500);
  digitalWrite(IN2Left, LOW);
  digitalWrite(IN1RevLeft, HIGH);
  delay(500);
  digitalWrite(IN1RevLeft, LOW);
  digitalWrite(IN2Left, HIGH);
  delay(100000);
    }

The IN2Left Pin never goes LOW... I am assuming a faulty Arduino but my Arduino seems to be working just fine as it runs other stuff (tested blink and reading an Ultrasonic sensor) just fine.

My deadline is 2 hours from now...

EDIT: Here's the complete void loop function... Note the two pins on top which go HIGH? They Never go LOW again in the entire code.


texts: does EEPROM reset itself when a new code is uploaded?

texts: I have a Nodemcu with which i'm doing a project. So whenever there is a power loss i want values of some of the variables to not be reset, because of that im trying to store the values in EEPROM of the nodemcu. But the problem is i want to know if the EEPROM will get reset when a new code is uploaded and also since the nodemcu stores wifi credentials in the EEPROM i dont want to accedentally select an EEPROM address in which the wifi credentials are stored and cause a problem. Can anyone tell me the safe EEPROM addresses to use and also if EEPROM will get rest if  a new code is uploaded?


texts: First recieved packet not displayed (Arduino with MRF24j40MA)

texts:
I'm trying to make two Arduino cards communicate, one is a sender and the other only receive packet from the first one and then display them.

My problem is that the first recieved packet is not displayed unlike the other packets(displayed normally)

here's the output of my code :

Here's my code of the reciever :

void handle_rx() {

Serial.print("received a packet ");Serial.print(mrf.get_rxinfo()->frame_length, DEC);Serial.println(" bytes long");

if(mrf.get_bufferPHY()){
  Serial.println("Packet data (PHY Payload):");
  for (int i = 0; i < mrf.get_rxinfo()->frame_length; i++) {
      Serial.print(mrf.get_rxbuf()[i]);
  }
}

Serial.println("\r\nASCII data (relevant data):");
for (int i = 0; i < mrf.rx_datalength(); i++) {
    Serial.write(mrf.get_rxinfo()->rx_data[i]);
}

Serial.print("\r\nLQI/RSSI=");
Serial.print(mrf.get_rxinfo()->lqi, DEC);
Serial.print("/");
Serial.println(mrf.get_rxinfo()->rssi, DEC);
}

Here is the complete sketch:

/**
 * Example code for using a microchip mrf24j40 module to send and receive
 * packets using plain 802.15.4
 * Requirements: 3 pins for spi, 3 pins for reset, chip select and interrupt
 * notifications
 * This example file is considered to be in the public domain
 * Originally written by Karl Palsson, karlp@tweak.net.au, March 2011
 */
#include <SPI.h>
#include <mrf24j.h>

const int pin_reset = 6;
const int pin_cs = 7; // default CS pin on ATmega8/168/328
const int pin_interrupt = 2; // default interrupt pin on ATmega8/168/328

Mrf24j mrf(pin_reset, pin_cs, pin_interrupt);

long last_time;
long last_time2;
long tx_interval = 1000;

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

  mrf.reset();
  mrf.init();

  mrf.set_pan(0xcafe);
  // This is _our_ address
  mrf.address16_write(0x4201);

  // uncomment if you want to receive any packet on this channel
  //mrf.set_promiscuous(true);

  // uncomment if you want to enable PA/LNA external control
  //mrf.set_palna(true);

  // uncomment if you want to buffer all PHY Payload
  //mrf.set_bufferPHY(true);

  attachInterrupt(0, interrupt_routine, CHANGE); // interrupt 0 equivalent to pin 2(INT0) on ATmega8/168/328
  last_time = millis();
  interrupts();
}

void interrupt_routine() {
    mrf.interrupt_handler(); // mrf24 object interrupt routine
}

void loop() {
    mrf.check_flags(&handle_rx, &handle_tx);
    unsigned long current_time = millis();
    if (current_time - last_time > tx_interval) {
        last_time = current_time;
        Serial.println("txxxing...");
        mrf.send16(0x4202, "abcd");
    }
}

void handle_rx() {
    Serial.print("received a packet ");Serial.print(mrf.get_rxinfo()->frame_length, DEC);Serial.println(" bytes long");

    if(mrf.get_bufferPHY()){
      Serial.println("Packet data (PHY Payload):");
      for (int i = 0; i < mrf.get_rxinfo()->frame_length; i++) {
          Serial.print(mrf.get_rxbuf()[i]);
      }
    }

    Serial.println("\r\nASCII data (relevant data):");
    for (int i = 0; i < mrf.rx_datalength(); i++) {
        Serial.write(mrf.get_rxinfo()->rx_data[i]);
    }

    Serial.print("\r\nLQI/RSSI=");
    Serial.print(mrf.get_rxinfo()->lqi, DEC);
    Serial.print("/");
    Serial.println(mrf.get_rxinfo()->rssi, DEC);
}

void handle_tx() {
    if (mrf.get_txinfo()->tx_ok) {
        Serial.println("TX went ok, got ack");
    } else {
        Serial.print("TX failed after ");Serial.print(mrf.get_txinfo()->retries);Serial.println(" retries\n");
    }
}


texts:
I'm trying to write a code for nodeMCU (esp8266 based board) to continuously calculate distance between GPS location and geographical coordinates written in a CSV file in SD. Originally I thought the best way to do it was to parse the file, save the longitudes and latitudes in two arrays at startup and, then, calculate continuously distances between arrays and coordinates taken from GPS. If distance is less than a value, an output warns me. There is only a "little" problem: the file contains 5500 coordinates and, so, it is impossible to allocate two arrays containing 5500 floats inside ram memory. Now I have thought two alternatives:
1) save the two arrays in flash memory that is, I know, a lot slower but also bigger
2) parse and calculate distance line by line continuously: in a loop I'll take the first line from SD, parse it, calculate distance between it and GPS location and, then do the same thing for second, third,... line. It requires the continuous access to SD and parsing but I don't have to use flash memory.
What is the best option in your opinion? Have you got alternatives or suggestions?
Thank you!!


texts: There's an error I don't know how to fix

texts:
I basically have a bread board with an rgb led and a peizo buzzer with a photocell.

I have the codes for both. If I put a code for the rgb, it works. If I put the code for the peizo, it works. Once I paste both codes onto it it says there's an error because "void setup" and "void loop" are already defined. What do I do to get both things to work?

rgb led code:

/*
Adafruit Arduino - Lesson 7. RGB Fader
*/
int redLEDPin = 11;
int greenLEDPin = 10;
int blueLEDPin = 9;
int redSwitchPin = 7;
int greenSwitchPin = 6;
int blueSwitchPin = 5;
int red = 0;
int blue = 0;
int green = 0;

void setup()
{
  pinMode(redLEDPin, OUTPUT);
  pinMode(greenLEDPin, OUTPUT);
  pinMode(blueLEDPin, OUTPUT);
  pinMode(redSwitchPin, INPUT_PULLUP);
  pinMode(greenSwitchPin, INPUT_PULLUP);
  pinMode(blueSwitchPin, INPUT_PULLUP);
}

void loop()
{
  if (digitalRead(redSwitchPin) == LOW)
  {
    red ++;
    if (red > 255) red = 0;
  }
  if (digitalRead(greenSwitchPin) == LOW)
  {
    green ++;
    if (green > 255) green = 0;
  }
  if (digitalRead(blueSwitchPin) == LOW)
  {
    blue ++;
    if (blue > 255) blue = 0;
  }
  analogWrite(redLEDPin, red);
  analogWrite(greenLEDPin, green);
  analogWrite(blueLEDPin, blue);
  delay(10);
}

peizo code:

int speakerPin = 12;
int photocellPin = 0;

void setup()
{
}

void loop()
{
  int reading = analogRead(photocellPin);
  int pitch = 200 + reading / 4;
  tone(speakerPin, pitch);
}


texts:
// TIMER/COUNTER 0
// PIN 6(OC0A) = NON-INVERTED [_BV(COM0A1)]
// PIN 5(OC0B) = INVERTED     [_BV(COM0B1) | _BV(COM0B0)]
// PWM MODE    = FAST PWM     [_BV(WGM01) | _BV(WGM00)]
// PRESCALER   = 1            [_BV(CS00)]
TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(COM0B0) | _BV(WGM01) | _BV(WGM00);
TCCR0B = _BV(CS00);

// TIMER/COUNTER 1
// PIN 9(OC1A)  = ?????
// PIN 10(OC1B) = ?????
// PWM MODE     = FAST PWM 8BIT[_BV(WGM12) | _BV(WGM10)]
// PRESCALER    = 1            [_BV(CS10)]
TCCR1A = ????? | _BV(WGM10);
TCCR1B = _BV(WGM12) | _BV(CS10);

// TIMER/COUNTER 2
// PIN 11(OC2A) = NON-INVERTED [_BV(COM2A1)]
// PIN 3(OC2B)  = NON-INVERTED [_BV(COM2B1)]
// PWM MODE     = FAST PWM     [_BV(WGM21) | _BV(WGM20)]
// PRESCALER    = 1            [_BV(CS20)]
TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
TCCR2B = _BV(CS20);

Hi. My intention of writing the codes is to clarify my doubts regarding arduino timer.
First of all, I intend to have 6 consistent PWM outputs which is 8 bits and runs at 62.5kHz. The confusion here is FAST PWM and PHASE CORRECT PWM. TIMER 1 and 2 is usually presented as PHASE CORRECT PWM. So does changing the PWM mode of TIMER 1 and 2 to FAST PWM enables the PWM to reach a frequency of 62.5kHz (prescaler set as 1)? Is the code that I have written correct? Do take note of the inverted and non-inverted pin mode.
Secondly, as seen from my code above, Timer/Counter 1 is not properly written (?????). I wish to control pin 9 and 10 so that it can invert or non-invert individually.
Timer 0 and 2 allows me to set the pins individually (inverted and non-inverted). However from the atmega328p datasheet, Timer 1 control register is  weird. How can I set the register so that I can do what I want to do which is to control the pins individually?

I truly apologize for any confusion caused by my sentence structure. I am aware I have a poor way of organizing and presenting my idea. And lastly, thank you for taking your time reading these doubt of mine.


texts:
I am extremely new to Arduino and electrical engineering, and the project I am attempting involves a ultrasonic sensor.  I am using the HC-SR04 with the Elegoo Mega2560 Arduino board.  A few days ago I was able to print out the distance correctly with an Arduino library, but after adding a h-bridge, 2 motors, and 2 9-volt batteries, the sensor didn't seem to work properly.  I went back to a simple circuit with only the HC-SR04, and the distance readouts were all over the place.  No matter what, the distance stayed between 90 and 120, mainly staying in the 110s.  These numbers seemed to have no correlation with the actual distance.  I even tried to calculate the distance myself in case there was something wrong with the library.

I have the VCC pin on the HC-SR04 connected to the 5v on the Arduino, the GND pin connected to the GND pin on the Arduino, the Trigger pin connected to pin 50 on the Arduino, and the Echo pin on the Arduino connected to pin 52 on the Arduino.  The Arduino is connected to my computer through USB.

Here is my sketch for printing out the distance without a library:

const int triggerPIN = 50;  //these are digital pins on the Arduino board
const int echoPIN = 52;     //I'm sure these pins aren't broken because I never used them before now

long duration;
int distance;

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

    pinMode (triggerPIN, OUTPUT);
    pinMode (echoPIN, INPUT);

    delay(1000);
}

int getDistance () {
    digitalWrite (triggerPIN, LOW);
    delayMicroseconds (2);

    digitalWrite (triggerPIN, HIGH);
    delayMicroseconds (10);
    digitalWrite (triggerPIN, LOW);

    duration = pulseIn (echoPIN, HIGH);
    distance = duration * 0.034 / 2;

    Serial.println (distance);
}

void loop() {
    getDistance ();  //I tried putting the code directly in the loop function with the same result
}

I am afraid that I broke either a part of the Arduino board or the sensor when I was fiddling around with the two batteries.  Is it possible to break a HCSR04 sensor by connecting two much voltage to the VCC pin on the sensor?  If so, how should I prevent this in the future?  I know that the working voltage for a HCSR04 is 5V, does this mean it needs at least 5V or no more than 5V?  I wanted to know for sure that it was broken and not an error on my part before I bought a new one.    Thanks in advance!