texts: How can I reset the program on an Arduino Uno while the device isn't recognised by my computer at all?

texts:
So I've recently been playing around with my arduino uno, and today it completely refuses to communicate with my computer at all. I've tried using other cables, switched OS (Tried Windows 8.1 and Ubuntu 14.04), and tried on my laptop, none of them recognise the device at all.

From what I've read, this problem can be caused my a program on it with a Serial.println() frequently used, which I believe is the case here. The solution for this problem is according to other answers, to hold the reset button while I upload an empty sketch to the arduino. However, I can't do this, since the computer doesn't communicate with the arduino at all.

Any ideas what could've gone wrong, and how to fix it?

EDIT: Alright, the problem seems to have resolved itself... I have no idea what made it work, I was frustrated and went to bed last night, and today it works without an issue..

EDIT #2: Scratch that.. now I get this error when I try to upload a program to the arduino:

avrdude stk500_getsync() not in sync resp=0x00

The device does show up in Device Manager, so I tried installing the arduino drivers for it, but it gives me the error code 10. Windows automatically installs some serial driver for it, but any attempts of serial communication with the arduino fails.


texts:
I'm working on a project, but just for testing, I haven't connected it to the internet yet, even though the code SHOULD be ready to roll out.

When trying to test some of my code with the serial console, I realized my program was locking up and I traced it down to here. Now my arduino uno and ethernet shield isn't currently connected to the internet, so my question is, how could I timeout this function so that I can keep my program running when there's no internet to connect it too.

Here's my code in the setup function

if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  }

If anyone has any thoughts or suggestions, I'd definitely appreciate it.


texts: LiquidCrystal_I2C may be incompatible with your current board message

texts:
I am trying to get the LED to blink the message in the code. However, I keep getting an error message library LiquidCrystal_I2C-master claims to run on AVR architecture(s) and may be incompatible with your current board which runs on esp32 architecture(s).
I have attempted to look at previous answers but I am very lost and confused. I appreciated any help I can get. Thank you!


texts: I am trying to power a small peristaltic pump using an UNO R3. I have it powered using usb, and I tried running the blink program to see if I could power it using digital write, and extended the delay to troubleshoot voltages using a multimeter. The motor doesn't do anything connected to the digital pins even when the digital write is set to high. If I connect the motor to the 5 V power pin the motor turns on so I know 5 V is enough voltage. I've looked at tutorials for DC motors and they explain how to set it up with motor reversing using components I don't have, and I don't need it to reverse. How can I get the motor to turn for a specific length of time?


texts:
I'm making a soccer car with arduino. And I have this undocumented motor control shield. So I don't know how to program it. I've tried to code it as if it be an H bridge, but is not working. Someone know which are the pins that I have to use?
The plate is from DK Electronics, and says motor control shield for arduino.

Don't know why but the image can't be upload from my phone.

As I can't show more this way I have published on my Twitter account the image, if you can I'll be grateful.
Link: https://twitter.com/ricardovaras_99/status/789249497322889216

This is the code I used guided by some internet articles about the Arduino's original motors control shield.

 pinMode(8,OUTPUT);       //Channel A Brake Pin Initialize
 pinMode(9,OUTPUT);       //Channel B Brake Pin Initialize
 pinMode(12,OUTPUT);      //Channel A Direction Pin Initialize
 pinMode(13,OUTPUT);      //Channel B Direction Pin Initialize


texts: If I use a biasing circuit for a signal going into an analog input pin, will it affect the ADC operation?

texts:
If I have a single 100Hz AC signal biased by two 1 M-ohm resistors (as per schematic below), and then output to an Arduino UNO analog input pin, with the UNO sampling at around 1 kHz using delays, would there be any issues with the ADC result?

(Source of schematic: http://tinyurl.com/ycprqsdx)

From the Atmega328P's spec sheet (the UNO's microprocessor) it recommends an output impedance of 10 k-ohms or less, as shown below.
If I used the pair of 1 M-ohm resistors as a biasing circuit and then deliberately slow down the sampling with delays (i.e.: in loop, do analogRead, then delay, then do analogRead, etc.), would it still be okay?


texts: Vibrating motors with different intervals

texts:
For my project, I have 3 ultrasonic sensors and 3 vibrating motors; the motors need to buzz for a small amount of time, then wait for a specific time that corresponds whith the range of the ultrasonic sensor, then muzz again.

The problem I'm having is that I used delays at first but that would cause the third motor only to buzz after the first two already waited.

I basically need something like "digitalWrite(motorPin_1, HIGH) for X amount of time;"
and at the same moment it has to start "digitalWrite(motorPin_2, HIGH) for X amount of time;".

Sadly I can't get the motors to vibrate any softer or harder, so I use these intervals.


texts: How do I send non-ASCII keys over the BLE HID connection using an Adafruit nRF52 Feather?

texts: The hid_keyboard example sketch shows how to send ASCII characters, but how can I send non-ASCII codes like the F1 key, or keys with shift/control modifiers?


texts: Connecting Arduino Uno WiFi Developer Edition to the Internet

texts:
I recently bought an Arduino Uno WiFi Developer Edition from here. Although all the other functionality appears to work (I’m able to upload/run programs, read sensors I plug in, etc.), I am not able to connect the Arduino to the internet. The Arduino has a built in ESP8266 chip which is compatible with the WiFi Link library, however, running ScanNetworks in the Arduino mac IDE (File > Examples > WiFi Link > ScanNetworks) doesn't work, nor does it print any errors. Other example files in that library don't work either. The CheckWiFiLinkFirmwareVersion program in the same library will print the welcome message "WiFi Link firmware check." but nothing after that.
I have tried every other WiFi library I could find in the library manager window (Sketch > Include Library > Manage Libraries), namely

Arduino Uno WiFi Dev Ed Library
WiFiEsp
WiFi101
WiFi

However, none of them work. Is the Arduino's WiFi chip defective, or am I doing something wrong? One reviews on the website that I bought the Arduino from said this (see lenny):

Arduino.org (which is different from arduino.cc) has not made software available to access the WiFi capabilities of this board. As far as I can tell, the wifi cannot be used. They keep saying that the software is coming soon.
See this thread on their forum: http://www.arduino.org/forums/uno/arduino-uno-wifi-arduinowifi-library-incomplete-solution-for-mqtt-tcp-udp-socket-communication-540

In summary, is the Arduino Uno WiFi Developer Edition known to be defective? If not, what am I doing wrong? If it is, could I potentially get a WiFi shield and use that instead of the built in chip? I have other shields for the Arduino (e.g. an SD card shield) that are working fine.


texts:
I followed the tutorial on controlling 8 LEDs using a SIPO SN74HC595N shift register on both Adafruit and Last Minute Engineer. I used a Sparkfun Pro Micro (Arduino Leonardo equivalent).

The problem is the LEDs are not lighting up in the way that I'm expecting it do it. Both guides said each LED will light up one after another. After all 8 are lit, all of them will turn off. Here is my result. Other LEDs will either dim up or down as the target LED turn on. I used the code provided from the guide and only changed the pinout number. The resistor values are the same for each color so it can't be the resistor. Anyone have any idea what's going on here?

/*
Test code for 74HC595N SIPO shift register. Used with Pro Micro
*/

int latchPin = 16;
int clockPin = 15;
int dataPin = 14;
int outputEnablePin = 10;

byte leds = 0;    // Variable to hold the pattern of which LEDs are currently turned on or off

void setup()
{
  // Set all the pins of 74HC595 as OUTPUT
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(outputEnablePin, OUTPUT);
  outputEnablePin = LOW;
}

/*
 * loop() - this function runs over and over again
 */
void loop()
{
  leds = 0; // Initially turns all the LEDs off, by giving the variable 'leds' the value 0
  updateShiftRegister();
  delay(500);
  for (int i = 0; i < 8; i++) // Turn all the LEDs ON one by one.
  {
    bitSet(leds, i);    // Set the bit that controls that LED in the variable 'leds'
    updateShiftRegister();
    delay(500);
  }
}

/*
 * updateShiftRegister() - This function sets the latchPin to low, then calls the Arduino function 'shiftOut' to shift out contents of variable 'leds' in the shift register before putting the 'latchPin' high again.
 */
void updateShiftRegister()
{
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, LSBFIRST, leds);
   digitalWrite(latchPin, HIGH);
}

Schematics:


texts: Using HC-SRO4 sensor and looking for obstacle

texts:
I am working in TinkerCAD, I want to design and simulate a circuit in which there are following components: 1.)An Arduino board. 2.)A potentiometer 3.)An HC-SRO4 sensor 4.)An LED.
So, the sensor should be able to tell if the range that has been set via the potentiometer has any objects in it or not. And if there are one or more objects in that range then the LED should also light up. Also, the user should be able to change the range using potentiometer during simulation.
I have attached the code here, but for some reason, I don't feel satisfied. Here is a list of the possible reasons. 1.) For LED lightening up, I had to use another if else , since it was showing an error else used without a previous if if I used LED in the same if else2.) The theoretical range for the sensor I have used is 2cm-400cm but in my circuit, it was not showing the upper range as 400cm.
Please tell the possible solutions. Also, can I improve my code and circuit

Here is the code which I used.

const int echoPin = 6;
const int pingPin = 7;

void setup()
{
 Serial.begin(9600);//Starting serial terminal
}

void loop()
{
  int sensorValue = 0;//Setting variable
  int mappedValue = 0;
  const int potentiometerRange = 0;//setting the buttons to variables to avoid confusion.
  long distance;//declaring a varible in loop because we can change the range during runtime.
  long actualDuration;//...
  long duration;
  pinMode(A0,INPUT);
  pinMode(11,OUTPUT);
  digitalWrite(11,LOW);//
  sensorValue = analogRead(potentiometerRange);//reading the potentiometer value.
  mappedValue = map(sensorValue,0,1023,2,400);//mapping the value accordingly for ultrasonic sensor.
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);//to ensure a clean high pulse later
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);//to trigger the ping.
  delayMicroseconds(10);
  digitalWrite(pingPin, LOW);
  pinMode(echoPin,INPUT);//noe echo which tuns low in the time when waves return back.
  duration =  pulseIn(echoPin,HIGH);//time calculated by sensor
  //calculation of distance from any object
  actualDuration = duration/2;//reducing the time in half for the distance is half only.
  distance = 0.0343*actualDuration;//keeping in mid that speed of sound is 343 m/s and pulseIn returns time in microseonds.
  if(mappedValue>=distance)//checking if the object is in range
    Serial.println("YES");
  else
    Serial.println("NO");
  if(mappedValue>=distance)
    digitalWrite(11,HIGH);
  else
    digitalWrite(11,LOW);
   delay(500); // Delay a little bit to improve simulation performance
}

I'm also attaching the picture of my circuit.


texts:
Out of ideas here, i try using PB0-3 as sinks for a LED matrix and the pins just won't sink.

My test code:

void setup() {
  //bitClear(SPCR, 6);
  pinMode(PD5, OUTPUT);

  pinMode(PB0, OUTPUT);
  pinMode(PB1, OUTPUT);
  pinMode(PB2, OUTPUT);
  pinMode(PB3, OUTPUT);

  digitalWrite(PB0, LOW);
  digitalWrite(PB1, LOW);
  digitalWrite(PB2, LOW);
  digitalWrite(PB3, LOW);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(PD5, HIGH);
  delay(1000);
  digitalWrite(PD5, LOW);
  delay(1000);
}

