texts:
My ATTiny85 is connected to a 433 transmitter and an analog sound sensor. The 433 is working fine (using VirtualWire) but when I send the reading from the sensor all I receive is a 1.

What I would like to receive is the value between 0 and 1024 like when I print the sensor to serial. I cannot check it because the ATTiny85 had no serial out.

My code is a combination of snippets I found online, I am not happy with all the magic to format the data that needs sending. I would also like to send "Reading: 637" in stead of just the number but I find the concatenation Google results extremely complicated.

Should this code send the sensor data like 672?
Could there maybe be some Fuse setting blocking the AnalogRead?

#include <VirtualWire.h>

const int transmit_pin = PB0;
const int sensor_pin = PB4;
int sensor_data;
char sensor_msg[4];

void setup()
{
  vw_set_tx_pin(transmit_pin);
  vw_setup(2000);
}

int count = 1;

void loop()
{

  sensor_data = analogRead(sensor_pin);
  itoa(sensor_data,sensor_msg,4);
  vw_send((uint8_t *)sensor_msg, strlen(sensor_msg));
  vw_wait_tx(); // Wait until the whole message is gone
  _delay_ms(1000);
  count = count + 1;

}

Receiver Code as requested
This is a Pro Mini (clone) and it has an LCD attached so I can see what is going on.

#include <VirtualWire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);

const int receive_pin = 11;
char* testje;
void setup()
{
    delay(1000);
    Serial.begin(9600); // Debugging only
    Serial.println("setup");

    // Initialise the IO and ISR
    vw_set_rx_pin(receive_pin);
    vw_setup(2000);  // Bits per sec

    vw_rx_start();       // Start the receiver PLL running

    lcd.init();
    lcd.backlight();
    lcd.home();
    lcd.clear();
    lcd.print("hello");
    delay(1000);
    lcd.clear();
}

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

  if (vw_get_message(buf, &buflen)) {
    int i;
    // Message with a good checksum received, print it.
    Serial.print("Got: ");

    for (i = 0; i < buflen; i++) {
       Serial.print((char)buf[i]);
    }
    Serial.println();
    Serial.println(buf);
    lcd.clear();
    lcd.print(buf);
  }
}


texts:
I have an UNIX Timestamp in my Arduino Sketch and would like to get the day of the week of this timestamp (1-7).

How can I convert the timestamp to get the day of the week?


texts: Digital Vibration sensor on NodeMCU ESP8266

texts:
First Post.

I'm using a NodeMCU esp8266 connected to a digital vibration sensor. My project is to detect when a pager vibrates to then trigger through the maker channel of ifttt an outcome.

I'm following this project as my base, hoping to adapt it ever so slightly, but the more I adapt the code the less it seems to work. https://blog.erindachtler.me/tutorial-a-wifi-enabled-washing-machine/

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

#define WIFI_SSID "wifissid"
#define WIFI_KEY "wifikey"

#define NOTIFY_URL
"https://maker.ifttt.com/trigger/myproject/with/key/mykey"

int vibration = 16; //vibration sensor
int LedPin =4; //built in led
int numberofshouts = 0;
int vibrationstate = 0;
int lastvibrationstate = 0;

void setup() {
pinMode(vibration, INPUT);
pinMode(LedPin, OUTPUT);
Serial.begin(9600);

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

WiFi.begin(WIFI_SSID, WIFI_KEY);

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

// Start the server
Serial.println("Server started");

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

}

void loop() {
// put your main code here, to run repeatedly:
int vibrationvalue = digitalRead(vibration);

if (vibrationvalue == HIGH)  {
  Serial.print("Vibration");
  sendDoneNotification();
}

else {
digitalWrite(LedPin, LOW);
}

}

void sendDoneNotification() {
WiFi.begin(WIFI_SSID, WIFI_KEY);

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

HTTPClient http;
http.begin(NOTIFY_URL);
int httpCode = http.GET();
if(httpCode > 0) {
// HTTP header has been send and Server response header has been handled
Serial.printf("[HTTP] GET... code: %d\n", httpCode);

// file found at server
if(httpCode == HTTP_CODE_OK) {
  String payload = http.getString();
  Serial.println(payload);
}
} else {
  Serial.printf("[HTTP] GET... failed, error: %s\n",
http.errorToString(httpCode).c_str());
}
http.end();

 WiFi.disconnect();
 }

What happens is my serial just reports

[HTTP] GET... failed, error: connection refused

I don't quite get the post commands.
I basically want it to read the vibration sensor and while it's reporting no movement do nothing, but after it detects vibration for a couple of seconds it then sends the post command to the maker url that will trigger my ifttt command, thus notifying me on my phone etc.

I have created and run a serial print program to test the sensor and adjust the sensitivity so I know the sensor is working.
My NodeMCU doesn't have a D1 pin so i have it connected to D0, not sure if this is correct or not.

Any tips or advice if there is an easier way of doing this.

Many thanks and have a nice day.

Adrian.


texts: Sending 4 analog values from one arduino to another with I2C

texts:
I have modded a cheap drone controller to output its joystick values to an Arduino Nano.
I made it to output its 4 pot values using I2C to another Arduino don't ask why. So my problem is that I need to send 4 values but I can send only 1. Help me please.
I don't have a time limit or something so I don't need this quick or now!
I am also using a 16x2 LCD without I2C to show the live values and sometime I want to make a menu there or stuff like that.
I would like if you wrote the code for me but its ok if you cant. Also I'm kind of a noob at arduino programming.
Master(a.k.a the nano in the controller):
int pot1 = A0;
int pot2 = A1;
int pot3 = A2;
int pot4 = A3;

int potValue1 = 0;
int potValue2 = 0;
int potValue3 = 0;
int potValue4 = 0;

int led = 10;
int button = 8;

int lastButtonState;    // the previous state of button
int currentButtonState; // the current state of button

int output1 = A4;
int output2 = A5;
int output3 = A6;
int output4 = A7;

#include <Wire.h>
#include <LiquidCrystal.h> // includes the LiquidCrystal Library

LiquidCrystal lcd(2, 3, 4, 5, 6, 7); // Creates an LC object. Parameters: (rs, enable, d4, d5, d6, d7)

#define SLAVE_ADDR 9

void setup() {
  pinMode(led, OUTPUT);
  pinMode(button, INPUT_PULLUP);

  // Open serial communications and wait for port to open:
  Wire.begin();

  lcd.begin(16, 2);
  lcd.print("   ArduinoTX");
  digitalWrite(led, HIGH);
  delay(600);
  digitalWrite(led, LOW);
  delay(600);
  digitalWrite(led, HIGH);
  delay(600);
  digitalWrite(led, LOW);
  delay(600);
  digitalWrite(led, HIGH);
  delay(600);
  delay(3000);
  lcd.clear();
}

void loop() {
  currentButtonState = digitalRead(button);
  potValue1 = analogRead(pot1);
  potValue2 = analogRead(pot2);
  potValue3 = analogRead(pot3);
  potValue4 = analogRead(pot4);

  int sendValue = map(potValue4, 1, 1023, 1, 255);  //converting to values 255 max
  int sendValue2 = map(potValue3, 1, 1023, 1, 255);
  int sendValue3 = map(potValue2, 1, 1023, 1, 255);
  int sendValue4 = map(potValue1, 1, 1023, 1, 255);

  Wire.beginTransmission(SLAVE_ADDR); //sending only one pot value
  Wire.write(sendValue);
  Wire.endTransmission();

  lastButtonState  = currentButtonState;      // save the last state
  currentButtonState = digitalRead(button); // read new state

  if (lastButtonState == LOW && currentButtonState == LOW) { //dont worry about this
    lcd.print(potValue4);
    lcd.print("        ");
    lcd.print(potValue2);
    delay(delayTime);
    lcd.clear();
    lcd.setCursor(0, 2);
    lcd.print(potValue3);
    lcd.print("        ");
    lcd.print(potValue1);
    delay(delayTime);
    lcd.clear();
  }
}

Slave(or an uno who receives the values):
int rd;
int br;

#include <Wire.h>

#define SLAVE_ADDR 9

void setup() {
  // put your setup code here, to run once:
  Wire.begin(SLAVE_ADDR);

  // Function to run when data received from master
  Wire.onReceive(receiveEvent);

  // Setup Serial Monitor
  Serial.begin(9600);
}

void receiveEvent() {
  // read one character from the I2C
  rd = Wire.read();
  Serial.println(rd);
}

void loop() {
  delay(50);
}

Thanks!


texts: Best way to read CSV from SD card and store values by date

texts:
I am starting a project in Arduino and I need to read data from an CSV stored in an SD card. The data is stored as the following:

id, value, date

What I want to do is read the file, filter by date and then store the values by id. Each id will correspond to different values from that same date.

Is it possible to do something like this?

Thank you very much for your advice.


texts:
Sometimes the arduino locks up for some reason. It would be nice to know why, but the problem is more general. I have found a hardware keep alive that resets the controller if it doesn't respond:
Arduino Keep Alive with AT-Tiny
This would work, but i wonder if there are there features like this built in to any of the processors that can be used in the Arduino environment (ESP8266, ESP32, or the like).
Maybe folks know of a processor with the "Keep Alive" feature?
How would i determine if this "keep alive" feature is present for a specific processor?
Thanks for any suggestions!
Mark


texts: Why is the Arduino IDE ignoring my replacement start up code?

texts:
I am trying to replace the standard startup code to save flash space.

I've put the new startup.s in my core directory and added the -nostartfiles parameter to the linker reciepe in my platform.txt.

When I compile with the IDE, it does not include my start code at all.

When I use Atmel Studio or a makefile, the code assembles and is included just fine.

How can I get the Arduino IDE to use my new start up code?


texts: How can I use stepper for specific degree?

texts:
I use Arduino and I'm beginner. I use the code below, but I don't understand what stepper.step(num) and STEPS in Stepper stepper(STEPS, 2,3,4,5) are, and I want to use stepper for specific degree and I don't know what I can do. for example if I want to use stepper for 40 degree what are STEP and num?

#include <Stepper.h>

// change this to the number of steps on your motor
#define STEPS 100

// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 2,3,4,5);

// the previous reading from the analog input
int previous = 0;

void setup()
{
  // set the speed of the motor to 30 RPMs
  stepper.setSpeed(100);
}

void loop()
{
  // get the sensor value
  //int val = analogRead(0);

  // move a number of steps equal to the change in the
  // sensor reading
  //stepper.step(val - previous);
  stepper.step(25);
  delay(1000000);
 // stepper.step(-5);

  // remember the previous value of the sensor
  //previous = val;
}

-----------------------------------------EDIT #2-----------------------------
my stepper is the first one in this link:
https://grahamwideman.wikispaces.com/file/view/28byj48_models_table.jpg/538898220/604x265/28byj48_models_table.jpg
( I think! )
and I don't know what it means?
------------------------------------------EDIT #3----------------------------
Thank you very much, I saw the link.

  Step Angle (8-Step sequence: Internal Motor alone): 5.625° (64 steps
  per revolution)

and I run this code for 45deg :

#include <Stepper.h>

#define STEPS_PER_MOTOR_REVOLUTION 32
#define STEPS_PER_OUTPUT_REVOLUTION 32 * 64  //2048
Stepper small_stepper(STEPS_PER_MOTOR_REVOLUTION, 2, 3, 4, 5);

int  Steps2Take;

void setup()
{

}

void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{

  Steps2Take  =  STEPS_PER_OUTPUT_REVOLUTION / 8.11;
  small_stepper.setSpeed(100);
  small_stepper.step(Steps2Take);
  delay(10000);
}

because I understand each turn has 2048 steps, for example if I want to have 1/2 turn, I have to have num=1024 ( 2048/2). ok, So, for 45deg, it's 1/8 turn so I have to set num=2048/8. but for example for 33 deg what should I do?
I thought num= 33*5.61
so for 45deg I use num=45*5.61
you know we have a lot of floating point and I'm not sure we do it correct. right? I'm a little confused.