(Using bog standard Blink as a starting point for tests)

My controller is an ATMega328P programmed using USBaspLoader on my own PCB.

If i connect the physical pin that should be sinking with a piece of wire to ground the LED starts blinking, so the "sending" part seems to work but the "receiving" part doesn't.
As you can see i tried manually disabling the SPI port, no luck either.
I tried different controllers, among them a good old ATMega8-16, nothing seems to work.
I even breadboarded a test circuit but no luck, PortB wont sink.


texts: ESP8266 check if TCP client disconnected...informally

texts:
Hi with ESP8266WiFi library, I usually check for connection of a TCP client with client.connected().

But it seems to still return true if my TCP client in an unexpected way (like disconnect to WiFi/ Power loss/...). Which leaves my program stuck in a infinite loop.

Is there a more reliable to check for connection status?


texts: CRC test fail on MS5803-14BA pressure sensor - what can I do?

texts:
Problem:

I bought two MS5803-14BA sensors and I soldered them myself to a SOIC-8 PCB to be able to use them. Only one sensor is used in my circuit. To access it, I use an Arduino Pro Mini 8MHz/3.3V with a library that has a CRC check for the sensor. When assembled to the circuit, one of the sensors pass the test, however the other fails. I'm using I2C to access the sensor.

I would like both sensors to pass the test so I could compare readings from two assembled circuits, but I really don't know how to do it. I have a three questions:

Where this problem can be originating from?
What kind of limitations I have for not passing the CRC test? Does it mean that the collected data can not be trusted?
If I use the raw readings D1 and D2 from a sensor that have failed the CRC test and pos-compensate them in the computer, will I have trustful results?
How to solve it?

Schematic:

simulate this circuit – Schematic created using CircuitLab

The resistors R1 and R2 are pull-up resistors.
The capacitor C1 is recommended by the sensor's datasheet.
Sensor's PS pin is connected to Vcc in order to select I2C mode for communication. The other option was SDI.
Sensor's CLS pin is connected to ground to select the address 0x77 to the sensor. Case it is connected to Vcc, the address is set to 0x76.

Documentation

Sensor's Data Sheet
Library used


texts: Help Connecting Lidar sensor over SPI to arduino Due?

texts:
I'm very new to Arduino and have never used the SPI protocol before. I've tried following tutorials online, but my SPI.transfer always returns a value of 255 whether the sensor is connected or not. The sensor is a Leddar Vu8 and has external power. I have included my wiring diagram, as well as the code i have written so far. Any help on how to get the read register over SPI would be greatly appreciated. Thanks in advance!

#include <SPI.h>
const int slaveSelectPin = 10;

void setup() {
  // set the slaveSelectPin as an output:
  Serial.begin(9600);
  pinMode(slaveSelectPin, OUTPUT);
  // initialize SPI:
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);
  SPI.setClockDivider(SPI_CLOCK_DIV4);
  SPI.begin();
  delay(100);
}

void loop() {
  digitalWrite(slaveSelectPin, LOW);
  delay(500);
  SPI.transfer(0x0B);
  int data = SPI.transfer(0x00400000);
  int data2 = SPI.transfer(0x0B);
  delay(500);
  Serial.println(data);
  Serial.println(data2);
  digitalWrite(slaveSelectPin, HIGH);
}

Wiring diagram:

Here is a snippet of the data sheet for the vu8:

The rest of the data sheet can be found here: https://www.robotshop.com/media/files/pdf2/leddarvu_and_configurator_user_guide.pdf
Starting on page 37.

Thanks in advance for any help!


texts:
I'm working on some software using an Uno (ATmega328P). I have a stage byte that can be 1 of 5 values (0-4) in my code and it will increase by 1 every 2.5 hours. If I lose power I need to ensure that on wake up the stage is the same as it was at the time of power loss, so each time the stage is updated I save it to EEPROM.

To ensure the EEPROM lasts as long as possible I want to write some code that uses more than a single byte which I continually erase and write to. I was wondering if there is any library to do this or if my idea below would work?

I currently don't need to use the EEPROM for anything else so to extend the EEPROM life I was going to section of 1 quarter of it (0-255 bytes) for saving this value. Each time I change the stage I will write 3 bytes to EEPROM which will be:

An index byte (used to shift addresses I write to).
A stage byte (the stage I need to store).
A count byte (the amount of times I have wrote the stage at the current index).

To begin with the index will be written to byte 0 in the EEPROM, the stage to byte 1 and the count to byte 2.

My plan is to allow the stage to be written to byte 1 250 times, then clear the count and shift the index to 3. This will in turn move the bytes that the stage and count are being written to to 4 and 5. I will do this until the index reaches the end of the 255 bytes and then return the index to 0. So in total I should be able to shift 85 times.

Each byte has 100,000 erase/write cycles so this means I can pass through bytes 0-255 400 times, writing the stage 250 times each pass. So instead of having 100K writes I would have about 8.5 million writes.

This is my first idea and I realize there is also some waste in the way I do it. I haven't worked with EEPROM much and I was just hoping for some advice as I'm sure I could be going at this completely wrong.


texts: How to use a Bi-color matrix led 8x8 with 24 pins?

texts:
I've just buy this 8x8 LED matrix WLG M20088A/BEG and I'm trying to light all the LEDs in one single color (green) but I don't understand how the 24 pins work for this specific model.

I know that every manufacturer makes different models. Does anyone have any experience with this particular model?


texts:
So I'm trying to read an 8-byte character string from an I2C device and print it to the serial console. This raw 8-char array is not terminated when it comes from the device, so I'm pretty sure I need to manually terminate it. Unfortunately, when I go to print the resultant string, the serial monitor just fills up with line breaks. Could someone take a look at this code and tell me where I went wrong?

uint8_t* HT_Controller::readMultiple(uint8_t reg, uint8_t num)
{
    Wire.beginTransmission(i2cAddr);
    Wire.write(reg);
    Wire.endTransmission();

    Wire.requestFrom(i2cAddr, num);
    uint8_t* data = new uint8_t[num];

    for(int i = 0; i < num; i++)
    {
        data[i] = Wire.read();
    }

    return data;
}

char* HT_Controller::getManufacturer()
{
    uint8_t* data = readMultiple(REGISTER_MFR, NUM_MFR_BYTES); //Read the bytes from the controller
    char* dataTerminated = new char[NUM_MFR_BYTES + 1]; //Our new array that will have a null char at the end
    memcpy(data, dataTerminated, NUM_MFR_BYTES); //Copy the bytes into the new array
    delete(data); //We're done with the original array, remove it from the heap
    dataTerminated[NUM_MFR_BYTES] = 0; //Add that null char. NB: we don't need to '+1' the index because arrays start at 0, not 1

    return dataTerminated;
}

And here's how it's used in the main sketch:

void loop()
{
    char* data = mc1->getManufacturer();
    Serial.println(data);
    delete(data);
    delay(500);
}


texts: Arduino IDE says fcould not convert 'pinMode(buttons[((inti)], 0u)' from 'void' to 'bool'. How do I fix

texts:
Alright, so this code is for a game that is a power source connected to 6 buttons at ports 1, 2, 9, 11, 12, and 13. These are consequently supposed to light up 6 LEDs, each connected to 1. If you press the buttons in the right order, all the LEDs blink at once. Does it work?

#define DEBOUNCE 10  // button debouncer, how many ms to debounce, 5+ ms is usually plenty

// here is where we define the buttons that we'll use. button "1" is the first, button "6" is the 6th, etc
byte buttons[] = {1, 2, 9, 11, 12, 13}; // the analog 0-5 pins are also known as 14-19
// This handy macro lets us determine how big the array up above is, by checking the size
#define NUMBUTTONS sizeof(buttons)
// we will track if a button is just pressed, just released, or 'currently pressed'
volatile byte pressed[NUMBUTTONS], justpressed[NUMBUTTONS], justreleased[NUMBUTTONS];

void setup() {
byte i;

// set up serial port
Serial.begin(9600);
Serial.print("Button checker with ");
Serial.print(NUMBUTTONS, DEC);
Serial.println(" buttons");

// pin1 LED
pinMode(1, OUTPUT);

 // Make input & enable pull-up resistors on switch pins
 for (i=0; ipinMode(buttons[i], INPUT);
 digitalWrite(buttons[i], HIGH);
  }

 // Run timer2 interrupt every 15 ms
 TCCR2A = 0;
 TCCR2B = 1<<CS22 | 1<<CS21 | 1<<CS20;

 //Timer2 Overflow Interrupt Enable
  TIMSK2 |= 1<<TOIE2;

 }

SIGNAL(TIMER2_OVF_vect) {
check_switches();
}

void check_switches()
{
  static byte previousstate[NUMBUTTONS];
static byte currentstate[NUMBUTTONS];
 static long lasttime;
 byte index;

  if (millis() // we wrapped around, lets just try again
     lasttime = millis();
  }

  if ((lasttime + DEBOUNCE) > millis()) {
    // not enough time has passed to debounce
return;
  }
  // ok we have waited DEBOUNCE milliseconds, lets reset the timer
  lasttime = millis();

  for (index = 0; index digitalRead(buttons[index]);   // read the button

    /*
    Serial.print(index, DEC);
    Serial.print(": cstate=");
    Serial.print(currentstate[index], DEC);
    Serial.print(", pstate=");
    Serial.print(previousstate[index], DEC);
    Serial.print(", press=");
    */

    if (currentstate[index] == previousstate[index]) {
      if ((pressed[index] == LOW) && (currentstate[index] == LOW)) {
          // just pressed
          justpressed[index] = 1;
      }
      else if ((pressed[index] == HIGH) && (currentstate[index] == HIGH))        {
          // just released
          justreleased[index] = 1;
      }
      pressed[index] = !currentstate[index];  // remember, digital HIGH     means NOT pressed
    }
    //Serial.println(pressed[index], DEC);
    previousstate[index] = currentstate[index];   // keep a running tally  of the buttons
  }
}

void loop() {
  for (byte i = 0; i if (justpressed[i]) {
      justpressed[i] = 0;
      Serial.print(i, DEC);
      Serial.println(" Just pressed");
      // remember, check_switches() will CLEAR the 'just pressed' flag
    }
    if (justreleased[i]) {
      justreleased[i] = 0;
      Serial.print(i, DEC);
      Serial.println(" Just released");
      // remember, check_switches() will CLEAR the 'just pressed' flag
    }
    if (pressed[i]) {
      Serial.print(i, DEC);
      Serial.println(" pressed");
      // is the button pressed down at this moment
    }
  }
}

int questionNumberArray[] = {1, 2, 9, 11, 12, 13};//the array itself
const size_t n = sizeof(questionNumberArray) / //the array used
sizeof(questionNumberArray[0]);//the base of the array

for (size_t i = 0; i < n - 1; i++) //the loop itself
{
size_t j = random(1, n - i);
int t = questionNumberArray[i]; //integer output for increase
questionNumberArray[i] = questionNumberArray[j];//the value definition
questionNumberArray[j] = t;
pinMode(questionNumberArray, INPUT);
if (digitalRead(questionNumberArray) == HIGH) {
  then(digitalRead(1, 2, 9, 11, 12, 13 == High(3))
  break;
}
}

Also, how do I make it so that people have infinite times to try


texts: How can I get two Arduinos to "talk" to each other?

texts:
I'm pretty new to this whole thing so please excuse my lack of familiarity with terminology.

I'm looking to build two "buzzers" of sorts. One will live on the ground floor and the other will live on the fourth floor. There is wireless internet as well as wired internet available to connect the two.

This is the basic idea. I might put more frills in later. Both buzzers have one button and one LED. I want it so that once a buzzer's button is pressed, the LED lights on both buzzers will light up. Then, only when buzzer two's button is pressed, will the LED lights on both buzzers turn off.

I'm pretty tied up on the two Arduinos communicating with each other. Is it possible to do something like that?


texts: ESP8266-12E and MCP23017 , unable to identify the application

texts:
After googling much I have found that MCP23017 can be used with esp8266-12e for more number of output pins.
I have tried all the programs from different tutorials on internet but could not make it work.

Basically my question is , i want to control all the 16 leds connected to GPA0-7 AND GPB0-7 individually , hence i need a program snippet for make it work.
I am using AP mode for esp8266-12e and sending get methods with params to identify which led to turn on/off.

Even i have written the basic program , can anyone help me completing the entire program. thanks for the help in advanced.

Pins i have connected are

ESP8266-12E    |   MCP23017
−−−−−−−−−−−−−−−+−−−−−−−−−−−−−−
GPIO-14 (scl)  |  PIN-12 (SCL)
GPIO-2 (sda)   |  PIN 13 (SDA)
GND            |  A0,A1,A2

My code:

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

ESP8266WebServer server(80);

void handleRoot() {
    server.send(200, "text/html", "
You are connected
");
}

void setup() {
    delay(1000);
    Serial.begin(115200);
    Serial.println();
    Serial.print("Configuring access point...");
    WiFi.softAP(ssid, password);

    IPAddress myIP = WiFi.softAPIP();
    Serial.print("AP IP address: ");
    Serial.println(myIP);
    server.on("/", handleRoot);

    server.on("/led1", [](){});
    server.on("/led2", [](){});
    server.on("/led3", [](){});
    server.on("/led4", [](){});
    // up to 16 leds i have written same method.

    server.begin();
}

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


texts: Super-fast USB communication; how is it possible?

texts:
On Arduino forums, there's a post where someone improved the USB communication and made it super-fast. I don't understand how he did this, and I'm trying to recreate this, but failing.
My test code
I made a simple program on Python for testing; here it's:
import serial
import sys
import datetime

ser = serial.Serial(
   port = 'COM9',
   baudrate = 26*115200, #biggest number acceptable by python
   parity = serial.PARITY_NONE,
   stopbits = serial.STOPBITS_ONE,
   bytesize = serial.EIGHTBITS
)

if ser.isOpen() == False :
   ser.open()
   if ser.isOpen() == False :
      print("Can't open serial port")
      sys.exit(1)

start = datetime.datetime.now()
s = b'abc'*10000
ser.write(s)
total_len = len(s)
end = datetime.datetime.now()
speed = total_len/(end - start).total_seconds()/1e6
print("Speed: " + str(speed) + " MB/s")

And I made a simple Arduino program to read:
char buf[500];

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

void loop() {
  if (Serial.available() > 0) {
     Serial.readBytes(buf, 500);
  }
}

With this, my best result was 0.2 MB/s with my Arduino mega. However, on that post, they reached 12 Mbit/s = 1.5 MB/s!!!!! This is insane!
Atemmpting to achieve their result:
Apparently Arduino libraries are different than before, so just taking their code and putting it in my arduino\avr\cores\arduino directory doesn't work. So I started trying to edit the code myself. I'm a C++ dev, so supposedly this should be doable... but...
The problem I faced
So eventually, the problem I faced was that there are two Serial communication modes (apparently) UART and CDC. The code from the forum uses CDC, while my Arduino IDE uses UART. I tried enabling CDC using:
#define USBCON

but this lead to the error:
error: #error "Targets with both UART0 and CDC serial not supported"

At this point I don't know how to continue, as I'm not a hardware expert. But I'd like your opinion on this whole thing:

Is it possible to get these speeds? How?
If it's, why is it not in the default Arduino library?
In case there's no easy answer for the other questions, is switching from UART to CDC easy, so that I could continue my testing?


texts:
As part of the research I am involved with, the detection (not imaging) of UV (ultraviolet) sources, either emitters or reflectors is an important factor.

I am aware of the SparkFun UV Sensor Breakout - ML8511 component, which, according to the product specifications, has a decent broadband response across the UVA and UVB, with little amount of visible light.

Is there an Arduino component that only detects the UVB waveband (280nm to 320nm)?


texts:
I am working on a project with LED strips that would consume 12V and 20A. The problem is that the household wall outlet limitation is 15A, and 20A current draw would potentially start a fire. I have been searching for tutorials of large current LED project, and none of them really addresses the current draw problem.

I found an adequate power supply. It is Meanwell RSP-320-12. http://www.mouser.com/ProductDetail/Mean-Well/RSP-320-12/?qs=Uzd%2Fwh%252bZzhBChmc2p7rgKQ%3D%3D.

How can I make it work with a 15A wall outlet limitation?

Thanks in advance!


texts:
I want to install pip on the Yún which is running Linino OS but every time I execute the standard steps for opkg i.e.

# opkg update
# opkg install distribute
# okpg install python-openssl
# easy_install pip

Error

Searching for pip
Reading http://pypi.python.org/simple/pip/
Couldn't find index page for 'pip' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
No local packages or download links found for pip
error: Could not find suitable distribution for Requirement.parse('pip')

What is the reason behind this?

Kernel Information

Linux Arduino 3.3.8 #1 Fri Nov 14 08:57:34 CET 2014 mips GNU/Linux


texts: Problem with sending IR with at ATMega328P-PU

texts:
I have a sketch that sends an IR code every second. It works fine (the correct code is received by my receiving Arduino next to it) on the Arduino but when I try to move the sketch to an ATMega328P-PU, the IR no longer sends (the serial monitor output still works).
I have used a camera to look at the IR LED and it just doesn't flash on the ATMega328 but does on the Arduino (and I have tested my LED, it does work). It uses pin 3 on the Arduino, so I use pin 5 on the ATMega328.
Are there extra components that are needed to make PWM work without the Arduino board? I am honestly stumped so any help would be appreciated. Thanks in advance.
Sketch:
#include <IRremote.h>

IRsend irsend; //Setup the IR transmitter

int codeToSend;
int team = 1;
int damage = 0;

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

void loop()
{
    team++;
    if (team > 8) team = 1;
    damage++;
    if (damage > 99) damage = 0;

    if (damage > 9) codeToSend = (String(team) + String(damage)).toInt();
    else codeToSend = (String(team) + "0" + String(damage)).toInt();

    Serial.println("sent");
    irsend.sendNEC(codeToSend, 32);
    delay(500);
}


texts: How do I know the size of the bootloader of ATtiny? Is it the same as ATMega328P?

texts:
I burned the bootloader in ATtiny45 with the Arduino tool.

I want to know how much memory it has taken.
Is this bootloader the same code of a bootloader used in the 328P or other chips?
Can I see this code in any way, to know how it works?


texts:
I'm just starting to discover Arduino. Currently, I've done 2 lessons from Arduino book and I have few questions about second circuit.

Why we need to add 10kOm resistors after wire to 2 pin?
Why we need to add resistors after LED?
And why 3, 5, 6, 9, 10, 11 pins with "wave" symbol?


texts: how to make led fade on and blink while wav file plays

texts:
To clarify I'm extremely new to this and I'm using an Arduino Uno with a wave shield. My circuit works as intended but I haven't learned enough of the code to know what to do to make it do exactly what I want.

Right now the following code makes the sound play on button press but the led sequence doesn't at all. If I move root.rewind(); play(root); to after the last digitalWrite then the led sequence runs but the audio doesn't play until the led sequence ends. I'm out to make the audio play while the led sequence runs. Any suggestions?

if (state == 1) {
    root.rewind();
    play(root);
    for (i = 0; i < 255; i++) { // loop from 0 to 254 (fade in)
        analogWrite(LED,i);     // set the LED brightness
        delay(15);              // wait 15ms because analogWrite
                                // is instantaneous and we would
                                // not see any change
    }
    analogWrite(LED, HIGH);     // turns the LED on
    delay(300);                 // waits for a second
    analogWrite(LED, LOW);      // turns the LED off
    delay(100);                 // waits for a second
    analogWrite(LED, HIGH);     // turns the LED on
    delay(300);                 // waits for a second
    analogWrite(LED, LOW);      // turns the LED off
    delay(100);                 // waits for a second

    digitalWrite(RESET, LOW);
}


texts:
The following code works fine until I turn the if (tijd - action >= 500) into if (tijd - action >= 1000)

I wonder why this fails.

If I just loop and print the tijd - action it has no problem with it and runs well beyond 1000.

The Logic Analyzer on the software serial only returns '255' when it fails, I also wonder what that means.

The core I use is this one
The chip I use is an ATtiny85
I run this using the Arduino IDE 1.8.2

[update]

with "start"

Sketch uses 3070 bytes (37%) of program storage space. Maximum is 8192 bytes.
Global variables use 146 bytes (28%) of dynamic memory, leaving 366 bytes for local variables. Maximum is 512 bytes.

with "starting"

Sketch uses 3072 bytes (37%) of program storage space. Maximum is 8192 bytes.
Global variables use 148 bytes (28%) of dynamic memory, leaving 364 bytes for local variables. Maximum is 512 bytes.

script

#include <SoftwareSerial.h>
#include <avr/sleep.h>
#include <avr/wdt.h>

#define TX_PIN 4
#define RX_PIN -1

#ifndef cbi
  #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
  #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

SoftwareSerial mySerial(RX_PIN, TX_PIN);

unsigned long tijd;
unsigned long action = 0;

volatile boolean f_wdt = 1;
ISR(WDT_vect) {
  f_wdt=1;
}

void system_sleep() {
  cbi(ADCSRA,ADEN);                    // switch Analog to Digitalconverter OFF

  set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here
  sleep_enable();

  sleep_mode();                        // System sleeps here

  sleep_disable();                     // System continues execution here when watchdog timed out
  sbi(ADCSRA,ADEN);                    // switch Analog to Digitalconverter ON
}

void setup_watchdog(int ii) {
  byte bb;
  int ww;
  if (ii > 9 ) ii=9;
  bb=ii & 7;
  if (ii > 7) bb|= (1<<5);
  bb|= (1<<WDCE);
  ww=bb;

  MCUSR &= ~(1<<WDRF);
  // start timed sequence
  WDTCR |= (1<<WDCE) | (1<<WDE);
  // set new watchdog timeout value
  WDTCR = bb;
  WDTCR |= _BV(WDIE);
}

void setup() {
  mySerial.begin(2400);
  mySerial.print("Starting..");
  setup_watchdog(8);
  pinMode(0, OUTPUT);
}

int zie = 0;

void loop() {
  if (f_wdt==1) {
    digitalWrite(0, HIGH);
    tijd = millis();
    mySerial.print(".");
    mySerial.print(tijd - action);
    zie+=1;
    if (tijd - action >= 500) { // fails when set to 1000
      digitalWrite(0, LOW);
      action = tijd;
      mySerial.print("z");
      mySerial.print(zie);
      mySerial.print(".");
      system_sleep();
    }
  }
}


texts: Why was the Atmega16U2 used on the Arduino UNO as a USB to Serial converter?

texts:
This is the first time that I realized that extra SMD IC near the USB port of the Arduino UNO is actually a fully fledged microcontroller, I thought that it was just a USB to Serial converter. Further research into this chip left me with more questions than answers.

First of all, why did Arduino decide to use the Atmega16U2 as a USB to Serial converter? Couldn't they have gone with an FTDI chip instead? I came across this phrase on Quora "The best part is that you can also program and create your own applications on the 16u2 if you have an In-circuit Serial Programmer". How exactly does this work?

What about the two other set of connectors on the board? (other than the two main rows of headers) The ones labeled ICSP and JP2? Is the JP2 for the 16U2? I read that these could be used for burning the code onto the Atmega328P so that it can be modified, but not overwritten. What are any other uses for the 16U2 on the Arduino UNO?


texts: Is it possible to detect host usb device connected to arduino? and how?

texts: let's say that I've connected an arduino uno to a pc, or to a mobile phone via usb .. how can I detect the device type and the running operation system if it's possible?


texts: Arduino n00b here. I currently have an Arduino Nano set up to run 6 servos from a PCA9685 board. I'm looking to add 6 switches and 6 LED indicators to switch servo positions. What I'm curious about is how to connect the WS2818B. I know they can be run through I2C, but the Pca9685 is using those wires. Can I run both the pca9685 and the LEDs through I2C or just run each LED through a separate pin?


texts: Temperature Sensor not giving proper values

texts:
In my current project I am reading temperature through sensor which is having only two wires.

To read sensor values, I have used below schematic which I have found on Arduino Project Hub site.

In my project I am using below Arduino program.

#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();
}

void loop(void)
{
  // call sensors.requestTemperatures() to issue a global temperature
  // request to all devices on the bus
  Serial.print(" Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.println("DONE");

  Serial.print("Temperature is: ");
  Serial.print(sensors.getTempCByIndex(0)); // Why "byIndex"?
    // You can have more than one IC on the same bus.
    // 0 refers to the first IC on the wire
    delay(1000);
}

After doing all this I am getting this output on serial monitor.

At which step I am doing wrong?


texts: It seems that the last several times I've tried to open Arduino IDE I've encountered an error that says Launch4j, "an error occurred while starting the application".  It takes some time before that happens.  I think I've seen some stuff online about this, however I've seen some mixed answers and results for how to solve that problem.  I'm using it on a Windows 7, 64 bit system.  I've tried opening it up while my Arduino was connected and it didn't work.


texts: Arduino as USB HID is slowed down when PC doesn't read events

texts:
I have an Arduino Micro that is acting as a HID device for a Linux PC.

I use this call to send the HID values:

HID().SendReport(1, _values, sizeof(_values));

This works in principle, but I noticed this issue:

If my Linux PC is not actively reading the events from the Arduino, then the Arduino is slowed down. My rotary encoders are missing signals, is one symptom.

But as soon as I read the events with my Linux PC, the Arduino loop() runs at full speed again.

I suspect that this is due to recv/send time out delays in the USB core code? Because I noticed this in USBCore.cpp:

u8 timeout = 250;               // 250ms timeout on send? TODO

Anyway, I tried to solve this issue in the following manners:

Check for configuration and suspension with:

     if (USBDevice.configured())
      if (!USBDevice.isSuspended())
         ...

Which did not work.

I also tried monitoring the increments of the frame number:

  // See if USB shows activity.
  static uint8_t prev_fr_num = UDFNUML;
  static uint8_t num_times_idle = 0;
  uint8_t fr_num = UDFNUML;
  if (fr_num == prev_fr_num )
  {
    if (num_times_idle < 255)
      num_times_idle++;
  }
  else
  {
    num_times_idle = 0;
    prev_fr_num = fr_num;
  }

And then only send if num_times_idle is smaller than a threshold. Again, this did not help.

The only way to make it fast, is by reading the events with linux, like so:

$ jstest /dev/input/js0

or alternatively:

$ evtest /dev/input/event5

How can I have the USB HID stuff not slow down my loop code when the PC is not paying attention?

Thanks!

Bram


texts:
I have a ProtoCentral FDC1004 board (datasheet: http://www.ti.com/lit/ds/symlink/fdc1004.pdf) connected to an Arduino. I am then trying to connect to the system via matlab.

I have found the address (0x50) using addrs = scanI2CBus(a) and I am now trying to read measurements from it.

Page 15 of the datasheet says the following to trigger measurements:

 1. Setting REPEAT (Register 0x0C:bit[8]) to 0.
 2. Setting the corresponding MEAS_x field (Register 0x0C:bit[7:4]) to 1.
    – For example, to trigger a single measurement of Measurement 2 at a rate of 100S/s,
    set Address 0x0C to 0x0540.

Q1: How do I work out where the value "0x0540" comes from?

Q2: I don't seem to be able to write this value, I'm able to write other values to this register and read them back however. How can I write 0x0540 to this register?

My matlab script is as follows:

a = arduino('COM7', 'Uno', 'Libraries', 'I2C');
capdev = device(a,'I2CAddress',0x50);

writeRegister(capdev, 0x0C, 0x0540,'uint16');
readRegister(capdev,0x0C,'uint16')
value1 = readRegister(capdev,0x02,'uint16')
value2 = readRegister(capdev,0x03,'uint16')

readRegister(capdev,0x0C,'uint16') simply displays the last value I wrote to this register during testing (eg 3)

0x02 and 0x03 are supposedly where measurement 2 is stored. These read as 0.

Q3: Any idea what I'm doing wrong, or how to implement this correctly?

Thank you!


texts: Using a 12V DC adapter to power Arduino nano, 12v Solenoid and an Hygrometer

texts:
First of all I am very novice in electronics so bare with me.

I am trying to make a self watering system using arduino nano, first I tried the fly fish hygrometer module with the 5V power of the Arduino, and that worked.

Then I wanted to add the 12V solenoid, so I changed to a 12V external power through the Vin.

My goal is to use only one power source.

This is what I have done so far:

And Schematics

My question is:

Can I power the hygrometer module using for the positive the 5V outlet of the Arduino nano and the ground from the 12V power source as shown in the figures?

Or will this burn the module or screw the readings?


texts: Wifi networking with ESP8266 (NODEMCU version)

texts:
I am doing some experiments with nodemcu 12 (which has built in esp8266). There most of the tutorials I found by internet describe how to connect to home wifi connection using it.

But when I power on nodemcu, I can see wifi network called "ESPXXX" in my laptop's wifi connection list.

So is there a way to directly connect to the wifi nw of esp8266 by my laptop or via another esp8266 (so I don't have to switch on my home wifi router)?

If it is possible, is there is way to change ssid of esp8266's wifi connection and add password (again this is not about connecting to home wifi and this is about the wifi connection on esp8266 it self)?
So we can make one esp8266 as a wifi host and connect other esp8266s as slave to it.

I am using arduino IDE to upload program into esp8266 and not Lua.

Thanks.


texts:
I'm working on an arduino project that uses the GSM Shield and the eHealthSensor from Cooking Hacks. However I ran into an issue in which the interrupt vectors from the header/cpp files used are being defined multiple time.

While I know where the definitions are, I am unsure as to how to circumvent this issue either by Arduino programming or modifying the files since I'm not too experienced in this field. Below are the code for the conflicting files.

Below are the vectors that are in conflict.

PinChangeInt.h

    #ifndef NO_PORTA_PINCHANGES
    ISR(PCINT0_vect) {
        #ifdef PINMODE
        PCintPort::s_PORT='A';
        #endif
        PCintPort::curr = portA.portInputReg;
        portA.PCint();
    }
    #define PORTBVECT PCINT1_vect
    #define PORTCVECT PCINT2_vect
    #define PORTDVECT PCINT3_vect
    #else
    #define PORTBVECT PCINT0_vect
    #define PORTCVECT PCINT1_vect
    #define PORTDVECT PCINT2_vect
    #endif

    #ifndef NO_PORTB_PINCHANGES
    ISR(PORTBVECT) {
        #ifdef PINMODE
        PCintPort::s_PORT='B';
        #endif
        PCintPort::curr = portB.portInputReg;
        portB.PCint();
    }
    #endif

    #ifndef NO_PORTC_PINCHANGES
    ISR(PORTCVECT) {
        #ifdef PINMODE
        PCintPort::s_PORT='C';
        #endif
        PCintPort::curr = portC.portInputReg;
        portC.PCint();
    }
    #endif

    #ifndef NO_PORTD_PINCHANGES
    ISR(PORTDVECT){
        #ifdef PINMODE
        PCintPort::s_PORT='D';
        #endif
        PCintPort::curr = portD.portInputReg;
        portD.PCint();
    }
    #endif

    #ifdef __USE_PORT_JK
    #ifndef NO_PORTJ_PINCHANGES
    ISR(PCINT1_vect) {
        #ifdef PINMODE
        PCintPort::s_PORT='J';
        #endif
        PCintPort::curr = portJ.portInputReg;
        portJ.PCint();
    }
    #endif

    #ifndef NO_PORTK_PINCHANGES
    ISR(PCINT2_vect){
        #ifdef PINMODE
        PCintPort::s_PORT='K';
        #endif
        PCintPort::curr = portK.portInputReg;
        portK.PCint();
    }
    #endif

    #endif // __USE_PORT_JK

GSM3SoftSerial.cpp

// This is here to avoid problems with Arduino compiler
void GSM3SoftSerialMgr::manageMsg(byte from, byte to){};

//#define PCINT1_vect _VECTOR(2)
//#undef PCINT1_vect

#if defined(PCINT0_vect)
ISR(PCINT0_vect)
{
  GSM3SoftSerial::handle_interrupt();
}
#endif

#if defined(PCINT1_vect)
ISR(PCINT1_vect)
{
  GSM3SoftSerial::handle_interrupt();
}
#endif

#if defined(PCINT2_vect)
ISR(PCINT2_vect)
{
  GSM3SoftSerial::handle_interrupt();
}
#endif

#if defined(PCINT3_vect)
ISR(PCINT3_vect)
{
  GSM3SoftSerial::handle_interrupt();
}
#endif

Any advice on how to fix this will be greatly appreciated.

If it helps, I am using an Arduino Mega 2560.


texts:
I am trying to communicate with PC by using modbus TCP communicate. When I use this code I can't communicate. Dou you know guys what is the problem? My ethernet Module is working I know that because I can ping it when I use different code from EtherCard.h library. But when I try to use Ethernet and Modbus library I can't communicate. I can't ping it.
#include <ModbusIP.h>
#include <SPI.h>
#include <Ethernet.h>
#include <Modbus.h>

int setPoint;zz
const int setPoint_IR = 100;

ModbusIP mb;

void setup() {
  Serial.begin(9600);
  byte mac [] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
  byte ip [] = {10, 0, 58, 37};
  mb.config (mac, ip);

  mb.addIreg(setPoint_IR);

}

void loop() {
  mb.task();
  setPoint = analogRead(A0);
  mb.Ireg(setPoint_IR, setPoint);
}

void DisplaySetPointValues(){
  String Printstr;
  Printstr = "Set point values = " + String(setPoint);
  Serial.println(Printstr);
}


texts: How can I connect more sensors when my lcd is blocking pin access?

texts:
So, I have a lcd that takes up the whole board of an arduino mega. I want to connect a temperature sensor and make a really lame weather station, but the lcd screen is totally in the road. It's a shield so this is to be expected.

I've come up with wacky ideas, like soldering to the rear of the board but I think that's a bad idea. Surely there must be a better way? The lcd shield exposes no pins.


texts: How to use an Arduino to measure speed of rocket

texts:
I am not very experienced with Arduino and I am trying to learn it. I was wondering what is the easiest and most effective way to calculate speed and log it every second so to say. This would be mounted in a model rocket to see what speeds it can reach. How would I achieve this?

Would it be hard to send over RF to see it in real time?

Thanks in Advance


texts: turning positional servo motor more then 180 degrees

texts:
My RC servo motor is capable of turning more then 180 degrees(around 200 degrees) when I physically turn it, but when I use my code it only turns 180.

Is there a way to code it so that it turns to 200 instead of 180?


texts: Arduino Ethernet Shield 2: How can I automatically determine the MAC Address?

texts:
I'm using an Arduino Mega.
I know that Ethernet Shield 2's come with a sticker with the MAC Address printed on it. This would imply to me that this address is hardcoded into the shield. Is there any way to recover the MAC without manually entering it in the sketch?
Thanks!


texts:
According to page 10 of this PDF https://www.sparkfun.com/datasheets/LCD/HD44780.pdf

The HD44780 has enough DDRAM to operate an 80 character display. A 16x2 display has 32 characters meaning we have 48 characters of free DDRAM. Is there anything in the Arduino's LiquidCrystal library which allows direct access to this DDRAM space? The HD44780 datasheet says it can be used as generalised RAM.


texts: Arduino serial communication input string checking

texts:
I am trying to check whether the input string in my serial is inside my string array, but it seems like that the condition if(array[i]==inputString) does not print true.

So here is my code:

String array[4]={"hey","jude","jane"},inputString,test;
boolean stringComplete=false;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  //int store=0;
  serialEvent();
  if(stringComplete){
    Serial.println(inputString);
    for(int i=0;i<4;i++){
      Serial.println("..");
      //test=array[i];
      Serial.println(array[i]);
      if(inputString==array[i]){
        Serial.println("true");
        break;
      }
    }
  inputString="";
  stringComplete=false;
  }
   //Serial.println(store);
}

void serialEvent() {
  while (Serial.available()) {
    char inChar = (char)Serial.read();
    inputString += inChar;
    if (inChar == '\n') {
      stringComplete = true;
    }
  }
}


texts: Timeout error uploading code to Arduino Mega 2560

texts:
I am new to Arduino programming, and my first sketch (from a tutorial) failed to upload. I am having trouble trying to figure out what is causing it (have tried to upload the sketch using different COM ports on my Mac).

Here's my setup:

  USB COM Port -> Arduino Mega 2560 -> Grove Mega Shield -> Grove Temperature Sensor
  v1.2 connected to Mega Shield UART0.

Here's the code from the tutorial:

// Demo code for Grove - Temperature Sensor V1.1/1.2
// Loovee @ 2015-8-26

#include <math.h>

//R0 = 100000 results in 'overflow in implicit constant conversion'

const int B=4275;                 // B value of the thermistor
const int R0 = 100000;            // R0 = 100k
const int pinTempSensor = A5;     // Grove - Temperature Sensor connect to A5

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

void loop()
{
    int a = analogRead(pinTempSensor );

    float R = 1023.0/((float)a)-1.0;
    R = 100000.0*R;

    float temperature=1.0/(log(R/100000.0)/B+1/298.15)-273.15;//convert to temperature via datasheet ;

    Serial.print("temperature = ");
    Serial.println(temperature);

    delay(100);
}

And here's the error output:

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_cmd(): short reply, len = 0
avr_read(): error reading address 0x0000
    read operation not supported for memory "signature"
avrdude: error reading signature data for part "ATmega2560", rc=-2
avrdude: error reading signature data, rc=-1
avrdude: stk500v2_ReceiveMessage(): timeout

What I have done so far:

1) Disconnect and reconnect USB Cable
2) Restart Arduino IDE (1.6.9)
3) Changed COM Ports
4) Press the reset button