texts:
I want to publish sensor data to server using MQTT protocol via GPRS/GSM modem.

I googled MQTT for Arduino, AQTT Arduino available only for Ethernet shield or will MQTT Arduino Ethernet shield work in GSM modem?


texts: I need a circuit or something to power up IR leds as arduino only give 5v and IR leds needs 1.2V. Is there a way to make one arduino pin a power supply of 1.2 V code or something ?


texts: arduino due-Python interfacing for high speed data rate

texts:
Four our project, I want to send data mesured by an Arduino due to a computer via Pyton very vast. So I tried to make a simple benchmark by sending 10240 int datas to determine the time it take. In order to do this, I first try using the programming port and execute this simple script:

int i=1;
int maxv=10240;
int value[10240];
int deb, fin;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(250000); //serial initialisation
  for (i=0 ; i<maxv ; i++){
    value[i]=i;
  }
  delay(200);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("starti"); //flag
  deb=micros();
  for (i=0 ; i<maxv ; i++) { // sending loop
      Serial.println(value[i]);
  }
  fin=micros();
  Serial.println("stopi");
  Serial.println((fin-deb)/1000000.0);
  delay(2000); //waiting
}

So with this I can mesure the time it take to send all the datas. And I receive it with this Python's script:

import numpy as np
import serial
ser = serial.Serial('/dev/ttyACM0', 250000)

value=np.empty(10240)

temp=ser.readline()

while temp!='starti\r\n': #search for the flag
    temp=ser.readline()

for j in range(10240):
    value[j]=int(ser.readline())

ser.readline()

time=float(ser.readline())
print time