Could someone please explain to me what the error output means?


texts: Change Digispark clock speed, run at low voltage?

texts:
I have a low voltage (3.2v) application. I was hoping to use the Digispark. I have a solution using a separate Tiny85, but want to use the Digispark USB programming.

To run at lower voltage I think you need the lower clock rate. I have done this using the standalone Tiny85. I could hook up the Digispark to the programmer direct and change the frequency fuses, however...

I assume reducing the clock rate by programming the fuses would break the Digispark boot loader as it would have the wrong timing. Correct?

Can I dynamically switch the clock frequency in my code after the bootloader or is it fuse controlled only?

Is the bootloader available and could I change it to a lower frequency? Would there be a lot of work changing the code to a different freq? Would it be powerful enough to run the USB bootloader?


texts: Will plugging in a 12v power supply in the wrong polarity to a CNC SHIELD fry my circuit or damage my power supply?

texts:
I'm currently in the process of making a DIY pen plotter using an Arduino CNC Shield and GRBL Code. Right now I'm connecting the power supply to the shield. I got a standard 12v supply and I cut off the barrel connector so I can connect the supply directly to the CNC Shield. I can't seem to figure out which wire is negative and which is positive. I don't have a multimeter on me so can't test it but I have attached a picture of the information on the power supply which I think should be able to give someone with more knowledge, insight onto the polarity. I think the left wire is negative but not one hundred percent sure. If I risk a test will this damage my circuits or power supply ? Sorry for such an easy question I just don't want to accidentally fry my circuits as have been working on this for a really long time !!
Thank you so much,
Arav


texts:
Hi I have a program that does not work right as I aspect:

v = tempC;
h = tempC * 10;
h = h % 10;
memset(stempCA, 0, sizeof(stempCA));
sprintf(stempCA, "%+.2d.%d", v, h);

it works fine on positive temperature "+11.22"
but not for negative values : "-02.-1"

where is my mistake?
 thanx


texts:
I am using the ESP32 in soft access point mode. In other words I specify my wifi username and password on the ESP32 and I am able to connect to it from my phone.
So I am not using any router or internet connection. Only my phone and the esp32.
If my phone is the only device on the network created by the esp32 do I have to worry about HTTPS? People say HTTP is not secure and I also know how easy it is to see http traffic with Wireshark. But if no one else has access to the network I guess http is secure correct? If no one knows the wifi password will my http requests be encrypted? Moreover, if I connect from my computer instead than my phone via wifi to the ESP32 and send UDP packets will those be encrypted?


texts: Feedback Request: HID USB to Bluetooth Relay

texts:
Bluetooth Relay Project:

  Develop a USB to bluetooth adapter for my mechanical keyboard. Using a USB host shield, have an Arduino Pro Mini read keyboard usb commands and repeat them over bluetooth.

I have minimal experience with Arduino and circuitry, from my perspective this project seems pretty straight forward plug and play of the hardware components.

I plan to use the following hardware:

Hardware:

Arduino

Arduino Pro Mini 328 - 3.3V/8MHz
Sparkfun Products: 11114

Bluetooth HID module

BlueSMiRF HID
Sparkfun Product: 10938 ($25)

USB Host Shield

USB Host Shield for Arduino Pro Mini
circuitsathome ($20)

Power Source

USB Phone power block
Output: 5v 1000mA

Total Cost: $55

I will be connecting the USB module by following the write up here and will be connecting the USBHost shield by following this guide and this guide

Does anyone have any comments/suggestions/concerns/words of wisdom before I start to order stuff?


texts:
I'm trying to get an arduino to generate a random pattern in a neopixel grid every time you restart it. But I only get the same number sequence generated each time. What I'm doing wrong?

Here's the sequence that keeps happening: 1110 0000 1101 0011

Here's the code I have so far:

/* ========================== INCLUDES ================================= */
#include "RGB.h"

#include <Adafruit_NeoPixel.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_GFX.h>
#ifndef PSTR
 #define PSTR // Make Arduino Due happy
#endif

/* ========================== NEOPIXELS SETTINGS ================================= */
#define NEOPIN 6
#define MATRIX_W 4
#define MATRIX_H 4

Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(MATRIX_W, MATRIX_H, NEOPIN,
  NEO_MATRIX_BOTTOM + NEO_MATRIX_LEFT +
  NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
  NEO_GRB + NEO_KHZ800);

/* ========================== BOARD / GRID STUFF ================================= */

/* coordinates for a 4 x 4 grid
00,10,20,30
01,11,21,31
02,12,22,32
03,13,23,33,
04,14,24,34
*/

int land[4][4] = {};

/* ========================== SETUP AND LOOP ================================= */

void setup(){

  Serial.begin(9600);

  matrix.begin();
  matrix.setBrightness(60);
  matrix.fillScreen(matrix.Color(off.r,off.g,off.b));
  crossFade(off, white, 50, 5);
  drawLand();
}

void loop(){
  matrix.show();
}

/* ========================== FUNCTIONS ================================= */

  void drawLand() {
  for(int row = 0; row < MATRIX_W; row++) {
    for(int column = 0; column < MATRIX_H; column++) {

     land[row][column] = random(0,2);

     Serial.println(land[row][column]);
     if(land[row][column] == 1) {
       matrix.drawPixel(column, row, matrix.Color(red.r,red.g,red.b));
     }
   }
  }
}


texts: NODEMCU 1.0 HX711 Load cell reading weird text

texts:
Hi Guys! i have a problem with the reading with my NODEMCU where i tried this code on an arduino UNO it is working perfectly fine but until i tried to switch it to NODEMCU 1.0 which have a wifi function that i need, the reading turn out to have this type of error, i've tried looking for solution online and tried every single of them but apparently none of it help. The image is the error i have faced and the connection i have made from the nodemcu to hx711 is VCC --> Vin or 3.3v, GND --> GND, DT --> D2, SCK --> D3.
Here's the code that i found online to use:

#include <HX711.h>

// Scale Settings
const int SCALE_DOUT_PIN = D2;
const int SCALE_SCK_PIN = D3;

HX711 scale(SCALE_DOUT_PIN, SCALE_SCK_PIN);

void setup() {
  Serial.begin(115200);
  scale.set_scale(-47740);// <- set here calibration factor!!!
  scale.tare();
}

void loop() {
  float weight = scale.get_units(1);
  Serial.println(String(weight, 3));
}

Thanks in advance!!


texts: Using Arduino BLE Nano to switch an electric circuit on and off

texts:
I'd like to use an Arduino Nano BLE to activate or deactivate an electric circuit.

I intend to use a relay to do so, but activating a relay seems to require a current with more intensity than what we can get out of a digital output (about 20 mA).

Is there a way to get more intensity out of a BLE nano ?

Are there others components that could behave the same way as a relay but could react from a digital output ?


texts: How to send Serial.Print only If Serial Connection is open?