with this beaudrate, it take nearly 2.4s which too slow for my purpose. If  try another baudrate, 500000 for example I read data like this : �Ë$Pd@s`¥š... I have this for all baudrate higher than 250000.

So I tried the native port which normaly send the data as fast as he can, but we this it took nearly 1.3s, and it's again too slow for my purpose.

I checked that it is not python wich is too slow, by doing the same than in the last example:

import time
import numpy as np

value=np.empty(10240)

deb1 = time.clock()

for j in range(10240):
    value[j]=j

fin1= time.clock()
print fin1-deb1

and it took only 4ms. So is it clearly the arduino wich send the data to slowly.

So how can I increase the data flux? I have seen the serial.write(buf,len) function which seems does not convert the data into ascii caracters. Does this function will be faster by putting the correct arguments? And, if it's the cas, how can I read this with Python?


texts:
I have some questions when it comes to draining batteries with low power projects.

I have been making a few low power projects with Arduino Pro Minis running on batteries. Some run on single non-recharchable CR123As while others run on two or three recharchable AAAs. I have removed the regulator and the power led on the Pro Minis, and I have changed the fuses making them run as low as 1.8v (or according to my measurements 1.7v). This way they consume a few µA and should be able to run for years on those batteries.

Now, what started to concern me is that this setup will be able to run the batteries very low. According to the voltage curve of a CR123A, it will be practically drained when reaching 1.7v. The same goes for two or three recharchable NiMH AAAs, that will have an individual voltage of 0.85v or 0.55v. Unless the batteries themselves have a discharge protection built in. In that case there might be no problem at all; I just don't know if batteries such as Eneloops have that.

So my questions are:

1) Do batteries such as CR123As and Eneloops have built in discharge protection so that they stop supplying power when the voltage is too low?

2) If no, will draining a non-rechargable CR123A be dangerous or problematic in any way? And will draining MiMHs down to 0.85v/0.55v hurt the batteries?

3) And, a question that I suppose applies to any battery powered Arduino project: When the supplied voltage drops below the Pro Minis BOD limit, will the Arduino stop using any power, or will it continue draining the batteries until they are completely empty? (In the first case I guess I could stick with the factory set BOD at 2.7v to protect the batteries.)

4) Finally, relating to the first question: Should I try to construct some kind of battery protection in the circuit, or is unnecessary when using CR123A and NiMH batteries?


texts: Attempts with Sainsmart Motor Shield Not Working

texts:
I received the sainsmart motor controller a few days ago, and am now having trouble testing it. The Arduino I am using is an Arduino Mega 2560. I thought it was an I2C communication issue but that wasn't working. So here I am now asking for help.
Here is my wiring.

Here is my code:

#include <AFMotor.h>

AF_DCMotor motor(2);

void setup() {
 Serial.begin(9600);           // set up Serial library at 9600 bps
 Serial.println("Motor test!");

 // turn on motor
 motor.setSpeed(200);

 motor.run(RELEASE);
}

void loop() {
 uint8_t i;

 Serial.print("tick");

 motor.run(FORWARD);
 for (i=0; i<255; i++) {
  motor.setSpeed(i);
  delay(10);
 }

 for (i=255; i!=0; i--) {
  motor.setSpeed(i);
  delay(10);
 }

Serial.print("tock");

motor.run(BACKWARD);

 for (i=0; i<255; i++) {
  motor.setSpeed(i);
  delay(10);
 }

for (i=255; i!=0; i--) {
  motor.setSpeed(i);
  delay(10);
 }

Serial.print("tech");
motor.run(RELEASE);
delay(1000);
 }

I also tried this one:

#include<AFMotor.h>
 AF_DCMotor motor2(2);
void setup() {
 // put your setup code here, to run once:
 motor2.setSpeed(255);
}

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

None of the two worked. If someone could help me that would be great. Thank You!!!


texts: Relays just switch ON and OFF on delay(), not on millis()

texts:
I use fuzzy logic for the running time of relays, but the relays just switch ON and OFF at the interval of the delay() I put at the end of loop.
This is my code:
void loop () {
  ph = -180/100.0;
  hasilec = -1.2;
  unsigned long now = millis();

  Serial.print("pH    ");
  Serial.print(ph);
  Serial.print("  ");
  Serial.print("EC ");
  Serial.print(hasilec);
  Serial.println("");
  Serial.print(ph);
  Serial.print(" ");
  Serial.print(hasilec);
  Serial.print(" ");
  Serial.println(" ");

  fuzzy->setInput(2, hasilec);
  fuzzy->setInput(1, ph);
  fuzzy->fuzzify();

  float pompa01 = fuzzy->defuzzify(1); //pHDOWN
  float pompa02 = fuzzy->defuzzify(2); //pHUP
  float pompa03 = fuzzy->defuzzify(3); //ABMIX

  long int pompa1 = pompa01 * 1000;
  long int pompa2 = pompa02 * 1000;
  long int pompa3 = pompa03 * 1000;

  Serial.println("Result= ");
  Serial.println("");
  Serial.print(" Pompa1 pHDOWN: ");
  Serial.println(pompa1);
  Serial.print(" pompa2 phUP  : ");
  Serial.println(pompa2);
  Serial.print(" pompa3 ABMIX : ");
  Serial.println(pompa3);
  Serial.println("");
  Serial.println("");
  Serial.println("");

  pump_periods[0] = pompa1;
  pump_periods[1] = pompa2;
  pump_periods[2] = pompa3;

  for (int i = 0; i < jml_pump; i++) {
    if (now - pump_last_actuations[i] >= pump_periods[i]) {
      pump_states[i] = (pump_states[i] == LOW) ? HIGH : LOW;
      digitalWrite(pump_pins[i], pump_states[i]);
      pump_last_actuations[i] = now;
    }
  }
  delay (20000);
}

The relay just switch ON and OFF on this delay delay (20000);.
What should I do?


texts: How to keep a specific bit set all the time for bit masking I2C operations?

texts:
I've been working on I2C and I learned how to initialize, send and receive with I2C communication protocol.

Next, I wanted to run the LCD1602 I2C adapter. But the module has a different bit masking, it turns out that I have to keep a specific bit set so I can control the remaining 7-bits, because otherwise I can't control the upper 4-bits if this bit is 0.

So, I put the 8-bit variable for the bit masking operations in the global section and initialize it with uint8_T bitmasking = 0x08; but it's volatile. I used static keyword, but the bit is not constant.

So what's the solution?

Regards,


texts: Do I need to power off the Arduino board before doing something?

texts:
Is it safe to build a circuit while the Arduino board is powered?

Should I power the board only when I have to upload the program?


texts: Graph plotting on Processing from Arduino sensor data

texts:
I am trying to plot a graph on processing but I'm having challenges going about it. The processing sketch below does work for plotting only one axis, and I'm trying to plot all three axis on the same sketch. Does anyone have an idea on how I could go about it. Below are the Arduino and Processing sketches.

Arduino

AcceleroMMA7361 ski;
int x;
int y;
int z;

void setup()
{
   Serial.begin(115200);
   ski.begin(13, 12,11,10, A0, A1, A2);
   ski.setARefVoltage(3.3);
   ski.setSensitivity(HIGH);
   ski.calibrate();
}

void loop()
{
    x = ski.getXRaw();
    y = ski.getYRaw();
    z = ski.getZRaw();
   //Serial.print("\nx: ");
     Serial.println(x);
   //Serial.print("\ty: ");
   //Serial.print(y);
   //Serial.print("\tz: ");
   //Serial.print(z);
   delay(10);                                     //(make it readable)
}//End of Arduino Sketch

Processing

import processing.serial.*;

Serial myPort;        // The serial port
int xPos = 1;         // horizontal position of the graph

float fValue;
boolean newVal = false;

void setup () {
   size(800, 630);
   println(Serial.list());
   myPort = new Serial(this, Serial.list()[0], 115200);
   myPort.bufferUntil('\n');
   background(2);
   stroke(127, 34, 255);
}

void draw () {
    if (newVal) {
       line(xPos, height, xPos, height - fValue);
       if (++xPos >= width) {
         xPos = 0;
         background(2);
       }
       newVal = false;
    }
}

void serialEvent (Serial myPort) {
   String inString = myPort.readStringUntil('\n');
   if (inString != null) {
       inString = trim(inString);
       fValue = float(inString);
       fValue = map(fValue, 0, 1023, 0, height);
       newVal = true;
     }
}


texts:
I want to use Seeeduino, but I can't activate port connection for it.

To use Seeduino I installed Seeeduino from Board Manager in Arduino Studio.

And then installed USB Serial Driver from this binary.

http://www.ftdichip.com/Drivers/VCP/MacOSX/FTDIUSBSerialDriver_v2_4_2.dmg

But somehow there is no corresponding port in Tools -> Port.
How can I activate the port?


texts: Emergency Vehicle - Make two LEDs flash with buttons and a passive buzzer change sound

texts:
My Dad and I are just learning how to use my new UNO.

We have learned how to make leds flash at the touch of a button. We have also learned how to make a passive buzzer sound at the touch of a button and change tone to sound like a police car.

We have just learned that we cant run more than one loop so we have combined the buzzer code and the LED code twice (for blue and red LEDs) and it works... but the delay on the LEDs is ruining the buzzer sound. Is there anything we can do?

The code is below.

Thank you!

Code:

int buzzerPin = 9;    // the number of the buzzer pin
int BlueLEDpin = 5;   // the number of the blue LED pin
int RedLEDpin = 7;    // the number of the Red LED pin
float sinVal;         // Define a variable to save sine value for buzzer
int toneVal;          // Define a variable to save sound frequency for buzzer

void setup() {
  pinMode(buzzerPin, OUTPUT); // Set Buzzer pin to output mode
  pinMode(BlueLEDpin, OUTPUT); // Set Blue LED pin to output mode
  pinMode(RedLEDpin, OUTPUT); // Set Red LED pin to output mode
}

void loop() {
    Buzzer();
    BlueLED();
    RedLED();

}

void Buzzer() {
  for (int x = 0; x < 360; x++) {       // X from 0 degree->360 degree
    sinVal = sin(x * (PI / 180));       // Calculate the sine of x
    toneVal = 2000 + sinVal * 500;      // Calculate sound frequency according to the sine of x
    tone(buzzerPin, toneVal);           // Output sound frequency to buzzerPin
    delay(1);
  }

 }

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

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


texts: Ethernet.begin() conflicts with build-in LED on Arduino Nano

texts:
I have Arduino Nano "clone" which I would like to use with Ethernet ENC28J60 shield. I have noticed that when I include/use UIPEthernet.h library, build-in LED does not work properly. I have written the following sketch which I have uploaded to Arduino and run both with and without Ethernet shield with the same result: LED is not blinking. Once I comment out the line Ethernet.begin(mac), LED starts blinking just fine.

Is there any way to overcome this conflict?

#include <UIPEthernet.h>

EthernetClient ethClient;

uint8_t mac[6] = { 0x90, 0xA2, 0xDA, 0x0D, 0xE2, 0xCD };

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

  // If this line is commented, LED starts blinking:
  Ethernet.begin(mac);

  pinMode(LED_BUILTIN, OUTPUT);

  Serial.println(F("setup() done."));
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);
}


texts: Have Arduino write data to a MySQL database?

texts:
Would it be possible to have an Arduino write directly to a MySQL database?

I'm a web programmer, so I'm familiar with how to get records from a MySQL database. I have MAMP installed on my mac, so I have the ability to build an interface, directly in the web browser, that retrives the records from a MySQL database.

What I'm thinking is to connect the Arduino directly to my computer via USB, and write data from the sensors, or the pins, directly to my MySQL database.

I'm using two phototransistor to record whenever something blocks the light. Each sensor records individually a timestamp for when the blocking occur.

Is that possible?


texts: Control RGB led using microphones, getting the right components

texts:
Sorry if this is too basic, but I am very new to arduino and electronics. I come from programming, I am trying to start a project where I can control an RGB led strip, I want to be able to control the light intensity and color of the light strip (something like this), using a microphone.

My goal is for frequency to control de color of the rgb light and the dB (Volume) to control the light intensity. I have found several microphones such as this ones. Can I get both frequency and dB input from this microphones?

Would I need some extra controllers for this project? Again I am very new with this, sorry by the basic questions.


texts:
Hello I have a problem with my nano arduino and the nrf24l01 as receiver . I'm trying to upload my code to my board, but it say that my code have this mistake:

Receiver:45:10: error: void value not ignored as it ought to be

exit status 1
void value not ignored as it ought to be

the complet code is:

#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>

//Receiver Code (Hand)

#include <Servo.h>    //the library which helps us to control the servo motor
#include <SPI.h>      //the communication interface with the modem
#include "RF24.h"     //the library which helps us to control the radio modem

//define the servo name
Servo myServo1;
Servo myServo3;
Servo myServo4;
Servo myServo2;
Servo myServo5;

RF24 radio(9,10);     /*This object represents a modem connected to the Arduino.
                      Arguments 9 and 10 are a digital pin numbers to which signals
                      CE and CSN are connected.*/

const uint64_t pipe = 0xE8E8F0F0E1LL; //the address of the modem,that will receive data from the Arduino.

int msg[5];

void setup(){

  //define the servo input pins
  myServo1.attach(15); //A1
  myServo2.attach(16); //A2
  myServo3.attach(17); //A3
  myServo4.attach(18); //A4
  myServo5.attach(19); //A5

  radio.begin();                    //it activates the modem.
  radio.openReadingPipe(1, pipe);   //determines the address of our modem which receive data.
  radio.startListening();           //enable receiving data via modem
  }

void loop(){
  if(radio.available()){
    bool done = false;
    while (!done){
    done = radio.read(msg, sizeof(msg));

    myServo1.write(msg[2]); //A1
    myServo2.write(msg[4]); //A2
    myServo3.write(msg[3]); //A3
    myServo4.write(msg[1]); //A4
    myServo5.write(msg[0]); //A5
    }
  }
}

and the problen is here:

done = radio.read(msg, sizeof(msg));

I don't know hoy to make that comes out as a code. I'm sorry.
I'm trying to program a bionic hand but i have just started to work with arduino boards and their respective prongram. If someone can help me I would be very grateful. thanks


texts:
I am using ESP8266 01 board to send some data via TCP to server on local network. My code is:

#include <ESP8266WiFi.h>

const char* ssid     = "ssid";
const char* password = "pas";

const char* host = "192.168.1.103";

void setup() {
  Serial.begin(115200);
  delay(10);

  // Wifi connection

  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

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

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

   delay(5000);

  Serial.print("connecting to ");
  Serial.println(host);

  // Use WiFiClient class to create TCP connections
  WiFiClient client;
  const int port = 8888;
  if (!client.connect(host, port))
  {
    Serial.println("connection failed");
    return;
  }

}

void loop() {

  while(Serial.available() == 0)
  {
    //wait for arduino serial data
  }

   while(Serial.available())
  {
    // send data to server
    client.print(Serial.read());
  }
}

After chacking code in Arduino IDE I am getting error message:

In function 'void loop()':
espwifitcp1:57: error: 'client' was not declared in this scope
     client.print(Serial.read());
     ^
exit status 1
'client' was not declared in this scope

It appears that if I declare WiFiClient client; inside setup() function it can't be accessed outside it. Do I correctly understand the problem? I have tried to declare object outside setup() and loop() functions but it got even more errors. Any suggestions?


texts: How do I pull chip select pin up and down, when I have CAN shield and Newhaven Display 4.3CTP-SHIELD-N share the same chip select pin(10)?

texts:
I am currently working on an Arduino project, which must be able to listen to the data going through CAN bus and display it on the Touchscreen LCD Newhaven Display 4.3CTP-SHIELD-N.

Problem is that Sparkfun CAN shield and the LCD shield share the same chip select (CS/SS) pin 10. I've tried changing the chip select of the CAN shield by changing values in library headers, but it did not work and now I think that I should pull pin 10 low, when executing CAN code, then pull it up for the CAN shield. Afterwards, do the same for the LCD shield, but I do not know how to write the code for that. Is this the right way to think about the problem or am I missing something?

At this point, I am very confused because some people say that, if two shields have same chip select pin, it's impossible to stack them. Others claim that they succeeded in stacking two shields like that.

What other methods are there for stacking two shields with the same chip select pin?

I am using this CAN library: https://github.com/sandeepmistry/arduino-CAN/blob/master/API.md

This LCD library: https://github.com/NewhavenDisplay/FTDI_FT801


texts: What should I do to communicate with GSM module?

texts:
Sorry, im a beginner, i tried to program an automatic doorlock using sms. But, I dont understand what happen with this error, what should I do? Add library? The error said that Pstring wasnt declared, but i dont know how to declare this.

#include <LiquidCrystal.h>
#include "SIM900.h"
#include "sms.h"
#include "SoftwareSerial.h"
#include "sms.h"

SMSGSM sms;
boolean started=false;
char buffer[160];
char smsbuffer[160];
char n[20];
int pintu=5;
int buttonState;
int lastButtonState = LOW;
long lastDebounceTime = 0;
long debounceDelay = 50;
boolean st=false;
int buzzer=6;

void setup()
{
  pinMode(pintu,OUTPUT);
  pinMode(buzzer,OUTPUT);

  digitalWrite(pintu,LOW);
 if (gsm.begin(9600))
 {
  started=true;
   digitalWrite(buzzer,HIGH);
   delay(100);
   digitalWrite(buzzer,LOW);
   delay(100);
   digitalWrite(buzzer,HIGH);
   delay(100);
   digitalWrite(buzzer,LOW);
   delay(100);
   digitalWrite(buzzer,HIGH);
   delay(100);
   digitalWrite(buzzer,LOW);
   delay(100);
  }
   if(started)
  {
   delsms();
   sms.SendSMS("08970869443","Pintu SMS Menyala");
  }
  else{digitalWrite(buzzer,HIGH); delay(2000); digitalWrite(buzzer,LOW);
  }

   }

   void loop()
   {

   int pos=0;
  if (gsm.begin(9600))
  {
  if (started){
  pos=sms.IsSMSPresent(SMS_ALL);
  if(pos)
  {
   sms.GetSMS(pos,n,smsbuffer,100);
   delay(2000);
    if(!strcmp(smsbuffer,"bukapintu"))
    {
      PString str(buffer, sizeof(buffer));
    str.begin();
    str.print("Pintu Dibuka");
    digitalWrite(pintu,HIGH);
   // String a=str
    sms.SendSMS(n,buffer);
    }
    if(!strcmp(smsbuffer,"tutuppintu"))
    {
      PString str(buffer, sizeof(buffer));
    str.begin();
    str.print("Kunci Pintu Ditutup");
    digitalWrite(pintu,LOW);
   // String a=str
    sms.SendSMS(n,buffer);
    }
    delsms();
   }
   }
   }
   }

   void delsms()
   {
   for (int i=0; i<10; i++)
  {
     int pos=sms.IsSMSPresent(SMS_ALL);
    if (pos!=0)
   {
    if (sms.DeleteSMS(pos)==1){}else{}
   }
   }
   }

Error message :

     Arduino: 1.6.7 (Windows 10), Board: "Arduino/Genuino Uno"

      D:\Kuliah\Project\Skripsi\pintu_sms\pintu_sms.ino: In function 'void loop()':

      pintu_sms:67: error: 'PString' was not declared in this scope

       PString str(buffer, sizeof(buffer));

       ^

      pintu_sms:67: error: expected ';' before 'str'

       PString str(buffer, sizeof(buffer));

               ^

     pintu_sms:68: error: 'str' was not declared in this scope

     str.begin();

     ^

    pintu_sms:76: error: 'PString' was not declared in this scope

       PString str(buffer, sizeof(buffer));

       ^

    pintu_sms:76: error: expected ';' before 'str'

       PString str(buffer, sizeof(buffer));

               ^

     pintu_sms:77: error: 'str' was not declared in this scope

     str.begin();

     ^

     exit status 1
  'PString' was not declared in this scope


texts:
I'm not sure this is right place for this question, but does anyone have any idea how a 7 segment display is projected or embedded in wood for products like this?

Full product info at http://www.amazon.com/Cube-Wood-LED-Alarm-Clock/dp/B00D6DI0LE

Another example:

From: http://www.selectism.com/2013/11/27/a-wooden-led-alarm-clock-and-wireless-bluetooth-speaker-from-gogroove/


texts: Cannot connect through /dev/ttyACM0 (Ubuntu 18.04)

texts:
I am using an Arduino UNO which worked fine until today. My system: Ubuntu 18.04

Now, the IDE can no longer connect to it:

Cannot do any sketch upload
Cannot ask for board info
No USB ports shown in tools --> port (only 2 serial ports shown)
ttyyACM0 not showing up in /dev

However, both lsusb and dmesg show that the board is recognized somehow.

lsusb output:

Bus 001 Device 012: ID 03eb:2fef Atmel Corp.

dmesg output:

[ 2922.171042] usb 1-1.3: new full-speed USB device number 12 using ehci-pci
[ 2922.282047] usb 1-1.3: New USB device found, idVendor=03eb, idProduct=2fef
[ 2922.282052] usb 1-1.3: New USB device strings: Mfr=0, Product=1, SerialNumber=0

The problem is the same on 2 different computers, which leads me to suspect that there is something wrong with the board. Is it possible that a board be shown by both dmesg and lsusb and still be malfunctioning ?


texts: How do I find names of components I don't know?

texts: I recently started with Arduino and I have my starter kit. However, there are some strange looking components I can't recognize. Is there some way to find out the names of these components?


texts: ArduinoJSON v6 - return a StaticJsonDocument from a function

texts:
I'm reading a stored JSON file from an ESP8266. I wish to return it as a StaticJsonDocument for further use.

return it at the end of function was done OK, but I need to assign it for document.

#include <ArduinoJson.h>
#include "FS.h"
#define filename "file.json"

StaticJsonDocument<200> doc;

void createJSON() {
        doc["sensor"] = "gps";
        doc["time"] = 1351824120;

        JsonArray data = doc.createNestedArray("data");
        data.add(48.756080);
        data.add(2.302038);
}

StaticJsonDocument<512> readJSON_file(){
        StaticJsonDocument<512> read_doc;
        File readFile = SPIFFS.open(filename, "r");
        DeserializationError error = deserializeJson(read_doc, readFile);
        if (error)
                Serial.println(F("Failed to read file, using default configuration"));

        serializeJson(read_doc, Serial);

        return read_doc;
}

void setup() {
        Serial.begin(9600);
        if (!SPIFFS.begin()) {
                Serial.println("Failed to mount file system");
        }

serializeJsonPretty(readJSON_file(),Serial);
}

void loop() {
        // not used in this example
}


texts:
This is my code:

const int trigPin = 4;
const int echoPin = 2;
const int trigPin2 = 6;
int incomingByte;
int val, val2;
const int echoPin2 = 7;

void setup() {
  // initialize serial communication:
  Serial.begin(9600);
}

void loop() {
  pinMode(trigPin, OUTPUT);
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  pinMode(trigPin2, OUTPUT);
  digitalWrite(trigPin2, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin2, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin2, LOW);

  pinMode(echoPin, INPUT);
  pinMode(echoPin2, INPUT);

  val = digitalRead(echoPin);
  val2 = digitalRead(echoPin2);

  if (val && val2 == HIGH) {
    Serial.println("Elephant on tracks");
  }

  if (Serial.available() > 0) {  // if the data came
    incomingByte = Serial.read();
  }
  // read byte
  if(incomingByte == '0') {
     digitalWrite(trigPin, LOW);
     digitalWrite(trigPin2, LOW);
     Serial.println("The system is OFF.");  // print message
  }
}

Anyhow, I click upload, and as the title of this question says, have to wait forever.
Not only this code, nothing gets uploaded. It was working just fine a week ago.
I run a Windows 7 64-bit system, and have an Arduino Uno R3.
Does anyone have any suggestions?


texts: Arduino Nano periodic reset under program control?

texts:
Is there a way to cause a periodic reset of an Arduino Nano under program control, short of some kind of external relay that signals the RST pin?

I'd like to do a full reset triggered by a digital write.

When the power is applied to the Nano it automatically pulls all the digital output pins to LOW so it appears that simply connecting a wire from a digital output to the RST pin would cause the system to continually reset and never run the program.  This would apply equally to using the DS3231 RTC chip's alarm function.  It would require the program to run in order to use it.

I suppose a relay would do the trick.  Or maybe even just an inverter chip like the 7404 between a digital output and the RST pin.  I am trying to fit this all in a small box so more hardware gets to be a problem.

So the question:  Is there any way to do this without external hardware?


texts: My DS18B20 is reading high. How can I get it to return the correct temperature?

texts:
I am working on a heating control system for my home, but having problems with the temperature sensor reading higher than I expect.

I have a 5V Arduino Mini Pro clone hooked up to a relay module, an HD47780 display and a Tiny RTC module, with a DS18B20 attached to it.

The DS18B20 is powered from the 5v Vcc applied to the Tiny RTC module rather than using parasitic power on the DQ line (as I wasn't sure if the Onewire libraries supported this mode of operation) and the DS18B20 datasheet says that Vcc may be between 3.0v and 5.5v. I measured the regulated power from the Mini Pro's  being at 5.2v.

I am comparing the temperature from the DS with the existing room thermostat (bi-metallic), an RS desktop temperature monitor with two sensors, a small 'thermo-hygrometer' and a bi-metallic fridge thermometer (in the upper quarter of its temperature range)†. The readout from the DS is always around 1-2 degrees higher than the readout from the other sensors, which are within a degree of each other.

† Not the actual one, but something similar.

Reading various forums I have heard that these sensors are quite accurate but can suffer from localised heating from components near them, so I moved the sensor onto a 20cm cable and positioned it well away from the rest of the electronics. This made no difference.

I then read that the DS can become self heating if it is supplied with too high a Vcc voltage, so I added a Red LED with 1.7v drop and measured the new voltage over the DS as 3.5v, but again, after waiting for the temperatures to stabilise once more, this made no difference.

Can anyone suggest why the DS may be reading high and what I can can do to prevent this?


texts: Running Pro Mini Continuous on 12v w/o Damaging Regulator

texts:
A Pro Mini needs to be placed in a 100mmx50mmx25mm, no holes but not air tight ABS plastic enclosure, with a 12v power supply connected to the raw input. It will be consuming max 40mA, ambient temperature 30-32C, and needs to be run 24/7. Upon prototyping in open air, I tried to touch the regulator MIC5205, after 30 seconds upon powering on with my bare fingers and it was too hot to touch. The rest of the components were cool to touch. I would use a buck converter to step down to 5v, however there isn't space for it in the current setup.

I used to run a Mega 24/7 on 12v, consuming much more current about 700mA, the onboard regulator malfunctioned after 1 year of use, which I believe was due to the excessive heat, as the PCB around the regulator turned a little brownish.

Despite being hot to touch, I understand that electronics run in heat all the time like computers, routers, etc for 24/7. Therefore, I would like to know if 12vx0.04A=0.48w will be too much heat/feasible to run in the above mentioned setup, without damaging the regulator in the long run?


texts: How can Arduino know that the number in a variable is a pin number and not something else?

texts:
I have a question with the topic variables.

So, a variable is a place where you can store data.

And when you make a variable with datatype int (int ledpin=13;) then you store a value 10 in a variable named ledpin.

BUT how can the Arduino know it's a pin number 13 from Arduino or a random number 13 that we are storing there?


texts: Communication between two arduinos over wifi esp8266

texts: I have two arduinos one is Arduino Mega while other is Arduino UNO and I want to send data from UNO to Mega and vice versa over wifi using two ESP8266 wifi modules without use of any router in between, so what is the simplest procedure I can use to do this? Moreover how can I do this with a router in between?


texts: Pro Micro recognised as Micro (win10, IDE 1.8.1)

texts:
I just got this pro-micro clone 5V and it's my first pro micro ever. After reading lots of discussions about how easy it is to brick and how it's just a smaller Leonardo, I've also found tutorials where they guide you to install custom things (sprkfun) to recognise the board, and others where it shows up as a Leonardo board.

However in my case I just plugged it in my Win10 laptop, the drivers got installed and it is automatically recognised as an Arduino Micro.
Since I haven't found people having this, and since I'd like not to brick it immediately I was wondering what's the procedure between:

follow sparkfun's guide for pro micro and install their custom
drivers
treat it as a Leonardo (in the IDE)
treat it as a standard Micro (in the IDE) since it's recognised as such

Thanks!

edit: solution: it's a Leonardo.


texts: Use serial communication on Sparkfun SAMD21 mini board

texts:
I am working on an economic module to be able to use serial communication with the Sparkfun SAMD21 mini development card. And I have one, the DTR (of my CH340G) do I have to connect it to the reset of my MCU? I mean, to reset the board, do I just have to press the reset button on the module or both (the MCU and the USB / UART module)? I enclose the schematic of how I made the small module, if anyone has suggestions or recommendations, I appreciate them.

It occurred to me to review the diagram of the arduino nano, which has the integrated USB / UART bridge, and from what I see, the DTR connects to the reset of the microcontroller and then to the button.
Regards.


texts: What is the difference between a 3 pin and 4 pin ultrasonic range sensor?

texts:
I am following a tutorial that uses an arduino and ultrasonic range sensor, it calls for a 3 pin module (Paralax 28015-ND) and I have a 4 pin module (http://www.electroschematics.com/wp-content/uploads/2013/07/HCSR04-datasheet-version-1.pdf).  The 3 pin seems to have one signal pin (both input and output) and the 4 pin has two separate signal pins (a trigger and echo).  How would I need to change the code and wiring if I am using the 4 pin?  Here is the code from the tutorial:

     /* Ping))) Sensor

   This sketch reads a PING))) ultrasonic rangefinder and returns the
   distance to the closest object in range. To do this, it sends a pulse
   to the sensor to initiate a reading, then listens for a pulse
   to return.  The length of the returning pulse is proportional to
   the distance of the object from the sensor.

   The circuit:
    * +V connection of the PING))) attached to +5V
    * GND connection of the PING))) attached to ground
    * SIG connection of the PING))) attached to digital pin 7

   http://www.arduino.cc/en/Tutorial/Ping

   created 3 Nov 2008
   by David A. Mellis
   modified 30 Aug 2011
   by Tom Igoe
   modified again 02 Apr 2016
   by Randy Sarafan

   This example code is in the public domain.

 */

// this constant won't change.  It's the pin number
// of the sensor's output:
const int pingPin = 4;

void setup() {
  // initialize serial communication:
  Serial.begin(9600);
}

void loop() {
  // establish variables for duration of the ping,
  // and the distance result in inches and centimeters:
  long duration, inches, cm;

  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pingPin, LOW);

  // The same pin is used to read the signal from the PING))): a HIGH
  // pulse whose duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.
  pinMode(pingPin, INPUT);
  duration = pulseIn(pingPin, HIGH);

  // convert the time into a distance
  inches = microsecondsToInches(duration);
  cm = microsecondsToCentimeters(duration);

  Serial.print(inches);
  Serial.print("in, ");
  Serial.print(cm);
  Serial.print("cm");
  Serial.println();


texts: Infrared sensor has a frequency to activate it?

texts:
I am trying to understand 2 sensors that I have here. One says that is "infrared sensor of 38kHz" and the other is "infrared optical reflexive sensor -> http://www.robosoftsystems.co.in/wikidocs/index.php?title=TCRT_5000_Reflective_Optical_Sensor"

I thought that infrared sensor would tell me if an infrared light is passing on it. Infrared light has a wavelenght, right? Can infrared light be emited in different frequencies? Or the frequency of infrared light is the same to all infrared lights?


texts: Adafruit Feather 32u4 BLE compatible with Software SPI?

texts:
Let me preface by saying that I am not super experienced with electronics. I have an Adafruit Feather 32u4 that is using Hardware SPI to communicate over Bluetooth. Unfortunately, I'm also hoping to use the SD library, which also uses Hardware SPI. I am hoping to change the board to use Software SPI instead, so that the two may work together.

The Bluefruit code by default has the following commented out:

/* ...software SPI, using SCK/MOSI/MISO user-defined SPI pins and then user selected CS/IRQ/RST */
Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_SCK, BLUEFRUIT_SPI_MISO,
                             BLUEFRUIT_SPI_MOSI, BLUEFRUIT_SPI_CS,
                             BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);

Which leads me to believe I could use SW SPI but simply uncommenting this and commenting out the HW SPI doesn't seem to work.

I am just not sure if it's not compatible with the board, or I need to do more than this...?


texts:
I have to realize a communication between Arduino Leonardo and a demon which runs on a pc.

The demon has to tell Arduino informations about the operative system of the machine to which it is linked,the dimension of the screen and other things about its state.

As it has to work both on Windows and on MAC OS-X, I thought to write the demon in Java, but I've seen that the library RXTX for communication is hardware dependent, so it can create problems if I use a different machine.

In your opinion shall I use Processing, or there is another way to achieve that?

Thank you in advance.


texts: Is there a away to transmit sensor signal over RF without Arduino?

texts:
I would like to place analog sensor in a place, that is impractical to reach with a wire. But it looks like an overkill to use a separate small Arduino board to read and transmit sensor signal to main Arduino board at a close range (~1 m).

Is there a cheap practical way to setup such sensor signal broadcast over RF without using Arduino board? Something that could work for considerable duration with a small tablet like battery?


texts:
I’d like to protect my arduino make with a unique serial number for every device I make.
What are the proper ways to do it? Probably there are kind of best practices…
Keep it in EEPROM is obviously a bad idea.

I believe that there is some chip that can be added to the circuitry.

The general idea is the following.
Circuitry has a hardware which gives a unique id (serial number). Distributor/seller generates the signature using unique id and put it to the eeprom. Arduino program verifies this signature using hardware serial number. Arduino program is distributed in binary or within the device.


texts: I need to create a library file for Arduino. While surfing the Internet, it shows me to use C, C++. Is a C++/C compiler mandatory to create library files in Arduino? Or we can use the Arduino IDE to create library files?


texts: How can I connect to an Arduino using WiFi?

texts:
I'm working on building a solar powered, Arduino based weather station. The weather station consists of a temperature sensor and a photoresistor, and I plan to add an anemometer in the future. I would like to connect the weather station to my wireless network so that I can retrieve the sensor data from my computer without having to run wires (I live in a rental).

What are the different options for connecting the Arduino to WiFi? I've looked at ethernet shields, WiFi shields, and something called Xbee, but I don't understand what each of them are for.

I also have a wireless home router that I could use. Is it possible to connect my Arduino Uno to the router via the routers ethernet or USB port and then receive data from and send commands to the Arduino wirelessly over my home network? If so, how would this be accomplished?

I currently have a bare Arduino Uno.


texts:
byte RSV_Resp_test[3] = {'a', 'b', 0};
Serial.println(reinterpret_cast<char>(RSV_Resp_test[1]));

produces the error

error: invalid cast from type 'byte {aka unsigned char}' to type 'char'
Serial.println(reinterpret_cast<char>(RSV_Resp_test[1]));
                                                      ^

How can this be an ill-formed cast?  I just need to print the value as a ascii character, not as a number.


texts: Send AT commands to ESP8266 from Arduino Uno via a SoftwareSerial port

texts:
GOAL

From Arduino UNO, send AT commands to ESP8266 via a SoftwareSerial port and receive results.

CURRENT STATUS

I either send AT commands and get nothing back (wiring scheme 1) or I send AT commands and get garbage back (wiring scheme 2).

Using the Arduino as a pass through (as explained in the tutorial listed in the resources section), I can send AT commands. I have found that I can communicate with the ESP8266 at 115200 baud.

This is the results of running AT+GMR:

AT version:0.40.0.0(Aug  8 2015 14:45:58)
SDK version:1.3.0
Ai-Thinker Technology Co.,Ltd.
Build:1.3.0.2 Sep 11 2015 11:48:04

WIRING SCHEME 1

!! I have the green wire attached to pin 3 on the Arduino Uno and the yellow wire attached to pin 2; not 1 and 0 as the picture suggests !!

WIRING SCHEME 2

Same wiring as above, but I have RX and TX reversed. The green wire is attached to pin 2 and the yellow wire is attached to pin 3.

CODE

This is running on Arduino Uno

#include <SoftwareSerial.h>

SoftwareSerial esp8266(2, 3);

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

  Serial.println("Started");

  // set the data rate for the SoftwareSerial port
  esp8266.begin(115200);
  esp8266.write("AT\r\n");
}

void loop() {
  if (esp8266.available()) {
    Serial.write(esp8266.read());
  }
  if (Serial.available()) {
    esp8266.write(Serial.read());
  }
}

RESULTS FROM RUNNING SKETCH

Wiring Scheme 1

Started

Wiring Scheme 2

Started
�����

I have tested the ESP8266 via the instructions listed in the tutorial in the Resources I've Used section below. The ESP8266 works just fine when sending it instructions via the Serial Prompt.

RESOURCES I'VE USED
http://rancidbacon.com/files/kiwicon8/ESP8266_WiFi_Module_Quick_Start_Guide_v_1.0.4.pdf

QUESTION

Does anyone know if what I am trying to do is possible? And if it is, what am I doing wrong?


texts: Multi-drop RS485 device control v1.0 - why is limit for "TIME_BETWEEN_MESSAGES "?

texts:
I am going to use Nick's rolling-master system library (http://www.gammon.com.au/forum/?id=11428) in my home project.

For first experiments and testing, I have:
- BAUD_RATE = 9600
- max adress = 2 (it means max 3 drops)
- 2 active drops with adress=0 and adress=1, 1 intentionally missing drop (simulation    of malfunction one of drops :-))
- TIME_BETWEEN_MESSAGES = 200000
- Packet length = 200 bytes
- Packet time = 208333 microseconds
- Timeout for no messages = 1633332 microseconds
- gap between messages = 200 ms (measured value by oscilloscope).
It work perfect.

I would like to increase the gap between the messages, but after I increased the constant "TIME_BETWEEN_MESSAGES"  from 200000 to 300000, then start bad communication  between the drops:
- TIME_BETWEEN_MESSAGES = 300000
- Packet length = 200 bytes
- Packet time = 208333 microseconds
- Timeout for no messages = 2033332 microseconds
- gap between messages = 2170 ms
Adress first started after reset (for example 1)  broadcasts, but nothing receives from other adress (for example 0), which started later.
Adress 0 receives all messages from adress 1 OK, but nothing transmits (subroutine "sendMessage ()" is never called).
After reseting of broacasting drop with adress  1, it works in reverse (addr 1 only receives, no broadcast, and addr 0 broadcasts).

Why is there limit for "TIME_BETWEEN_MESSAGES" value ? How to increase gap between messages ? For my purpose be enough gap 1 - 2 sec and so drops should have enough time for their own job.

Thanks for advice,
Vava
(Sorry for my English... :-)


texts: Help understanding how avrdude works with ArduinoISP and why its not working for me

texts:
I am trying to use avrdude with a Mega2560 running ArduinoISP

Note: I have the 10uF cap on the Mega2560 RESET line as described by Ardunio.

Also, I am using avrdude/6.3 on Windows 10.  The Mega2560(ArduinoISP) is connected to the PC using an a USB cable - connection is COM8.

I have a couple of tasks I want to do

Update the firmware on my USBASP
Load Arduino boot on ATTINY85 dev board.

I started with Arduino IDE but moved to avrdude to better understand the problem

For #1:
Wired it per https://www.arduino.cc/en/Tutorial/ArduinoISP

AVR-ISP pin     MEGA-ISP pin
6/10 (name)

1/9 (MISO)      50
2/2 (VCC)       VCC
3/7 (SCK)       52
4/1 (MOSI)      51
5/5 (RESET)     53
6/10 (GND)      GND

I tried using the command:

avrdude -c arduino -p m8 -P COM8

I get the error

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xed
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xe0

avrdude done.  Thank you.

--UPDATE-- The error above was caused by not setting the BAUD rate. Now I get:

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.

What I really want to know is more of how this process works so I can better understand it and be able to debug the issues.

Is this an error communicating with the ISP (Arduino) or is it an issue with the ISP talking to the target (ATMega8B on USBAVR)?
What does "stk500" mean?  Is that the programming protocol, the ISP protocol, or something all together different?
Is this all documented somewhere?


texts: I know that I can program Arduino with python but is it possible to make every project, which can be completed by normal IDE?


texts:
I would like to send and receive SMS's with my Arduino project. I have an A6 SIM900A GSM module with me which is from Chinese. However, it does not work and does not accept any AT commands.

So, I have decided to buy a new one. I need a suggestion which is the simplest GSM module or maybe more references I can refer to on Internet.


texts:
Can we use the vin pin of the lolin v3 nodeMCU as a 5V supply. If yes, i checked mine with a multimeter. At max, it gives a voltage of 2V. Is my pin blown out? Also, can use the VU pin as a 5V supply? Will using it cause any problems to my laptop's USB port? Can somebody help me out?

I need 5V to drive a relay using the v3


texts: Why does enabling TIMSK1 mess up serial?

texts:
I am intending to write a code where a user will send lines through serial to affect timer interrupts. I am noticing a problem with serial where as soon as I enable the timer interrupts, the serial communication becomes garbled. More specifically, as soon as I enable the timer interrupts and I open the serial monitor, the monitor gets flooded with garbage. I haven't written too much code and this is already happening. Am I making a silly mistake? I am using an Arduino Mega 2560. My code is below:

void setup() {
  Serial.begin(9600);
  Serial.println("Hello World!");
  timer_setup();
}

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

void timer_setup() {
  // waveform generation = 0100 = CTC
  TCCR1B &= ~(1 << WGM13);
  TCCR1B |=  (1 << WGM12);
  TCCR1A &= ~(1 << WGM11);
  TCCR1A &= ~(1 << WGM10);
  // output mode = 00 (disconnected)
  TCCR1A &= ~(3 << COM1A0);
  TCCR1A &= ~(3 << COM1B0);
  // Set the timer pre-scaler
  TCCR1B = (TCCR1B & ~(0x07 << CS10)) | (2 << CS10);
  OCR1A = 0x4000;
  TCNT1 = 0;
  // Enable timer interrupt mask 1
  TIMSK1 |= (1<<OCIE1A);
}

If I comment out the TIMSK1 |= (1<<OCIE1A) line, serial doesn't mess up.


texts:
I have a code here, from DFmini player. I have a tactile switch. when I press it on and release it will play a sound. My question is that when I press the tactile but not release it so I want it still play the same sound.
But while the tactile switch is pressed down it keeps repeating the same sound. I want it to play just for once while the tactile button is still pressed down.
//#include <SoftwareSerial.h>   //If we use other pins than D0 adn D1 for TX and RX for the music player
#include <DFMiniMp3.h>          //Downlaod here: https://electronoobs.com/eng_arduino_DFPlayer_Mini_Mp3_by_Makuna.php

int sw1 = 3;
int sw2 = 4;
int sw3 = 5;
int sw4 = 6;
int sw5 = 7;
int sw6 = 8;
class Mp3Notify
{
public:
  static void OnError(uint16_t errorCode)
  {
    // see DfMp3_Error for code meaning
    Serial.println();
    Serial.print("Com Error ");
    Serial.println(errorCode);
  }

  static void OnPlayFinished(uint16_t globalTrack)
  {
    Serial.println();
    Serial.print("Play finished for #");
    Serial.println(globalTrack);
  }

  static void OnCardOnline(uint16_t code)
  {
    Serial.println();
    Serial.print("Card online ");
    Serial.println(code);
  }

  static void OnCardInserted(uint16_t code)
  {
    Serial.println();
    Serial.print("Card inserted ");
    Serial.println(code);
  }

  static void OnCardRemoved(uint16_t code)
  {
    Serial.println();
    Serial.print("Card removed ");
    Serial.println(code);
  }
};

DFMiniMp3<HardwareSerial, Mp3Notify> mp3(Serial);   //Create the UART connection to the module

void setup()
{
  //3 push buttons with pullups
  pinMode(sw1,INPUT);                        //Define each button as input with pullup
  pinMode(sw2,INPUT);
  pinMode(sw3,INPUT);
  pinMode(sw4,INPUT);
  pinMode(sw5,INPUT);
  pinMode(sw6,INPUT);
  digitalWrite (sw1, HIGH); //12 Votls supply set to off state
  digitalWrite (sw2, HIGH); //5 Votls supply set to off state
  digitalWrite (sw3, HIGH); //3 Votls supply set to off state
  digitalWrite (sw4, HIGH); //Ajustable Votls supply set to off state
  digitalWrite (sw5, HIGH); //3 Votls supply set to off state
  digitalWrite (sw6, HIGH); //Ajustable Votls supply set to off state
  Serial.begin(9600);
  mp3.begin();                                      //Start communication with the DFplayer module
  uint16_t volume = mp3.getVolume();                //Get actual volume
  mp3.setVolume(30);                                //Set new volum (max is 30)
  uint16_t count = mp3.getTotalTrackCount();        //Get the total tracks on the SD card in case we want to sue this later...
}

//just a fucntion that we use to create delays in "ms"
//without using the delay() function
void waitMilliseconds(uint16_t msWait)
{
  uint32_t start = millis();

  while ((millis() - start) < msWait)
  {
    // calling mp3.loop() periodically allows for notifications
    // to be handled without interrupts
    mp3.loop();
    delay(1);
  }
}

void loop()
{
  if(!digitalRead(sw1))
  {
      mp3.playMp3FolderTrack(1);  // Play audio track 0001
      waitMilliseconds(1000);     // 1s of delay
  }

  if(!digitalRead(sw2))
  {
      mp3.playMp3FolderTrack(2);  // Play audio track 0002
      waitMilliseconds(1000);     // 1s of delay
  }

  if(!digitalRead(sw3))
  {
      mp3.playMp3FolderTrack(3);  // Play audio track 0003
      waitMilliseconds(1000);     // 1s of delay;
  }

  if(!digitalRead(sw4))
  {
      mp3.playMp3FolderTrack(4);  // Play audio track 0001
      waitMilliseconds(1000);     // 1s of delay
  }

  if(!digitalRead(sw5))
  {
      mp3.playMp3FolderTrack(5);  // Play audio track 0002
      waitMilliseconds(1000);     // 1s of delay
  }

  if(!digitalRead(sw6))
  {
      mp3.playMp3FolderTrack(6);  // Play audio track 0003
      waitMilliseconds(1000);     // 1s of delay;
  }

}//end of void


texts:
I am trying to send commands via serial from Python to Arduino with the code below.

If I save this code in a dedicated python file "Stepper.py" (Python2.7 on Mac OSX) , the code runs successfully but nothing happens (the code does not trigger a motor connected to Arduino).

If I start terminal and run the same code from the interactive shell it works as expected.

How can I run it via a dedicated file ?

import serial
import time

ser = serial.Serial(port="/dev/cu.usbmodem144231", baudrate=9600, timeout = 0)
ser.write("200+")
time.sleep(1)
print ser.read()


texts: I cant understand what is going on here , I was trying to find way to send through Serial a number for example 12 and then extract from it number 1 and 2 and store them in two different variables , but suddenly i was unable to make a simple division !!


texts: A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header

texts:
rst:0x10 (RTCWDT_RTC_RESET),boot:0x1f (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371
I am getting this error in my esp32 devkit v1
How to solve it?
I am using arduino IDE for programming the esp32


texts:
I have a nested array, but I get only the correct size of the first one.

I use this as a reference Arduino sizeOf

int clockOn_0 [] = {19,0,0};
int clockOn_1 [] = {20,0,0};

int clockOff_0[] = {6,0,0};
int clockOff_1[] = {22,0,0};

int clock_flag_0[] = {0};
int clock_flag_1[] = {0};

int *dailyTO0[] = {clockOn_0,clockOff_0, clock_flag_0};
int *dailyTO1[] = {clockOn_1,clockOff_1, clock_flag_1};
int **test[] = {dailyTO0,dailyTO1};

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  Serial.println("\n");

  for (int m=0; m<sizeof(test)/sizeof(test[0]);m++){
    for (int n=0; n<(sizeof(test[m])/sizeof(test[m][0]));n++){
      for (int i=0; i<(sizeof(test[m][n])/sizeof(test[m][n][0]));i++){
        Serial.println(test[m][n][i]);
      }
    }
  }

}

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

}

This is the result:

⸮Hpxy⸮ $08⸮x$:⸮⸮
23:29:40.059 ->
23:29:40.059 -> 19
23:29:40.059 -> 20


texts:
Hi i am getting the following errors when trying to do coding.

C:\Program Files (x86)\Arduino\libraries\KTA259V3-master/KTA259V3.h:
51:5: error: 'Adafruit_MAX31855_Info' does not name a type

     Adafruit_MAX31855_Info get_info(void);
     ^

C:\Program Files (x86)\Arduino\libraries\KTA259V3-master/KTA259V3.h:
54:5: error: 'Adafruit_MAX31855_Info' does not name a type

     Adafruit_MAX31855_Info get_info(uint8_t ch);
     ^

The library code is:

#ifndef KTA259V3_H
#define KTA259V3_H

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

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

// Time to wait in milliseconds for signal to settle after switching channels on MUX
#define KTA259V3_MUX_WAIT 250

// Pins for ADG608R Multiplexer
#define KTA259V3_PIN_A0 4
#define KTA259V3_PIN_A1 5
#define KTA259V3_PIN_A2 6
#define KTA259V3_PIN_EN 7

class KTA259V3 : public Adafruit_MAX31855 {
  private:
    uint8_t samples;

  public:
    /** Constructor */
    KTA259V3(uint8_t pin);

    /** Set amount of oversampling **/
    void set_oversampling(uint16_t samples);

    /** Select channel on MUX, use numbers 1 to 8 (not 0 to 7).
      * PCB is has channels 1 to 8 marked on it. User must wait
      * for signal to settle before reading it.
      */
    void select_channel(uint8_t ch);

    /** Calls update() on parent class */
    void update(void);

    /** Selects channel, waits KTA259V3_MUX_WAIT, then updates _info */
    void update(uint8_t ch);

    /** Returns _info structure from last update */
    Adafruit_MAX31855_Info get_info(void);

    /** Selects channel and update, then return _info structure */
    Adafruit_MAX31855_Info get_info(uint8_t ch);
};

#endif

Any idea why this error occurs?


texts: Memsic Accelerometer not returning T value

texts:
I hooked up a Memsic2125 accelerometer to a Arduino Uno.  X and Y values are returning fine, but the T value is returning -4000 every time.

// these constants won't change:
const int xPin = 2;     // X output of the accelerometer
const int yPin = 3;     // Y output of the accelerometer
const int tPin = 4;     // Y output of the accelerometer

void setup() {
  // initialize serial communications:
  Serial.begin(9600);
  // initialize the pins connected to the accelerometer
  // as inputs:
  pinMode(xPin, INPUT);
  pinMode(yPin, INPUT);
  pinMode(tPin, INPUT);
}

void loop() {
  // variables to read the pulse widths:
  int pulseX, pulseY, pulseT;
  // variables to contain the resulting accelerations
  int accelerationX, accelerationY, accelerationT;

  // read pulse from x- and y-axes:
  pulseX = pulseIn(xPin,HIGH);
  pulseY = pulseIn(yPin,HIGH);
  pulseT = pulseIn(tPin,HIGH);
  // convert the pulse width into acceleration
  // accelerationX and accelerationY are in milli-g's:
  // earth's gravity is 1000 milli-g's, or 1g.
  accelerationX = ((pulseX / 10) - 500) * 8;
  accelerationY = ((pulseY / 10) - 500) * 8;
  accelerationT = ((pulseT / 10) - 500) * 8;

  // print the acceleration
  Serial.print(accelerationX);
  // print a tab character:
  Serial.print("\t");
  Serial.print(accelerationY);
  // print a tab character:
  Serial.print("\t");
  Serial.print(accelerationT);
  Serial.println();

  delay(100);
}

The output looks like this...

-104    -24 -4000
-96 -24 -4000
-96 -24 -4000
-104    -24 -4000
-96 -24 -4000
-104    -24 -4000
40  -216    -4000
120 -184    -4000
72  -200    -4000
-80 -376    -4000
456 672 -4000
-8  -40 -4000
-112    0   -4000
-112    0   -4000

Any ideas on how to get the -4000 fixed?


texts:
I have two input signal that when activated have to restart the ardiuno board so I have to connect them to the RESET pin. As you know the arduino board have only one RESET pin so I can't connect both to the same pin.
I think that a good idea is a circuit that takes the two inputs and activate the RESTART pin when one of the two is active.
Have you any idea to solve that problem?

Thank you.


texts: Using Arrays and LED's to represent Piano Scales

texts:
I am trying to use addressable LED's to show various piano scales using the semi notes formula for each scale as an array and an input to indicate the starting note.

int MajorScale[] = {2,2,1,2,2,2,1}; //represents the semi notes in a major scale
int t= 8 //represents the led number that represent the first C on the keyboard

The following leds should light up -

(8, 8+2, 8+2+2, 8+2+2+1, 8+2+2+1+2, 8+2+2+1+2+2, 8+2+2+1+2+2+2 , 8+2+2+1+2+2+2+1)  // This is first C Major Scale on the Piano

so..
(8,10,12,13,15,17,19) // This is first C Major Scale on the Piano where 8 is the first c

Then light up all the other C Major scales available on the piano limited by the number of keys on the piano in this case 76 keys

As there are 12 notes for each octave , add this to the array

if i take just the C note

8, 8+12, 8+12+12 ,8+12+12+12, 8+12+12+12+12  etc

My code so far just lights up the semitone that i set up in the array

enter code here
#include "FastLED.h"
#define DATA_PIN 5
#define NUM_LEDS 76
#define BRIGHTNESS 10
CRGB leds[NUM_LEDS];
int MajorScale[] = {2,2,1,2,2,2,1};
int delayValue = 1000;

void setup() {
Serial.begin(9600); // open the serial port at 9600 bps:
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
FastLED.clear();
}

void loop() {
for(int i = 0; i <=6; i++)
{
    leds[MajorScale[i]] = CRGB::BlueViolet;
    FastLED.show();
     delay(delayValue);

}

FastLED.clear();
}


texts:
I'm using pulseIn on an ESP32 for measuring a frequency between 500 Hz and 10 KHz. I measure both the HIGH and the LOW time, as all simple examples suggest. 95% of the time the result is correct, but sometimes pulseIn returns 0. It can happen on the HIGH or the LOW measure. I'm using GPIO27, which should not be a problem. On a digital scope the signal is very steady and clean.The code is very basic.

const int pulsePin = 27; // Input signal connected to Pin 12 of Arduino

unsigned long Htime;
unsigned long Ltime;
unsigned long Ttime;
float Frequency; // Calculated Frequency

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

void loop() {
  Htime=pulseIn(pulsePin,HIGH);
  delay(10);
  Ltime=pulseIn(pulsePin,LOW);
  Ttime=Htime+Ltime;
  Serial.print(Htime);
  Serial.print(", ");
  Serial.println(Ltime);
  delay(100);
}

The output looks like below:

Of course I can add code to ignore measurements with a 0 result, but any ideas on why they appear?


texts: Code stuck on mag.getEvent(&event); in HMC5833L Compass

texts:
Last week I created some code in which I can run a Ublox GPS NEO-6 and a magnetometer HMC5883L together. Which at the time worked brilliantly.
Yesterday I have attempted to run the code again, with the same connections. No modifications to the code.

The GPS NEO-6 works as expected, the magnetometer not so much. After using serial commands as breakpoints, I am able to see that it gets to the line:

mag.getEvent(&event);

Then I bought two new HMC5883L modules and uploaded the example code, to see if the magnetometer will even run correctly.
The example code returned the basic stats on the breakout board but once again stopped at that line.

Out of curiosity, I removed the magnetometer and ran the program. It displayed exactly the same.
It's not picking up that the HMC5883L is even disconnected.

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_HMC5883_U.h>
/* Assign a unique ID to this sensor at the same time */
Adafruit_HMC5883_Unified mag = Adafruit_HMC5883_Unified(12345);

void displaySensorDetails(void)
{
  sensor_t sensor;
  mag.getSensor(&sensor);
  Serial.println("------------------------------------");
  Serial.print  ("Sensor:       "); Serial.println(sensor.name);
  Serial.print  ("Driver Ver:   "); Serial.println(sensor.version);
  Serial.print  ("Unique ID:    "); Serial.println(sensor.sensor_id);
  Serial.print  ("Max Value:    "); Serial.print(sensor.max_value); Serial.println(" uT");
  Serial.print  ("Min Value:    "); Serial.print(sensor.min_value); Serial.println(" uT");
  Serial.print  ("Resolution:   "); Serial.print(sensor.resolution); Serial.println(" uT");
  Serial.println("------------------------------------");
  Serial.println("");
  delay(500);
}

void setup(void)
{
  Serial.begin(9600);
  Serial.println("HMC5883 Magnetometer Test"); Serial.println("");

  /* Initialise the sensor */
  if(!mag.begin())
  {
    /* There was a problem detecting the HMC5883 ... check your connections */
    Serial.println("Ooops, no HMC5883 detected ... Check your wiring!");
    while(1);
  }

  /* Display some basic information on this sensor */
  displaySensorDetails();
}

void loop(void)
{
  /* Get a new sensor event */
 sensors_event_t event;
 mag.getEvent(&event);

 /* Display the results (magnetic vector values are in micro-Tesla (uT)) */
 Serial.print("X: "); Serial.print(event.magnetic.x); Serial.print("  ");
 Serial.print("Y: "); Serial.print(event.magnetic.y); Serial.print("  ");
 Serial.print("Z: "); Serial.print(event.magnetic.z); Serial.print("  ");Serial.println("uT");

 // Hold the module so that Z is pointing 'up' and you can measure the heading with x&y
 // Calculate heading when the magnetometer is level, then correct for signs of axis.
 float heading = atan2(event.magnetic.y, event.magnetic.x);

 // Once you have your heading, you must then add your 'Declination Angle', which is the 'Error' of the magnetic field in your location.
 // Find yours here: http://www.magnetic-declination.com/
 // Mine is: -13* 2' W, which is ~13 Degrees, or (which we need) 0.22 radians
 // If you cannot find your Declination, comment out these two lines, your compass will be slightly off.
 float declinationAngle = 0.22;
 heading += declinationAngle;

 // Correct for when signs are reversed.
 if(heading < 0)
   heading += 2*PI;

 // Check for wrap due to addition of declination.
 if(heading > 2*PI)
   heading -= 2*PI;

 // Convert radians to degrees for readability.
 float headingDegrees = heading * 180/M_PI;

 Serial.print("Heading (degrees): "); Serial.println(headingDegrees);

 delay(500);
}

The wires i used are about 20cm long.


texts: Unable to light up all the LEDS connected to Arduino using processing

texts:
I have 3 LEDs connected to my arduino which are controlled via laptop key presses with processing.

While the LEDs are able to light up when the respective buttons are pressed, i am unable to light up all 3 LEDs simultaneously when i press all 3 keys at the same time. I am however able to light up 2 LEDs by pressing 2 buttons simultaneously.

All the LEDs light up when their respective buttons are pressed, so i know that it is not a defective LED and/or faulty connections/wiring at play but something else that is causing the issue.

My processing code:

import processing.serial.*;
Serial myPort;

void setup(){
  println("The available ports are: ");
  println(Serial.list());
  myPort = new Serial(this,Serial.list()[0],9600);
  myPort.buffer(64);
  size(500, 500);
}

void draw(){
  if(keyPressed){
    if(key == 'r' || key == 'R'){
      myPort.write(1);
      println("red");
    }
    else if(key == 'y' || key == 'Y'){
      myPort.write(2);
      println("yellow");
    }
    else if(key == 'g' || key == 'G'){
      myPort.write(3);
      println("green");
    }
  }

}

void keyReleased(){
 if(key == 'r' || key == 'R'){
      myPort.write(4);
      println("red released");
    }
    else if(key == 'y' || key == 'Y'){
      myPort.write(5);
      println("yellow released");
    }
    else if(key == 'g' || key == 'G'){
      myPort.write(6);
      println("green released");
    }

  println("released");
}

My Arduino code:

int red = 7;
int yellow = 6;
int green = 5;

void setup(){
  Serial.begin(9600);
  pinMode(red,OUTPUT);
   pinMode(yellow,OUTPUT);
    pinMode(green,OUTPUT);
}

void loop(){

}

void serialEvent(){
    int input = Serial.read();
    if(input == 1){
      digitalWrite(red,HIGH);
    }
    else if(input == 2){
      digitalWrite(yellow,HIGH);
    }
    else if(input == 3){
      digitalWrite(green,HIGH);
    }
    else if(input == 4){
      digitalWrite(red,LOW);
    }
    else if(input == 5){
      digitalWrite(yellow,LOW);
    }
    else if(input == 6){
      digitalWrite(green,LOW);
    }
}

Things i've tried.

I've tried increasing the buffer size from 10(initially) to 64(in the code above)
I've tried increasing the baud rate from 9600 to 12000, just in case it was the serial information not being read fast enough.

None of the things i've tried, listed above, was above to solve my problem, and i dont see what could be causing the problem.

Any advice would be much appreciated.


texts: How to use a microSD card reader with SCK instead of CLK?

texts:
I've bought this microSD reader/writer: http://www.ebay.com/itm/131132034753

I've found only one tutorial, where the pins are similar to my pins, but in the example there is a CLK instead of SCK: https://learn.sparkfun.com/tutorials/microsd-shield-and-sd-breakout-hookup-guide

The pins on my MicroSD reader are:

CS
SCK
MOSI
MISO
VCC
GND


texts: Servo going up to the limit as soon as attached

texts:
I have a Futaba S148 servo (https://servodatabase.com/servo/futaba/s148)
connected to an Arduino Uno.

As soon as the script attaches the servo, it rotates to its limit and gets stuck.

I've tried several scripts, and narrowed to the simplest:

#include <Servo.h>  // servo library
Servo servo1;  // servo control object
void setup()
{
  //  Attach the servo1 object to digital pin 4.
  servo1.attach(10);
}
void loop()
{
}

Also connected the servo to the board with this:

#include <Servo.h>  // servo library
Servo servo1;  // servo control object
void setup()
{
  //  Attach the servo1 object to digital pin 4.
  //servo1.attach(10); <--- notice this commented out
}
void loop()
{
}

and then the servo remains still.

I'm using a battery pack of 4.8 V which works fine with the servo and the RC radio, so the battery and the servo, works fine together with remote control.

I have another different SG90 servo running with its own power source and connected to the pin 9, and with a different sketch, it works perfectly.


texts: adding a dead band to my motor and gearbox

texts:
I have a motor and gearbox that has limits and a pot built in.

I have some code what drives the motor one way to when it hits its limits takes a value and drives the other way and takes a value, then map the range from 0 to 100, that all works fine.

I also have a analog input map to 0 to 100 what I would like to do is to drive the motor to where ever the analog input is at, which is what I have done with the code below but when the motor gets close it starts hunting backwards and forwards.

I tried to add some sort of dead band (where + 0.5 / where - 0.5) it just seems to just move the problem.

I did try -+ but this still did not help, so what I need to do is aim for the target value and stop then if I'm within 0.5 ether way then that is good enough.

How can I do that?

sensor       = pot on motor,
where        = 0 to 5 input,
vent1UPlim   = limits,
vent1DOWNlim = limits

PS. I know the map of 0 to 100 could do with being bigger but it's just easier to get my head around at the moment.

        //            pot           0-10v     ONE WAY
          if (sensorValue > (where + 0.5)) {
          if (digitalRead(vent1UPlim)==    HIGH) {
            DoneInitializationA=false;
            digitalWrite(vent1enable,      HIGH);
            delay(50);
            digitalWrite(vent1PWMA ,       HIGH);
            mydisp.drawStr(0, 2, "-close-|");
          }
          else {
            digitalWrite(vent1PWMA ,       LOW);
            delay(50);
            digitalWrite(vent1enable,      LOW);
            mydisp.drawStr(0, 2, "       |");
          }
        }
        else {
          if (!DoneInitializationA)
          {
            digitalWrite(vent1PWMA ,       LOW);
            delay(50);
            digitalWrite(vent1enable,      LOW);
            mydisp.drawStr(0, 2, "       |");
            DoneInitializationA=true;
          }
        }

           //                                   OTHER WAY
          if (sensorValue < (where - 0.5)) {
          if (digitalRead(vent1DOWNlim)==  HIGH) {
            DoneInitializationB=false;
            digitalWrite(vent1enable,      HIGH);
            delay(50);
            digitalWrite(vent1PWMB ,       HIGH);
            mydisp.drawStr(0, 2, "-open -|");
          }
          else {
            digitalWrite(vent1PWMB ,       LOW);
            delay(50);
            digitalWrite(vent1enable,      LOW);
            mydisp.drawStr(0, 2, "       |");
          }
        }
        else {
          if (!DoneInitializationB)
          {
            digitalWrite(vent1PWMB ,       LOW);
            delay(50);
            digitalWrite(vent1enable,      LOW);
            mydisp.drawStr(0, 2, "       |");
            DoneInitializationB=true;
          }
        }


texts: How does one use (specically the wiring) the OV7670 camera with the Arduino Uno?

texts: If one could tell me where each of the pins on the back of the camera go to, that would be great. if someone added the code also that would be awesome.


texts: How do I disable drag-and-drop text editing in Arduino IDE?  This is very annoying.  If not careful, this causes code to move around when trying to copy and paste...


texts: Simple wifi scan networks doesn't work on ESP-01

texts:
I can't figure out why, but my very simple wifi scan code doesn't work on two pieces of  ESP-01. At first I thought, about bad or burn out MCU, but none of my two ESP-01 and can not find nearby wifi.
I have tried it on NodeMCU... That's works. But on ESP-01 it doesn't work at all. No nearby wifi found.
This is my code
#include "ESP8266WiFi.h"
void setup() {
  Serial.begin(115200);

  // Set WiFi to station mode and disconnect from an AP if it was previously connected
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  Serial.println("Setup done");
}

void loop() {
  Serial.println("scan start");

  // WiFi.scanNetworks will return the number of networks found
  int n = WiFi.scanNetworks();
  Serial.println("scan done");
  if (n == 0)
    Serial.println("no networks found");
  else
  {
    Serial.print(n);
    Serial.println(" networks found");
    for (int i = 0; i < n; ++i)
    {
      // Print SSID and RSSI for each network found
      Serial.print(i + 1);
      Serial.print(": ");
      Serial.print(WiFi.SSID(i));
      Serial.print(" (");
      Serial.print(WiFi.RSSI(i));
      Serial.print(")");
      Serial.println((WiFi.encryptionType(i)));
      delay(100);
    }
  }
  Serial.println("");

  // Wait a bit before scanning again
  delay(5000);
}

and output from Serial console is "scan done ... no networks found"


texts:
I would like to know what I've done wrong. I configured my circuit using the "Hello world tutorial. I got the infamous white square pattern

D7 to pin 2
D6 to pin 3
D5 to pin 4
D4 to pin 5
E to pin 11

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

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd(2, 3, 4, 5, 11, 12);      // put your pin numbers here

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 0);
  // print the number of seconds since reset:
  lcd.print("hello, world!");
}


texts: void timerIsr() doesn't work and the oscilloscope doesn't show anything

texts:
I have a project on simulation and realization of a pulsation detector.
The cardiac part is coupled to an electronic thermometer in Proteus, but void timerIsr() isn't called and doesn't show anything in LM016L. Besides, when I use my oscilloscope it also shows nothing.
#include<LiquidCrystal.h>
#include <TimerOne.h>

LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

int HBSensor = 4;
int HBCount = 0;
int HBCheck = 0;
int TimeinSec = 0;
int HBperMin = 0;
int HBStart = 0;
int HBStartCheck = 0;
const int sensor = A0;
int led1(1);
int led2(2);
int led3(3);
float tempc;
float vout;

void setup() {
  lcd.begin(20, 4);
  pinMode(HBSensor, INPUT);
  pinMode(HBStart, INPUT_PULLUP);

  Timer1.initialize(800000);
  Timer1.attachInterrupt(timerIsr);

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Current HB: ");
  lcd.setCursor(0, 1);
  lcd.print("Time in Sec :");
  lcd.setCursor(0, 2);
  lcd.print("HB per Min :0.0");

  pinMode(sensor, INPUT);
  delay(500);
  pinMode(1, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
}

void loop() {
  if (digitalRead(HBStart) == LOW) {
    lcd.setCursor(0, 3);
    lcd.print("HB Counting ..");
    HBStartCheck = 1;
  }

  if (HBStartCheck == 1) {
    if ((digitalRead(HBSensor) == HIGH) && (HBCheck == 0)) {
      HBCount = HBCount + 1;
      HBCheck = 1;
      lcd.setCursor(14, 0);
      lcd.print(HBCount);
      lcd.print(" ");
    }

    if ((digitalRead(HBSensor) == LOW) && (HBCheck == 1)) {
      HBCheck = 0;
    }

    if (TimeinSec == 10) {
      HBperMin = HBCount * 6;
      HBStartCheck = 0;
      lcd.setCursor(14, 2);
      lcd.print(HBperMin);
      lcd.print(" ");
      lcd.setCursor(0, 3);
      lcd.print("Press Button again.");
      HBCount = 0;
      TimeinSec = 0;
    }

    vout = analogRead(sensor);
    tempc = (vout * 500) / 1023;
    lcd.setCursor(0, 0);
    lcd.print("in degree C=");
    lcd.print(tempc);
    lcd.setCursor(0, 1);

    if (tempc > 38) {
      digitalWrite(led2, HIGH);
      digitalWrite(led3, LOW);
      digitalWrite(led1, LOW);
    }

    if (tempc > 37 && tempc < 38) {
      digitalWrite(led1, HIGH);
      digitalWrite(led3, LOW);
      digitalWrite(led2, LOW);
    }

    if (tempc < 37) {
      digitalWrite(led3, HIGH);
      digitalWrite(led1, LOW);
      digitalWrite(led2, LOW);
    }
  }
}

void timerIsr() {
  if (HBStartCheck == 1) {
    TimeinSec = TimeinSec + 1;
    lcd.setCursor(14, 1);
    lcd.print(TimeinSec);
    lcd.print("");
  }
}


texts: OSEPP 16x2 LCD Display Turns On But Does not Display any White Boxes

texts:
Circuit Wiring
This is my first ever post on here and it is due to a recent personal project i started on a Mega 2560 board. (I was attempting to build a temp and humidity sensor for which i would need to display the values on a LCD display). At first, i built the circuit according to a reference project and i noticed the LCD screen would light up only the first half of the screen (it would be lit up white boxes) img1
Then, assuming my LCD display is not working, i took everything apart and built an initialization LCD circuit.. in which i have read that it should display boxes on the top row. But, when i wire it up very basically, it just lights up but nothing happens. Can anyone tell me whether my LCD might be broken? (I have purchased 3 up till now and would hate to return to the store for ANOTHER broken LCD)
Kindly provide any advice or insight you may have to offer ( I am a complete beginner in Arduino)
I have attached all the pictures of my circuit wiring and of the LCD display.
EDIT 1: I rewired the circuit to include a resistor for contrast (V0; did not use a potentiometer because when i did use it.. it did not make any difference when changing the resistance) I also placed a 100ohm resistor for the backlight (pin A).
The code I used:

#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {   // set up the LCD's number of columns and rows:
lcd.begin(16, 2);   // Print a message to the LCD.   lcd.print("hello,
world!"); }
void loop() {   // set the cursor to column 0, line 1   // (note: line
1 is the second row, since counting begins with 0):   lcd.setCursor(0,
1);   // print the number of seconds since reset:   lcd.print(millis()
/ 1000); }

Also, i have uploaded a close up picture of my LCD and there seems to be a faint 'Dark' spot towards the middle of the display.. does that imply it is damaged?


texts: Using Modbus-RTU with Arduino and temperature controller

texts:
I'm trying to connect with a 4 channel temperature controller using Arduino Modbus Library.

This is a part of my temperature controller datasheet. It has register for read PV of each channel.

I have studied example code of the library and now i'm trying to read PV of each channel.

So, I have modified the example code as below,

#include <ModbusMaster.h>

    // instantiate ModbusMaster object
    ModbusMaster node;

    void setup()
    {
      // use Serial (port 0); initialize Modbus communication baud rate
      Serial.begin(19200);

      // communicate with Modbus slave ID 2 over Serial (port 0)
      node.begin(2, Serial);
    }

    void loop()
    {
      static uint32_t i;
      uint8_t j, result;
      uint16_t data[6];

      i++;

      // set word 0 of TX buffer to least-significant word of counter (bits 15..0)
      node.setTransmitBuffer(0, lowWord(i));

      // set word 1 of TX buffer to most-significant word of counter (bits 31..16)
      node.setTransmitBuffer(1, highWord(i));

      // slave: read (4) 16-bit registers starting at register 2 to RX buffer
      result = node.readHoldingRegisters(1, 4);

      // do something with data if read is successful
      if (result == node.ku8MBSuccess)
      {
        for (j = 0; j < 4; j++)
        {
          data[j] = node.getResponseBuffer(j);
        }
      }

    }

My questions are,
Explain below lines in the code

          // set word 0 of TX buffer to least-significant word of counter (bits 15..0)
      node.setTransmitBuffer(0, lowWord(i));

      // set word 1 of TX buffer to most-significant word of counter (bits 31..16)
      node.setTransmitBuffer(1, highWord(i));

I didn't  pass any request to slave, So, can I get the 4 PV value like this?
If not, please explain how can I do it.


texts:
Is it valid configuration using hardware I2C pins:

Especially: can NanoEvery initialize communication with DS2482, while it is slave for Mega2560? Using Wire library or should I use software I2C when talking to Mega2560 and leave NanoEvery as master to DS2482?
Needed to use additional Nano due to long times of reading temperatures connected to DS2482 that blocks Mega controller.
Graph source


texts: How is it possible to access the CPU registers using memory addresses?

texts:
The following is taken from ATmega328-328P Data sheet.

According to this, I can access all the 32 registers in CPU using memory addresses. For example:

 unsigned char *register = 0x0;

will access the first register. Is this true? if so, then is this also possible to do on regular CPUs (like my laptop), since I thought you can only use a pointer to access memory and not CPU registers.

Is the register mapped into the SRAM in this case?


texts: 'Delay command' and bluetooth communication problem

texts:
I have a project where I send data to Arduino via Bluetooth using an Android application. For example, when I press 1 from the 'bar led' part of the application, an animation needs to happen. When I press 2, a different animation will be displayed. However, because there is a 'delay command' in the animations, there is a delay in data exchange when I press the button. How can I prevent this? Is there a command I can use instead of the 'Delay command'?

void loop() {
  if (bluetooth.available()) {
  while (bluetooth.available())
    {
      bar_analog = bluetooth.parseInt();
      head_analog = bluetooth.parseInt();
      bar_anim = bluetooth.parseInt();
      strip_anim = bluetooth.parseInt();
      motor_speed = bluetooth.parseInt();
      direct = bluetooth.parseInt();
      level = bluetooth.parseInt();
      if (debug) {
        Serial.print("Bar Brightness: ");
        Serial.println(bar_analog);
        Serial.print("Bar Animation Type: ");
        Serial.println(bar_anim);
        Serial.print("Headlight Brightness: ");
        Serial.println(head_analog);
        Serial.print("Strip Animation Type: ");
        Serial.println(strip_anim);
        Serial.print("Motor Speed Level: ");
        Serial.println(motor_speed);
        Serial.print("Direction: ");
        Serial.println(direct);
        Serial.print("Mast Goes: ");
        Serial.println(level);
        Serial.println("--------------------------------");
      }
      if (bluetooth.read() == '\n') {

      }
  }}
  if(bar_anim==1) {
  digitalWrite(8,HIGH);
  delay(50);
  digitalWrite(8,LOW);
  delay(250);
  }
  else if(bar_anim==2) {
  digitalWrite(8,HIGH);
  delay(250);
  digitalWrite(8,LOW);
  delay(50);
}
}


texts:
I'm trying to create a program for my robot, but something is not right.
Here's the code:

#include <SPI.h>
#include <Tone.h>
#include <Wire.h>   // standardowa biblioteka Arduino
#include <LiquidCrystal_I2C.h> // dolaczenie pobranej biblioteki I2C dla LCD

//Enums:
enum Dir
{
  forward = 1,
  backward = 2,
  left = 3,
  right = 4
};

enum State
{
    movingForward = 1,
    movingBack = 2,
    turningLeft = 3,
    turningRight = 4,
    doingNothing = 5,
    readyToMove = 6 //Potrzebne?
};

enum SpeedState
{
  slowingDown = 1,
  maxSpeed = 2,
  accelerating = 3,
  notMoving = 4
};

//Classes:
LiquidCrystal_I2C lcd1(0x27, 20, 4);

//Base class for devices
class Device
{
    public:
        virtual void Init() = 0;
};

//STEPPER::
class StepMotor: public Device
{
    public:
        int motorPin;
        int dirPin;
        int sleepPin;

        void Init ( void )
        {
            pinMode(motorPin, OUTPUT);
            pinMode(dirPin, OUTPUT);
            pinMode(sleepPin, OUTPUT);

            toneObject.begin(motorPin);
        }

        void SetSpeed ( int speed )
        {
          toneObject.play(speed);
        }

    private:
      Tone toneObject;
};

//VARIABLES:
int a = 1; //przyspieszenie (przyrost prędkości i jej ubytek przy hamowaniu
int s_accelerating = 1; //droga przyspieszania [mm]
int s_braking = 1;  //droga hamowania [mm]

class Robot
{
    public:
        static float x;
        static float y;
        static float t;
        static State state;
        static SpeedState speedState;
        static int currentSpeed;
};

class MoveOrder
{
  public:
    static Dir direction;
    static int distance;
    static int speed;
    static int distanceRemaining;
    static int distanceMade;
};

//FUNCTIONS:
void SetInterrupt ( void )
{
    noInterrupts();           // disable all interrupts
    TCCR5A = 0;
    TCCR5B = 0;
    TCNT5  = 0;
    OCR5A = 310;            // compare match register 16MHz/256/2Hz   400 okolo 6.4ms  380-6.1ms 300-4.9ms
    TCCR5B |= (1 << WGM12);   // CTC mode
    TCCR5B |= (1 << CS12);    // 256 prescaler
    TIMSK5 |= (1 << OCIE1A);  // enable timer compare interrupt
    interrupts();             // enable all interrupts
}

void SetSpeed ( int speedValue )
{
   //currently empty
}

void setup()
{
    SetInterrupt();
}

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

}

ISR(TIMER5_COMPA_vect)
{
    if (Robot::state != doingNothing)
    {
        if (Robot::state == movingForward || Robot::state == movingBack )
        {
          if (MoveOrder::distanceMade < s_accelerating)
            {

                Robot::currentSpeed += a;

                SetSpeed(4);

            }
        }
    }
}

Compilation returns this:

Arduino:1.6.10 (Windows 10), Płytka:"Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\Marcin\AppData\Local\Temp\ccU9OfJk.ltrans0.ltrans.o: In function `__vector_21':