texts:
So I looked through the Arduino Mega2560 documentation and searched the web for a solution, and so far I haven't had any success.

What I'm trying to accomplish is fairly simple. I need to send a serial command over serial, ONLY if there is a serial connection between the PC and the Arduino. I've tried:

If(Serial){
   Serial.Println("COMMAND");
}

That doesn't work, and I think it's because the Arduino cannot distinguish between listening to the Serial port versus establishing a Serial connection.

Any help would be appreciated.

Cheers!


texts: How to logically tell than an UNO is being, or about to be programmed

texts:
I have an MIDI application that uses the RX and TX serial interface.  When I program the UNO there is a collision between the on board programmer and the MIDI application RX serial port.  The MIDI shield provides a jumper to disconnect to prevent the collision during programming.

I would like to add a FET switch to open and close if I am programming, but it's not clear to me that there is a signal I can tap into on the UNO that indicates programming is about to start or that it has just finished.

I was thinking about using a pull up on a digital pin on the UNO that drives low when the program starts up. That might be the way to go, but I assumed that this must be a common issue with a common solution that I am just not finding on stack exchange.
Is there a standard logical way to tell that UNO is about to be programmed via the onboard USB port?


texts: Porting "far" flash memory access from Arduino Mega to Due

texts:
I have a project that runs on the Arduino Mega 2560 which takes up almost the complete amount of flash memory available (https://github.com/fredlcore/bsb_lan/blob/master/BSB_lan.ino). Because of this, I'm planning on migrating the project to the Arduino Due.

My main problem at the moment is to port those functions that access flash memory in the "far" memory area (>64k) for which on the one hand various _PF functions (like strncpy_PF) are provided, and on the other hand a dummy "pointer" type uint_farptr_t (which is actually uint32_t) is available.

My problems now are twofold:

While the _PF functions have specific definements for the Due which under "normal" circumstances should work without changes in the code, they expect different variable types. For example, strncpy_PF takes uint_farptr_t (i.e. uint32_t) as argument for src on the Mega, it expects a const char * on the Due. Compilation thus results in lots of errors.
For the Mega to be able to access char arrays (which are 16 Bit on the Mega) above 128k, I need a rather dirty workaround (see function calc_enum_offset() in the code linked above). Basically I need to take the memory address of a 16 Bit char pointer and make some calculations to get the final address from which I read the strings. On the Mega, I can do these calculations on the basis of uint_farptr_t and then read from the calculated memory address with pgm_read_byte_far() for example. On the Due, however, pgm_read_byte_far(addr) is translated to (*(const unsigned char *)(addr)). Again, the uint32_t type does not fit this.

Do you have any suggestions on how I should tackle these issues with the least amount of code?


texts:
I tried Google, I tried a bunch of forums and I searched here. This question needs a final answer:

Which GSM-shield is most efficient for GPRS communication?

Since Arduino is the amateurs best friend for home automation and IoT, an "efficient" shield has a very low power consumption.

I am currently developing a system that collects some data from different sensors at a place far, far away, with limited access to power (e.g. it has a very small solar panel and a battery). It is also in pocket-size which makes a car battery a bad option.

Anyway, this specific device reads these sensors every 20 minutes, and if there's a deviation since the previous reading it starts the GSM module to send the new data to my API.

SMS and call features are of absolutely no interest at all.

Since these GSM-power-absorbing-current-eating-devils really like power I must think outside the box and compare different alternatives. So besides the primary question in this post, is there any way you can limit the power consumed, for example by limit the connection speed or anything like that? I'm using a M590 module at the moment, and that beast can eat around 2A if it's hungry.

Thanks in advance :)


texts: Should BLK and GRN of Pro Mini be connected to upload sketch?

texts:
Is the following connector is valid for Arduino Pro Mini (no BLK and GRN)?

I was told to make a certain Arduino application, and got some Arduino Pro Mini  (ATmeag328 3.3V 8 MHz) with the connector above.

Everytime I tried to upload an example sketch 'Blink', the IDE complains (verbose enabled):

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

resp may differ (I saw 0x1f and 0x83)

But, according to the official document,  I think that I should use some FTDI thing, which has 6 pins including BLK and GRN.

I wonder whether I can use the existing 4-pin connector, or whether I must use 6-pin FTDI connector.


texts: is any windows application available for accelerometer based computer mouse

texts:
I want to make an AIR mouse using Arduino
and accelerometer, for this i used USB to TTL
converter i have done everything successfully
but can anyone tell me how use it in computer.
I mean i don't know how to make computer
application for this mouse. please suggest me
any application for this. And give any idea for
"how can i use Bluetooth for this."


texts: L293D to change the direction current and amplify it - Temperature-Stabilizer

texts:
I have a question about my project. I'm going to make a temperature-stabilizer. To make this, I think I should use a TEC with a H-bridge and a LM35. First of all, I tried to make a H-bridge by myself, I have only used four NPN transistors and It didn't go well. Then I bought L293D motor driver - not the module one, tried it and it works well. But as datasheet says, it's output current is max 600mA. But this current doesn't make TEC work efficiently. So that, I need to amplify the current. But I don't want to buy high amp motor drivers, hardwares are to expensive in my city. Of course I'll if there's no another way.

Arduino will be used to get temperature values from LM35 and give the H-bridge voltage, control the current direction when necessary. I learned how to use transistors to amplify but if I'll change the direction, it won't work. But I don't know how to make this circuit.

The algorithm that I thought using is this:

The scheme that I thought using in this:

What should I do to solve my problem? Thank you for all.

Resources:

My Tec1-12706 Datasheet:
http://www.thermonamic.com/TEC1-12706-English.pdf
LM35 Datasheet - (I have LP package):
https://www.ti.com/lit/ds/symlink/lm35.pdf
L293D Datasheet: https://www.ti.com/lit/ds/symlink/l293.pdf
The transistor method to amplify:
https://www.youtube.com/watch?v=WZD9RZoMhVE


texts:
I have an Arduino ATmega8A. I tried to use its analog inputs. Initially I used a normal program without using aref and connected potentiometer at A0 and I got expected values.

After that for accuracy I used a LM431 circuit for 2.5V reference. Programmed the Arduino and I again got expected values. It was working properly until this stage.

For more accuracy I tried using LM317 1.25 reference as voltage reference for aref pin. The problem comes here. When I run the program initially the values were changing from maximum value. Like it was showing 1.25, when I changed the resistance on the potentiometer it was changing its value for a sec. and again showing maximum value 1.25. I off the circuit and tried it once again. At that time there were no changes and it was giving me maximum value.

I thought there is a problem in my LM317 circuit or my LM317.

I connected the LM431 circuit again and changed the program and run it once again, the outputs were giving me maximum value i.e. 2.5 ,outputs values  were not changing as I change resistance on potentiometer. So I tried with normal program without using aref pin, the same thing happened there.

This is program without using potentiometer

int r;
float v;

void setup()
{
  analogReference(EXTERNAL);
  pinMode(A0, INPUT);
  Serial.begin(9600);
}

void loop()
{
  r = analogRead(A0);
  v = (5.0 / 1023.) * r;
  Serial.println(v);
  delay(250);
}

The potentiometer is connected at A0 and the other 2 pins are connected to + 5v and gnd. Initially it was working properly

The program using vref

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
float exRef = 2.52;

int r;
float v;

void setup()
{
  analogReference(EXTERNAL);
  analogWrite(6, 20);
  lcd.begin(16, 2);
  pinMode(A0, INPUT);
}

void loop()
{
  r = analogRead(A0);

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Voltage:");
  lcd.setCursor(8, 0);
  lcd.print(convert(exRef, r), 5);
  delay(1000);
}

float convert(float exref, int r)
{
  return (((float) r / 1023.) * exref);
}

I have interfaced Arduino with lcd too.
I set aref to 2.5 the program and connected to lm431 circuit it was working properly.
After that I connected Arduino to lm317 circuit and set aref to 1.25. As I  connected it it was giving me maximum value
After that I tried with normal program that is first one without using aref it was still giving me maximum value.

![lm317 circuit](https://i.stack.imgur.com/KvkNS.jpg


texts: Command through Serial monitor does not properly work in Arduino

texts:
I am executing a function in Arduino by giving String input to the serial monitor.

The issue here is when i enter "SHOW$" (without quotes) the function showData() works but when i enter the same "SHOW$" (without quotes) it doesn't gets called.
I want to call the function showData() every time i enter the "SHOW$" text into the serial console.

My question here is to what mistake i am doing here, and what is the solution for this.

String strReq = "";
char inChar = 0;

void setup() {

  Serial.begin(9600);

}

void loop() {

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

    if (inChar == '$') {

     Serial.println(" Received String :");
     Serial.print(strReq);

     if (strReq.equalsIgnoreCase("SHOW"))
       showData();

     Serial.flush();
     strReq = "";

    } else {

      strReq = strReq + inChar;

    }

  }

}

void showData() {

  Serial.print("Showing Information");

}


texts:
I'd like to connect a 12V access control device to the Arduino, but I lack the understanding.

How can the signals from and to the device be done when they have different voltages?

I am afraid that the 12V would brick the Arduino.


texts:
Learning how to program with Arduino, but the learning curve is out of my league.

I have this

    #include <FastLED.h>
    #define NUM_LEDS 4
    #define DATA_PIN 3

        CRGB leds[NUM_LEDS];

           void setup() {
       FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
   }

       void loop() {
      // Turn the first led red for 1 second
      leds[0] = CRGB::Green;
      leds[1] = CRGB::Red;
      leds[2] = CRGB::Green;
      leds[3] = CRGB::Red;
      FastLED.show( 99 );
      delay(1000);

      // Set the first led back to black for 1 second
      leds[0] = CRGB::Red;
      leds[1] = CRGB::Green;
      leds[2] = CRGB::Red;
      leds[3] = CRGB::Green;
      FastLED.show( 99 );
      delay(1000);
    }

So, I want them to fade from green to red.
led 1 is green, and led 2 is red
I should probably program this in a different way, but I don't know how.
Any ideas are welcome!


texts:
I have a Lolin NodeMCU V3 with a broken USB port: no power, no data.

It does show up on WIFI as AI-thinker_xxx, I can connect, but what can I do next?

Is there a way to program the NodeMCU Over the Air (OTA), or through some pins?

Description found here under V3


texts:
Are loops not allowed in setup()? The following doesn't print anything inside the for loop to the serial terminal

Code:

void setup() {
  Serial.begin(9600);
  Serial.println("Ping");
  for (int i = 0; i >= 10; i++) {
    Serial.println(i);
    Serial.println("Pong");
  }
}

void loop() {

}

Output:

Ping


texts: Help with reading and storing data from sim module

texts:
I'm using a sim800C module and an Arduino Uno. I want the code to send back an SMS to a number which sends it the password. So, if the sim module receives 'abcd' I want it to send back an SMS, saying 'ok'. Where I'm stuck is actually storing the read SMS. Since I need to check the SMS with a pre-defined password, I need to store the SMS the module received somehow. Please help ? Here's the code so far:
#include <SoftwareSerial.h>
SoftwareSerial sim(10, 11);
int _timeout;
String _buffer;
String number = "+000000000000"; //-> change with your number
String incoming;

void setup() {
  //delay(7000); //delay for 7 seconds to make sure the modules get the signal
  Serial.begin(9600);
  _buffer.reserve(50);
  Serial.println("System Started...");
  sim.begin(9600);
  delay(1000);
  Serial.println("Type s to send an SMS, r to receive an SMS, and c to make a call");
}

void loop() {
  char inChar[5];
  if (Serial.available() > 0)
    switch (Serial.read())
    {
      case 's':
        SendMessage();
        break;
      case 'r':
        RecieveMessage();
        break;
    }
// this is where the sim module spits back the received SMS to the serial monitor. How do I store it ?
  if (sim.available() > 0) {
    Serial.write(sim.read());

  }
}

void SendMessage()
{
  //Serial.println ("Sending Message");
  sim.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
  delay(1000);
  //Serial.println ("Set SMS Number");
  sim.println("AT+CMGS=\"" + number + "\"\r"); //Mobile phone number to send message
  delay(1000);
  String SMS = "GPS-cordinates";
  sim.println(SMS);
  delay(100);
  sim.println((char)26);// ASCII code of CTRL+Z
  delay(1000);
  _buffer = _readSerial();
}

void RecieveMessage()
{
  Serial.println ("SIM800C Read an SMS");
  delay (1000);
  sim.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
  delay(1000);
  Serial.write ("Unread Message done");
}

String _readSerial() {
  _timeout = 0;
  while  (!sim.available() && _timeout < 12000  )
  {
    delay(13);
    _timeout++;
  }
  if (sim.available()) {
    return sim.readString();
  }
}


texts:
void storedata(File filename ,int type , String data)
{
    if(type == 1){
      Serial.println("Group Creation");
    }
    //Storing Data into file
    pinMode(10, OUTPUT);
    if (!SD.begin(SD_CS_PIN)) {
    Serial.println("initialization failed!");
    return;
  }
    Serial.println("initialization done.");
    filename = SD.open("filename.txt", FILE_WRITE);
    if (filename) {
    Serial.print("Writing to filename.txt...");
    SdFile file("sdfile.txt", O_WRITE | O_CREAT);
    if (!file.isOpen()) {
    Serial.println("filename.txt");
   }
    sdfile.println(data);
    //close the file:
    filename.close();
    Serial.println("done.");
    }else{
    // if the file didn't open, print an error:
    Serial.println("error opening filename.txt");
  }}

Im using this function to write on the Sd card , before calling this function the sketch memory is 28802 bytes ie ) 93% , simply just by calling this function from setup increased the sketch memory to 102% and iam unable to compile is there any unusual memory usage in this code ?


texts:
I am trying to use the Arduino Servo library to drive a simple servo and am having some difficulty getting it to even move.

Here's the setup:

And the schematic that Fritzing generated for me:

And the code:

#include <Servo.h>

int SERVO_SIGNAL_PIN = 9;

Servo servo;
int pos = 0;
bool GOING_UP = true;

void setup() {
    // Attach the servo and give it a few seconds to reset to the starting position.
    servo.attach(SERVO_SIGNAL_PIN);
    servo.write(0);
    delay(5000);
}

void loop() {
    if((GOING_UP && pos < 180) || pos == 0) {
        GOING_UP = true;
    } else {
        GOING_UP = false;
    }

    int step = 1;

    if(!GOING_UP) {
        step *= -1;
    }

    pos += step;

    servo.write(pos);
    delay(15);
}

When I run this, nothing happens. When I attach a multimeter and set it to the "6V" setting, I have found some strange readings:

When I connect the red multimeter lead ("red lead") to the 5V line connecting the Arduino to the breadboard, and the black multimeter lead ("black lead") to the black GND line connecting the Arduino to the breadboard, I get readings around 5V; but...
When I connect the red lead to the red power line going to the servo, and the black lead to the black GND line coming back from the servo, I get a voltage reading of roughly -20V!!!

I'm not sure what this means/implies. Is anything jumping out at anyone? Anything I can troubleshoot here? Thanks in advance!


texts:
I have a functon that creates a instance of KeyReport and I want to fill statically the KeyReport.keys array. I'm new in the Arduino world so I'll put a example to explain it better:

void sendKey(byte keys[6], byte modifiers)
{
  KeyReport report = {0};

  report.keys = keys; // This is my main trouble
  report.modifiers = modifiers;
  report.reserved = 1;
  Keyboard.sendReport(&report);
}

void setup(){
delay(3000);
sendKey( {0x17,0,0,0,0,0}, 0x5); // I want to send hardcoded reports like this
}

void loop(){}


texts: How do you move motor car forward for set amount of time and turning left/right

texts:
Am new to Arduino, wanted to know how to give motor direction to move and the duration of those movements. Goal is to move forward for say 5 seconds, turn left, move for 0.5 seconds, turn right, move for 5 seconds.