ccU9OfJk.ltrans0.o:(.text+0x812): undefined reference to `Robot::state'

ccU9OfJk.ltrans0.o:(.text+0x816): undefined reference to `Robot::state'

C:\Users\Marcin\AppData\Local\Temp\ccU9OfJk.ltrans0.ltrans.o: In function `__vector_47':

ccU9OfJk.ltrans0.o:(.text+0x820): undefined reference to `MoveOrder::distanceMade'

ccU9OfJk.ltrans0.o:(.text+0x824): undefined reference to `MoveOrder::distanceMade'

ccU9OfJk.ltrans0.o:(.text+0x82e): undefined reference to `Robot::currentSpeed'

ccU9OfJk.ltrans0.o:(.text+0x832): undefined reference to `Robot::currentSpeed'

ccU9OfJk.ltrans0.o:(.text+0x838): undefined reference to `Robot::currentSpeed'

ccU9OfJk.ltrans0.o:(.text+0x83c): undefined reference to `Robot::currentSpeed'

collect2.exe: error: ld returned 1 exit status

exit status 1

I noticed that when I comment these lines:

        Robot::currentSpeed += a;

        SetSpeed(4);

errors are gone. Why?


texts:
Is it possible to set all 6 PWM frequencies to a value between 2 and 5 kHz?

I've read that the base frequency for pins pins 5 and 6 is 62500 Hz.
And the divisors for the pins 5 and 6 are only this ones: 1, 8, 64, 256, and 1024.

The closest I can get is 7.812,5 Hz with the 8 divisor. Are there any other possibilities to achieve this?