void loop() {
  //turn on motor A
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  analogWrite(ENA, 100);
  //turn on motor B
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
  analogWrite(ENB, 100);
  delay(1000);

  analogWrite(ENA, 100); //speed 0 - 255
  analogWrite(ENB, 100); //speed 0 - 255
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
  delay(5000);

  analogWrite(ENA, 100); //speed 0 - 255
  analogWrite(ENB, 100); //speed 0 - 255
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
  delay(500);

  analogWrite(ENA, 100); //speed 0 - 255
  analogWrite(ENB, 100); //speed 0 - 255
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
  delay(500);

  analogWrite(ENA, 100); //speed 0 - 255
  analogWrite(ENB, 100); //speed 0 - 255
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
  delay(5000);


texts:
I wrote a simple program where I transmit and receive a letter via UART. The transmit function works 100% but the receive interrupt function doesn't work at all... Can someone adjust the receive interrupt function so I can receive a string instead of a char?

#define FOSC 16000000 // Clock Speed
#define BAUD 9600
#define MYUBRR FOSC/16/BAUD-1

void setup() {
  USART_Init(MYUBRR);
  interrupts();
}

void loop() {
}

void USART_Init(unsigned int ubrr) {
  /*Set baud rate */
  UBRR0H = (unsigned char)(ubrr>>8);
  UBRR0L = (unsigned char)ubrr;
  UCSR0B = (1<<RXEN0)|(1<<TXEN0);
  //Enable receiver and transmitter */
  UCSR0C = (1<<USBS0)|(3<<UCSZ00);
  /* Set frame format: 8data, 2stop bit */
  UCSR0A |= (1 << RXCIE0);
  UCSR0C=0;
}
void USART_Transmit(unsigned char data) {
  /* Wait for empty transmit buffer */
  while(!( UCSR0A & (1<<UDRE0)));
  /* Put data into buffer, sends the data */
  UDR0 = data;
}

ISR(USART__RXC_vect) {
  char ReceivedByte;
  ReceivedByte = UDR0;
  // Fetch the received byte value into the variable "ByteReceived"
}


texts:
I just got a new pro-micro Atmega32U4 board, and installed the current Arduino IDE (1.8) and cannot get it working.

There is no entry for a pro-micro, so I chose Leonardo as it uses the same chip.

When I choose upload, the two red LEDs blink fast, but I get an error from avrdude, saying that it cannot upload the code.

The board is probably from a Chinese web shop ($6 clone). There are no buttons on the board.

My questions are:

Is there already a bootloader on the chip, or do I have to program one? How do I check this?
How does it know that it must receive an upload, instead of running the flash program?
Which board should I choose in the IDE?

This is the error:

  Couldn't find a Board on the selected port. Check that you have the correct port selected.  If it is correct, try pressing the board's reset button after initiating the upload.

It looks exactly like this one.

Update: I did everything the manual said. I can choose the pro-micro now. Still the same error message. How do I check what state the bootloader is in?


texts: Does NodeMCU have some protection against wrong connections that could kill a computer USB?

texts: I know some computer USB could handle some bad connection (by blocking the port, which need to reboot the computer). But I wonder if a NodeMCU 8266 offers some protection.


texts: Difference between char array and unsigned char array

texts:
I have written a small test code for Arduino Uno which is as follows:
unsigned char tes[4];
char testing[4];

void setup() {
    Serial.begin(9600);
    for (int i = 0; i < 4; i++) {
        testing[i] = i;
        tes[i] = i;
    }
    for (int i = 0; i < 4; i++) {
        Serial.print("unsigned char is: ");
        Serial.println(tes[i]);
        Serial.print("char is: ");
        Serial.println(testing[i]);
    }
}

void loop() {
}

and the output which I get is as follows
unsigned char is: 0
char is:
unsigned char is: 1
char is:
unsigned char is: 2
char is:
unsigned char is: 3
char is:

Can someone help me out why is the difference in output.


texts: how can I change the setting for number of upload retries in the IDE?

texts:
I run into this problem when I mess something up, and it's pretty annoying to wait for 10 not in sync timeouts before I can try some different method.

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

How can I set the number of "attempts" to say 2 instead of 10? Or how can I safely interrupt the upload process in the IDE?


texts:
I need to create a interruption-proof power for a project of mine, very similar to the design of this link.

My problem is that I need to adjust the current delivered of the solar panel (21V, 1.2A) to 5V and simultaneously charge a battery 12V, 18Ah. If the solar panel does not supply power, the battery takes its place.

Does anyone know any circuit to do something? Or can someone give me a light as do something?


texts: What minimum equipment is needed to program the Freematics Vehicle Data Logger?

texts:
I was looking for a GPS/OBD2 data logger that logs data to an SD card and eventually arrived at the Arduino powered Freematics Vehicle Data Logger. It's great that it's programmable, but I have no experience with Arduino.

Reading the documentation, it says that I program the device either by USBasp or Arduino as ISP. The USBasp is a dongle programmer, but I don't know what is meant by Arduino as ISP.

My goal is to use this device to log data. I don't plan to extensive write programs for it. What is the minimum equipment that I need to have in order to be able to write a bit of code and flash it to the device?


texts:
I Have been working on a power logger with INA219 and L298N
the thing is, the voltage and current displayed on Serial Monitor is not the same on my multimeter.
the Arduino is connected to the pc to view the result on the serial
#include <Wire.h>
#include <Adafruit_INA219.h>

Adafruit_INA219 ina219;

//Adafruit_INA219 ina219_A;
//Adafruit_INA219 ina219_B(0x41);

void setup(void)
{
  Serial.begin(115200);
  while (!Serial) {
      // will pause Zero, Leonardo, etc until serial console opens
      delay(1);
  }

  uint32_t currentFrequency;

  Serial.println("Hello!");

  if (! ina219.begin()) {
    Serial.println("Failed to find INA219 chip");
    while (1) { delay(10); }
  }
  ina219.setCalibration_32V_1A();

  Serial.println("Measuring voltage and current with INA219 ...");
}

void data(void)
{
  float shuntvoltage = 0;
  float busvoltage = 0;
  float current_mA = 0;
  float loadvoltage = 0;
  float power_mW = 0;
    delay(2000);
  shuntvoltage = ina219.getShuntVoltage_mV();
  busvoltage = ina219.getBusVoltage_V();
  current_mA = ina219.getCurrent_mA();
  power_mW = ina219.getPower_mW();
  loadvoltage = busvoltage + (shuntvoltage / 1000);

  Serial.print("Bus Voltage:   "); Serial.print(busvoltage); Serial.println(" V");
  Serial.print("Shunt Voltage: "); Serial.print(shuntvoltage); Serial.println(" mV");
  Serial.print("Load Voltage:  "); Serial.print(loadvoltage); Serial.println(" V");
  Serial.print("Current:       "); Serial.print(current_mA); Serial.println(" mA");
  Serial.print("Power:         "); Serial.print(power_mW); Serial.println(" mW");
  Serial.println("");

  delay(2000);
}

void loop() {

    analogWrite(9, 245); //ENA pin
    digitalWrite(8, HIGH);
    digitalWrite(7, LOW);
    data();
    delay(5000);

    analogWrite(9, 200); //ENA pin
    digitalWrite(8, HIGH);
    digitalWrite(7, LOW);
    data();
    delay(5000);

    analogWrite(9, 150); //ENA pin
    digitalWrite(8, HIGH);
    digitalWrite(7, LOW);
    data();
    delay(5000);

    analogWrite(9, 0); //ENA pin
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
    data();
    delay(5000);

}


texts: How can I run multiple programs on an Arduino?

texts:
I'm trying to get students to experiment with Arduino. However, due to a lack of boards, two teams of students will collaborate on each board. They will push their own code (independent from each other) and use half the pins.

The "hardware" part isn't really a concern: students will push their sketches on a server that uploads them on the board, or something like that.

What I'm worried about is the software part. How can I allow two sketches to run on the same board, and allow the user to upload sketches without resetting the board?

As of my understanding, using the flash memory isn't an option, because the board must be reset before it can be written.

My first idea was to compile the students' C code into custom-made "assembly", and then push the assembly code to the board, which stores it into RAM and interprets it. However, my biggest problem would be implementing functions, I don't really have a clue of how I could do that. While common C functions could just be encoded in a fashion like FUNC printf STRING %s VAR a for printf("%s", a), I don't know how to encode user-defined functions. Besides, I don't even think the RAM is sufficient for running the client, storing two small programs, and running them.

Then, I thought about running the C code on the computer, but replacing digitalWrite with appropriate signals to the board. However, I'm worried about the performance of this, mostly when dealing with "high" speeds - say, using a custom-made library to print text on a LCD driver.


texts: Problem with Arduino driver! Port option not visible. How to resolve it?

texts:
I am not able to upload sketch because my Windows 8.1 PC is not able to recognise it. It used to work fine but suddenly my driver disappeared from my device manager and no light is shown on the Arduino uno led also.

I tried to uninstall and install the Arduino IDE again but still didn't work.

Note:- whenever I connect the USB cable to my PC, I see a dim light glowing for few milli seconds.

Update:- Also my Arduino board is not dead since it worked when connected to other pc but not working with my windows pc.

What could be the problem? How do I install the port driver back?


texts: I wish to use an arduino like this with a 12v solenoid lock like this. How can I do this. I am told that using this might work, but I am also thinking I can use a transistor's amlification to do that. Can you tell which one is better and if transistor, how to do that?


texts: Powering Arduino with 110v and controlling relay

texts:
I've found a lot of tutorials about how to use an Arduino to control power supplies to lamps and things like that using a relay. However, I also need to power the Arduino with the same power that is going through the relay.

In other words, I'd like to be able to plug my device into the wall. The device would use the 110VAC to power the Arduino. My device would also have some outlets that I could plug something into. The Arduino would be connected to a relay and would decide when to enable electricity to the outlet. The important part being that I would like everything to be on one power source.

Do I need to have a step down converter to transform the power, in addition to the relay? Is there some sort of break out board that has both of these functionalities in one board? What is the best way to do this?


texts: Toggle Button For LED Strip not executing properly

texts:
I have been using a library to control a LED Strip with buttons. My current code does not execute properly. It skips the if statement and just runs the code in a loop with no regard to the button and I'm uncertain why. I'm using an Arduino Uno with an LPD8806.

#include "LPD8806.h"
#include "SPI.h" // Comment out this line if using Trinket or Gemma
#ifdef __AVR_ATtiny85__
#include <avr/power.h>
#endif

int nLEDs = 160;

// Chose 2 pins for output; can be any valid output pins:
int dataPin  = 2;
int clockPin = 3;

// First parameter is the number of LEDs in the strand.  The LED strips
// are 32 LEDs per meter but you can extend or cut the strip.  Next two
// parameters are SPI data and clock pins:
LPD8806 strip = LPD8806(nLEDs, dataPin, clockPin);

int inPin = 4;
boolean lastState = LOW;//storage for last button state

void setup(){
   pinMode(inPin, INPUT);//this time we will set the pin as INPUT
   Serial.begin(9600);//initialize Serial connection
   #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000L)
   clock_prescale_set(clock_div_1); // Enable 16 MHz on Trinket
   #endif

   strip.begin();
   // Update the strip, to start they are all 'off'
   strip.show();

 }

void loop(){

   if (digitalRead(inPin) == HIGH && lastState == LOW){//if button has just
   been pressed
   // Start up the LED strip
        theaterChase(strip.Color(127, 127, 127), 50); // White
        delay(100);
    } else if(digitalRead(inPin) == LOW && lastState == HIGH){
        digitalWrite(dataPin, LOW);
        digitalWrite(clockPin, LOW);
    }
    lastState = digitalRead(inPin);
    }

    //Theatre-style crawling lights.
    void theaterChase(uint32_t c, uint8_t wait) {
         for (int j=0; j<10; j++) {  //do 10 cycles of chasing
              for (int q=0; q < 3; q++) {
                   for (int i=0; i < strip.numPixels(); i=i+3) {
                      strip.setPixelColor(i+q, c);    //turn every third pixel on
      }
      strip.show();

      delay(wait);

      for (int i=0; i < strip.numPixels(); i=i+3) {
      strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
  }


texts: Trying to get my mega 2560 to work for my 3d printer

texts:
Trying to pit marlins v2non this board and it gives me an error and I have no idea what to do

Arduino: 1.6.10 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Sketch uses 85,558 bytes (33%) of program storage space. Maximum is 253,952 bytes.
Global variables use 3,606 bytes (44%) of dynamic memory, leaving 4,586 bytes for local variables. Maximum is 8,192 bytes.
avrdude: ser_open(): can't open device "\\.\COM4": Access is denied.

avrdude: ser_drain(): read error: The handle is invalid.

avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The handle is invalid.

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The handle is invalid.

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The handle is invalid.

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The handle is invalid.

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The handle is invalid.

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The handle is invalid.

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
the selected serial port avrdude: stk500v2_getsync(): timeout communicating with programmer
 does not exist or your board is not connected

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


texts: Arduino Micro draws too much power from iPhone. How can I change that?

texts:
I'm building a USB keyboard that has two buttons - space and enter. The plan is to use this USB keyboard (with an Apple Lightning connector to USB) with the built in iOS switch control. I bought the lightning to USB dongle, and hooked it up to a normal keyboard, and it works fine.

Next, I took an Arduino Micro (ATMEGA32u4) and programed it to act as a keyboard with the two keys I need (space and enter). On a PC, it works just fine, but when I hook it up to my iPhone, I get the message:

Arduino Micro: The connected device requires too much power.

I've done quite a bit of research on this, and I found this post. In a nutshell, that post said that when you connect a device to an iOS device, one of the first things it does is tell the iDevice how much current it could potentially draw. This number (about 200mA for the Arduino Micro) is what decides whether the iDevice will support the device or not, when in truth, the device will not come close to its max current draw, at least not in my case.

I hooked up a meter to the normal keyboard, and it draws just over 4mA. When I hook up the Arduino, it is drawing almost 40mA. While the Arduino is drawing much more than the keyboard, it should be okay, because when I plugged in a flash drive, it was drawing 50mA, but the iPhone didn't complain.

There is my story, here is my question:

Is there any way to change it so that the Arduino Micro doesn't request so much power? In other words, is there a way to reset the value that is causing the iPhone to not use the device?


texts:
I am trying to make some LED lights to turn on when i flick a switch on my RC crontroller. I will connect the signal wire from RC controller to pin 8. The plan is: if i flick the swich, the LED's (pin 12,11,10,9) will turn on, and if i don't flick the swich the LED's wont turn on. This is a Arduino nano what will be connected on a drone.I found another question HERE, but there was no real answers.
 I get a error that say:

  exit status 1
  could not convert 'digitalWrite(8u, 1u)' from 'void' to 'bool'

How can i fix this? Should i write the code another way?

Arduino Code:

    void setup() {

  pinMode(4, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, INPUT);

}

void loop() {

  if (digitalWrite(8, HIGH));
    digitalWrite(12, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
  else
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);

  digitalWrite(4,HIGH);
  delay(1500);
  digitalWrite(4,LOW);
}


texts:
I've decided to use Sparkfun's Pro Mini boards to make my project into a semi-professional product.

My first thought turned to enclosures - of which the entire internet seems to be bereft. If I ever DO see an enclosure, it's for the Uno sized board and costs about twice the price of the board, which seems incredible to me.

No matter, I have found a way to make quite good enclosures for the Pro Mini pretty easily and cheaply.

HOWEVER, the next problem is mounting the board inside the box. I would like to be able to mount it firmly to the base but in a way which allows it to be removed if necessary. Obviously, there's not a lot of scope for putting screws through the board. It occurs to me that anything which holds it would need to do so by gripping the edges or the corners. Is there such a thing?

If there's nothing that fits the bill, would the board be OK if I were to HOT GLUE it to the base of the enclosure?


texts:
I have 2 buttons and 2 voids (blink_slow) (blink_fast).
i need to be able to press button 1 and blink-slow void will run, then press button 2  and blink fast will run. none of my code works, any idea how i can do this?

const int btn1 1;
const int btn2 2;
const int led  13;

void setup(){
pinMode(btn1,INPUT_PULLUP);
pinMode(btn2,INPUT_PULLUP);
pinMode(led,OUTPUT);
digitalWrite(led,HIGH);
}
void loop(){
if(digitalRead(btn2 =LOW)){
blink_slow();
}
if(digitalRead(btn3 =LOW)){
blink_fast();
}

void blink_slow(){
digitalWrite(led,LOW);
delay(1000)
digitalWrite(led,HIGH);
delay(1000)
}

void blink_fast(){
digitalWrite(led,LOW);
delay(500)
digitalWrite(led,HIGH);
delay(500)
}


texts: NodeMCU power consumption measurement and DeepSleep

texts:
I'm working on a project using a nodeMCU using a ICR14500(3.7V and 700mAh) battery and I'm experienced some issues when I try to estimate the total current consumption. Firstly I experienced some problems with the power supply (here is the previous question NodeMCU powered with battery and use WiFi) but this problem is now solved.

At this moment if I measure the current consumption connecting the amperimeter in serie between the battery and the nodeMCU input voltage pin I see a current consumption of 140mA continiously (ignoring the deep sleep mode) and I experienced some strange behaviours in my NodeMCU, even the code doesn't work. If I remove the amperimeter from my set up all works smooth and my source code works perfectly.

In order to validate my amperimeter I modified a usb cable and I added the amperimeter in the middle of the wire and I measured the current consumption powering me nodeMCU from the computer and I saw a current consumption of 80mA when the code is run and 14mA when the device is in deep sleep. This behaviour seems the expected one.

Are there any colateral effect measuring the battery current consumption which I haven't considered?