texts: OneWire with DS18B20 digital sensor only works on the I2C (20 and 21) pins of my Mega?

texts:
I am using an Arduino Mega to read a DS18B20 temperature sensor using the OneWire library in the code below which I got here:

#include <OneWire.h>

#define DS18S20_Pin 20 //DS18S20 Signal pin on digital 20

//Temperature chip i/o
OneWire ds(DS18S20_Pin);  // on digital pin 20

 #define DS18S20_ID 0x10
 #define DS18B20_ID 0x28
 float temp;

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

void loop(void) {
  boolean tempTest = getTemperature();
  Serial.println(tempTest);
  Serial.println(temp);

  delay(1000); //just here to slow down the output so it is easier to read

}

 boolean getTemperature(){
 byte i;
 byte present = 0;
 byte data[12];
 byte addr[8];
 //find a device
 if (!ds.search(addr)) {
 ds.reset_search();
 return false;
 }
 if (OneWire::crc8( addr, 7) != addr[7]) {
 return false;
 }
 if (addr[0] != DS18S20_ID && addr[0] != DS18B20_ID) {
 return false;
 }
 ds.reset();
 ds.select(addr);
 // Start conversion
 ds.write(0x44, 1);
 // Wait some time...
 delay(850);
 present = ds.reset();
 ds.select(addr);
 // Issue Read scratchpad command
 ds.write(0xBE);
 // Receive 9 bytes
 for ( i = 0; i < 9; i++) {
 data[i] = ds.read();
 }
 // Calculate temperature value
 temp = ( (data[1] << 8) + data[0] )*0.0625;
 return true;
 }

When I use this code with the sensor attached to pins digital pins 20 or 21 it reads successfully, ok great, somehow by the grace of god I chose pin 20 on the first try. So then I move on to integrating my next sensor which utilizes the I2C and the Wire library, I should note that I am using this shield so I was able to connect right to the I2C without realizing I was using pins 20 and 21. Now, when I combined the two programs the I2C sensor was initialized second so it ended up getting the pins and the DS18B20 would fail to read, after pulling out my hair for a couple of hours I looked at a Mega pinout and realized it was on the I2C pins and thinking I finally figured it out I went to go and move the DS18B20 to one of the 52 other digital pins, this is when I came to the cold discovery that my DS18B20/OneWire will not work on any pins except pins 20 and 21 which I NEED for I2C. I have not checked every single digital pin but I have checked about half of them and nothing works except pins 20 and 21, I cant figure it out, nothing I can find mentions that OneWire uses or conflicts with the I2C connection.

More Info:

Using latest OneWire
I am not using DallasTemperature and would prefer not to, I could not get it to work whether on pins 20/21 or not
I am using a resistor on the sensor
I am currently only trying to run the code above to debug, no references to I2C sensor or Wire library whatsoever.

Thanks for reading and for any help, I am totally stumped here and thought I was avoiding some of these dumb double use pin issues by using the Mega instead of an Uno...


texts: Connecting Pulse Sensor to RFDuino Simblee

texts:
I am trying to make a heart rate sensor watch. I am trying to do this using a Simblee (www.simblee.com) and a Pulse Sensor (www.pulsesensor.com) however they will not work! The original code from pulsesensor uses Timer2, which I commented out in favor of delay(2) (i'm new to Arduino and it seemed to work). I am getting readings over serial they just seem to be in a wave instead of a pulse. I need to get this working as I am out of time and money ;) Would anyone have any ideas on how I could get them working?

ALL CODE ON GITHUB (https://github.com/shadow85926/SimbleeArduinoCode)
Thank you.

Wave pattern:
http://imgur.com/2XUBUU6


texts:
In the following code :-
The aim of code is " when push button is pressed , led is on and when push button is is pressed again led is of"

#define led 12
#define button 7
boolean trigger = false;
boolean previous = false;
void setup()
{
  pinMode(led , OUTPUT);
  pinMode(button , INPUT);
}
void loop()
{
  int current = digitalRead(button) ;
  if (current && !previous)
  {
    trigger = !trigger;
  }
  previous = current;
  digitalWrite(led , trigger);
}

My Questions are as follows:-

When i used digitalread(button) instead of introducing variable i.e
current. LED shows abnormal behavior. Why ?
What is the purpose of current = previous expression. Whats its
significance?
Also please explain the working of a code in a brief manner in a
loop.
Why I should use Boolean instead of int?


texts: Arduino Wire communication with MCP23008 GPIO pin expander to turn on an LED with a button press

texts:
I am using an Arduino Uno and an MCP23008 GPIO pin expander, I have a momentary button connected to GPIO 2 on the MCP23008 and an LED light connected to GPIO 1 on the MCP23008. What I want is for the LED to turn on when the button is pressed down, and off otherwise. The code I currently have is this:

   #include "Wire.h"       //import Wire library
   byte inVal;             //declare byte variable

   void setup() {

      Serial.begin(9600);
      Wire.begin();
      Wire.beginTransmission(0x20);   //MCP23008 i2c addr
      Wire.write(0x00);               //MCP23008 internal register addr for I.O.dir
      Wire.write(00000010);           //set all pins as output, except for #2 as input
      Wire.endTransmission();
    }

    void loop() {

      Wire.begin();
      Wire.beginTransmission(0x20);   //MCP23008 i2c addr
      Wire.write(0x09);               //MCP23008 internal register addr for GPIO access
      //Wire.write(0xFF);             //set all output pins to HIGH, commented out for now.
      Wire.endTransmission();
      Wire.requestFrom(0x20,1);       //get one byte of input input from MCP23008
      inVal=Wire.read();              //set pyte as variable

      //Serial.println(inVal,BIN);    //output byte to serial monitor, commented out for now

      Serial.println(bitRead(inVal, 1)); //output second bit from byte(1 or 0, for HIGH or LOW, depending on the press of the momentary button.
      if((bitRead(inVal, 1)==1))      //if the bit from the button is high,
      {
        Wire.beginTransmission(0x20);
        Wire.write(0x09);
        Wire.write(0xFF);             //then set all output pins as HIGH
        Wire.endTransmission();
      }

      else if((bitRead(inVal, 1)==0))  //if the bit from the button is low,
      {
        Wire.beginTransmission(0x20);
        Wire.write(0x09);
        Wire.write(0x00);             //then set all output pins as LOW
        Wire.endTransmission();
      }
    }

I don't know as much Arduino as I do Python, and I have even less experience with i2c connections and the Wire library, but this looks to me like it should be working.

The bit printed on the serial monitor is HIGH, until I press the button once, then it stays LOW forever until I modify and re-upload the code to the Arduino.
Not sure what's going wrong here. Anything helps, thanks.


texts: Directly synthesising an OOK modulated LF signal using a CSV file

texts:
I'm looking to transmit some data (CSV files) from a measurement instrument underground to a receiver on the surface. I've learned that in order to penetrate the limestone, low frequencies have to be used (around 80-130kHz). There are various methods to achieve this including ground-spike antennas that use the earth between two electrodes to help form a large antenna by injecting current into it, and magentic loop antenna pairs that essentially work as an inductor by transmitting and receiving the magnetic (H) component of the RF transmission rather than the low power E field component.
With that put aside, I've noticed that there aren't any existing RF modules that transmit at these frequencies. Because of that I've considered the posibility of directly synthesising a modulated signal using an Arduino (UNO or Nano). As far as I understand it I need a direct digital synthesis (DDS) IC to generate a reference frequency. From there I understand the Arduino can be used to calculate a waveform that simulates the modulation of that carrier in the mentioned frequency range. I've identified that on-off keying (OOK) would be a suitable modulation method due to its simplicity and resistance to noise.
This is where I need some help. How do I take a CSV file, use its contents to OOK modulate a carrier wave and then directly synthesise this waveform using Arduino? Are there libraries that already exist to enable this? If so, how would I use them? I don't have extensive programming knowledge so I'd appreciate any help I can get.


texts:
I have an Arduino attached to an accelerometer sensor. I'm looking to detect the motion of a head shake sideways.

While I am able to stream the readings from the sensor, I am unsure how to buffer values in Arduino until a condition is met.

Example using Y axis :

Y=0.00 (Nothing happens)

Y=1.00 (Left turn occurs, keep value)

Y=-1.00 (Right turn occurs, keep value)

Y=1.00 (Left turn occurs, keep value)

Y=-1.00 (Right turn occurs, keep value, shake head condition fulfilled, four left/right value detected, jump to function.)

Any advice on how to go about doing and perhaps a sample example will be greatly appreciated.


texts: How can I discover attached motor shields in code?

texts: I'm using the Motor Shield v2 and I'm looking for a way to automatically discover the addresses of attached motor shields.


texts:
I am trying to use the Arduino as a switch for an external circuit.

I first thought about using a shift register, but this wont allow me to switch the external circuit. Here is a little sketch of what I want to do :

So basically I got this external circuit with a 3 position switch. And I want to replace this manual switch with an Arduino so it can be controlled by a PC, without influencing the other circuits Voltage or Amps...

Any suggestions ?


texts: How to connect neo 6m 6pin module with nodemcu v3

texts:
I got this neo 6m gps module from a broken drone. and i would like to connect it to nodemcu v3 board.
most of the gps module that i have seen are with 4 pins (vcc,gnd,tx,rx) , but this module has 6 pins (gnd,vcc,txd,rxd,scl,sda) .
i am not sure how to wire it up and what library to use.


texts: WS2812 HELP. Need name of Unkown component

texts:
https://i.imgur.com/u5SIvLo.png

I need to know what the little "thing" that i marked in blue is and how it works.

Thanks.

picture taken here: https://www.sparkfun.com/products/13282


texts: How to upload and play music file directly to ATMega328 arduino nano

texts:
I'm wanting to upload a v short piece of music, to an arduino nano, and then play it repeatedly.

The file length only needs to be 10ms, how do I do this?  I'm unsure what format to put it in, where to put it in the code and also the size limits (Is it 2kb (RAM size) or 32kb (EEPROM) size that will decide how big a file I can put in?

I don't know how/where to put the code and how to get it to play.  I found lots of information on running it off SD cards or other external memory, but these aren't an option at the moment as I am limited to what I currently have (currently - an arduino nano, a load of resistors, diodes and that's about it) I'm just wiring the speaker directly between pin4 and ground but could do more wiring if that's required.

I'm quite happy to reduce the sample rate of the file down to get it small enough to fit the 2kb or 32kb size - but I have no idea what to to/where to paste the code/even where to get the code from a .wav or .mp3 or whatever filetype.

Thanks very much


texts:
I am a newbie in arduino working on a bot with L293D shield. But I have a  question as what would be the input current to drive all 4 dc motors and 2 servo motors.  I can see that it can supply 0.6Amp current for the four motors.

I am considering the amount of electrons flowing in per unit time is equal to the electrons flowing out of the circuit, as an simplistic aprach. So practically the input current should be greater than or equal to 2.4Amp.

As I have 6 motors in total so I was thinking about making a 12V 3Amp DC supply for a better performance. Should I do it like that? will it damage the board or shield?


texts: ESP8266: Interfacing MAX485 TTL-to-RS485 on serial port

texts:
I am using the ESP8266 NODEMCU.
I am aware that the CH341 on the NodeMCU is bridged to the serial pins GPIO3(Rx) and GPIO1(Tx).
Hence, any data send on Rx and Tx is also visible on the serial monitor.
I need to interface MAX485 TTL-to-RS485 to the ESP8266 on different serial pins (other than GPIO3 and GPIO1).
Is there a way to configure other pins as Rx and Tx?
Please suggest any other ways to achieve this.
EDIT-1:
I need to use two serial ports at the same time (one with the CH341 and another with TTL-to-RS485). Please help with this.


texts: Arduino Micro project with Bluetooth low energy

texts:
I created my project prototype with Arduino Micro and Adafruit Bluetooth low energy device.

Now I need to develop the prototype to production (like a small USB device). I just need Rx, Tx, 3V pin from Arduino Micro.

I started design with ATmega32U4, USB and BLE by using Fritzing IDE. I am confused with Arduino Micro parts like reset, bootloader and other pins. Is there any problem if I leave the unwanted pins from Arduino unconnected, for my project? Will it work correctly like a Arduino micro?

This is my first PCB design. Please help me to design a final PCB with the unwanted pins left unconnected.


texts:
So, I'm creating this project for school. It's a simple robot with Arduino MEGA 2560 and basically, I create a digital map, feed it into the Arduino program and then the robot can drive. However, I've run into some problems while trying to implement my idea. Parsing errors mostly. And I want to know if there is another and different approach.

So, basically at the moment, this is how my digital map works:

Using C# and Visual Studio IDE I've created a program with which I can create the map. Basically, I create connections(lines/roads) and the connection has a starting and end point, a median point and a label(what it is). So, each connection info token is something like this:

"Connection[x1: 0, y1: 0|x2: 13, y2: 0|xm: 6.5, ym: 0|label: Nothing]"

"Connection[x1: 13, y1: 0|x2: 13, y2: 28|xm: 13, ym: 14|label: library]"

Now, I have figured out a way to import this information into Arduino, and I've stored the information into a class object I created. Now, the difficulty I'm experiencing is how am I going to drive the robot from one point to another, store the robot's position and go to any point in the map when asked to.

Edit:

As for the implementation and storage of the map, it's like this:

So, I have a class Vertex. It basically the equivalent of a point and store (x, y) values.

class Vertex {
  public:
    int x;
    int y;

    Vertex(int _x, int _y) {
       x = _x;
       y = _y;
    }
};

Then there's the connection class. It stores the starting vertex, the end vertex, the median vertex and the label(string). It's like this:

class Connection {
  Vertex v1();
  Vertex v2();
  Vertex median();
  String label;

  public:
    Connection(Vertex _v1, Vertex _v2, Vertex _median, String _label) {
        v1() =  Vertex(_v1.x, _v1.y);
        v2() =  Vertex(_v2.x, _v2.y);
        median() = Vertex(_median.x, _median.y);
        String label = _label;
  }
};

And, finally, there's the map class where the user passes in the info tokens produced by my map creating application made in Visual Studio and it works like this:

#include "Connection.h"

class Map {
  public:
    Map(string infoTokens[]) {
      //I import the info tokens here.
    }

    void drawMap(MCUFRIEND_kbv tft, String ) {
      //This is a totally different function, it is just for drawing the map
        on top of the TFT screen that I have on my robot.
    }

    void driveTo(Vertex rP, String destinationLabel) {
      //This is where I drive my robot when the user requests to go to a
        destination and provides the label.
    }
};

As for the importing of the info tokens(the map information) I just do some String Manipulation on, for example, this
"Connection[x1: 0, y1: 0|x2: 13, y2: 0|xm: 6.5, ym: 0|label: Nothing]"
and get back all the info in the required data types. As for the importing it doesn't really change anything because I have tested my function(not present here) a lot of times and it works brilliantly. My question is how to use that information to hopefully drive the robot.


texts:
I put a LED into 3.3V of the arduino and Ground, and it blew my LED violently, smoke was everyone, the whole half top of the led blew up across my room.

However, when i program the arduino with Pin13 HIGH per say, it will not blow up. Will be lit brightly. (Both using no resistors). However, if I plug mroe stuff in the board, for example, a lcd screen, rotary switches, and pushbuttons for my program, the LED dims to such a low brightness I cannot see.

Why is this? How Do I fix it?

Schematic:

Note, that i am using a mega, and some of it is slightly changed, and LED is being powered from A0 (Or Pin 54 on Mega)


texts:
I've synced my Uno with the Arduino IDE and I'm using the following code to get the GPS coordinates:

#include <TinyGPS.h>
#include <SoftwareSerial.h>

unsigned long fix_age;
SoftwareSerial GPS(4,3);
TinyGPS gps;
void gpsdump(TinyGPS &gps);
bool feedgps();
void getGPS();
long lat, lon;
float LAT, LON;

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

void loop(){
  long lat, lon;
  unsigned long fix_age, time, date, speed, course;
  unsigned long chars;
  unsigned short sentences, failed_checksum;
  // retrieves +/- lat/long in 100000ths of a degree
  gps.get_position(&lat, &lon, &fix_age);
  // time in hh:mm:ss, date in dd/mm/yy

  getGPS();
  Serial.print("Latitude : ");
  Serial.print(lat/100000,7); //#UPDATED
  Serial.print(" :: Longitude : ");
  Serial.println(lon/100000,7); //#UPDATED
}

void getGPS(){
  bool newdata = false;
  unsigned long start = millis();
  // Every 1 seconds we print an update
  while (millis() - start < 1000)
  {
    if (feedgps ()){
      newdata = true;
    }
  }
  if (newdata)
  {
    gpsdump(gps);
  }
}

bool feedgps(){
  while (GPS.available())
  {
    if (gps.encode(GPS.read()))
      return true;
  }
  return 0;
}

void gpsdump(TinyGPS &gps)
{
  //byte month, day, hour, minute, second, hundredths;
  gps.get_position(&lat, &lon);
  Serial.print("Hello World : "); //#UPDATED (Test)
  LAT = lat;
  LON = lon;
  {
    feedgps(); // If we don't feed the gps during this long
  }
}

When I compile, it uploads successfully and when I check the serial streams, it displays:

Latitude : 41103 :: Longitude : 41103

But my lat/lon (in the risk of disclosing location) is
(38.984898400, -76.957276900)

It doesn't seem to be the same.


texts:
When slot == SLOT_1 is true, speed_value is positive but when slot == SLOT_2 is true, speed_value becomes negative.

I printed the value of speed_value immediately after the statement speed_value = -speed_value and it shows a positive number. How did speed_value changed sign when it enters the slot == SLOT_2 argument?

case ENCODER_BOARD:
  if(port == 0)
  {
    uint8_t slot = readBuffer(7);
    int16_t speed_value = readShort(8);
    speed_value = -speed_value;

    if(slot == SLOT_1)
    {
      Encoder_1.setTarPWM(speed_value);
    }
    else if(slot == SLOT_2)
    {
      Encoder_2.setTarPWM(speed_value);
    }
    else if(slot == SLOT_3)
    {
      Encoder_3.setTarPWM(speed_value);
    }
    else if(slot == SLOT_4)
    {
      Encoder_4.setTarPWM(speed_value);
    }
  }

int16_t readShort(int16_t idx)
{
  valShort.byteVal[0] = readBuffer(idx);
  valShort.byteVal[1] = readBuffer(idx+1);
  return valShort.shortVal;
}

uint8_t readBuffer(int16_t index)
{
  if(BluetoothSource == DATA_SERIAL)
  {
    return buffer[index];
  }
  else if(BluetoothSource == DATA_SERIAL2)
  {
    return bufferBt1[index];
  }
  else if(BluetoothSource == DATA_SERIAL3)
  {
    return bufferBt2[index];
  }
}

All the code are taken from here and I am not the owner. I myself still studying how these whole code works. I am hoping someone out there who have experience with these kind of implementations be able to help me out.


texts:
I wish to blink only one led (number two in the strip) bit it does not do so, any idea why and how can I do it?
Code:
#include "FastLED.h"

//Number of LEDs
#define NUM_LEDS 9

//Define our clock and data lines
#define DATA_PIN 11
#define CLOCK_PIN 13

//Create the LED array
CRGB leds[NUM_LEDS];

void setup() {
      FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, BGR>(leds, NUM_LEDS);
      FastLED.setBrightness(5);
}

void loop() {
  leds[0] = CRGB::Blue;
  leds[1] = CRGB::Green;

  //Blink this one only
  leds[2] = CRGB::Red;
  leds[2] = CRGB::Black;
  delay(500);
  leds[2] = CRGB::Red;

  leds[3] = CRGB::White;
  leds[4] = CRGB::Purple;
  leds[5] = CRGB::Green;
  leds[6] = CRGB::Blue;
  leds[7] = CRGB::Yellow;
  leds[8] = CRGB::Red;
  FastLED.show();
}


texts:
hello guys i want to ask about 2 things
first one is i'm connecting and arduino uno attached to a usb host sheild and transferring data of a mouse coordinates to 10 arduino leonardo
i'm using the standard speed 100
normal mode
my wires is all about 10 cm long

i need to speed up the comm to fast mode
how to make this ? and the line of code where to put it in the code and in the master or slave ?

what about the pull-up resistors ? does arduino uno includes built in pull-up resistors ? does it needs to disable it and put my own pull up resistors ?
i’m using wire library


texts: Reliably duplicate custom IR remote control with ATTiny85

texts:
This is something I'm struggling with for a while and fail to find solid solution.
The Arduino IR library provides method for recording arbitrary IR code and re-sending it. This gave me different results every time I recorded the IR remote, so I wrote a little code, based on interrupts, that try to record the IR rise/fall as accurately as possible.
I am working with ATTiny85 running at 8Mhz on internal oscillator.

Here is the code:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(4,3);

const int dataSize = 40;
int data[dataSize];
int dataLength[dataSize];

void setup() {
  pinMode(0, OUTPUT); // 0 is IR receiver pin
  mySerial.begin(9600);
  mySerial.println("Start");
  attachInterrupt(0,IR_ISR,CHANGE);
  mySerial.println("Registered");
  sei();
}
volatile unsigned long prev = micros();
volatile unsigned long curr = -1;
volatile unsigned short index = 0;
volatile bool rising = true;
void IR_ISR()
{
  if (!rising)
  {
    dataLength[index] = micros() - curr;
    rising = !rising;
    return;
  }

  curr = micros();

  data[index++] = (int)curr-prev;

  prev = curr;
  rising = !rising;
}

void loop() {

  delay(5000);
  for (int i=1; i<dataSize; i++)
  {
    mySerial.print(data[i]);
    mySerial.print("(");
    mySerial.print(dataLength[i]);
    mySerial.print(")");
    mySerial.print("; ");
  }
  mySerial.println();
  index = 0;
}

Problem is that the milliseconds alter on each record of the remote control, here is an example of the output of 3 attempts of clicking at the same button of the remote control (I pasted only the first 5 IR modulations to avoid too much text, total is about 39):

  Start
  Registered

  14104(9496); 1184(672); 1184(616); 1160(656); 1176(672); ...

  14096(9480); 1184(664); 1208(568); 1136(616); 1184(664); ...

  14096(9384); 1216(576); 1136(616); 1184(664); 1208(560); ...

The format is: [microseconds from previous falling edge](microseconds from rise to fall);

As you can see, the results vary. According to the arduino.cc website, the micros() function has a 8 microseconds resolution on 8Mhz AVR's, but the difference between reads is bigger than that.

This is not reliable enough for me to solidly duplicate a remote control, and I'm looking for a resolution that will provide accurate results, as the magnitude of every deviation increases when the voltages are low (for example, with a 3v 2032 coin battery half discharged).


texts: how to increase the delay factor of DHT11?

texts:
There is no compiler error but output is showing timeout error.
as per as the instruction given in
https://github.com/RobTillaart/Arduino/issues/61

it says to increase the timeout factor but i did not found the constraints which were asked to be changed.


texts:
I am new to arduino.

Why does this not work the way it's supposed to?
Shouldn't it block all interrupts for 3secs after it received one from digi pin 2?

How would I accomplish this:
Running a method whenever the value on this pin changes, execute it and then listen for more interrupts from that pin?

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  attachInterrupt(digitalPinToInterrupt(2), test, CHANGE);
}

int i = 0;

void loop(){}

void test(){
  noInterrupts();
  Serial.println("Interrupt registered - waiting " + i);
  delay(3000);
  Serial.println("done waiting!" + i);
  i++;
  interrupts();
}


texts: Sharing serial output from one to many arduinos (plus a computer) via USB hub

texts:
I am trying to send rotary encoder output from an UNO to seven Trinket M0s and a computer via a (powered) USB hub.

Currently the UNO → Laptop bit works great, serial monitoring works via the hub for everyone and I'm able to get a master/slave connection going between the UNO and a Trinket via Arduino's Wire library. But Wire uses pins, and I haven't had any luck finding a similar solution for USB. Thus far, the best leads seem to be around using something like stty in a bash script to listen for what each port is up to but I'm so far in over my head at this point that that might just be wishful thinking.

I'm not looking for a solution here, just some suggestions as to where to head next. Specifically:

Is the Wire library useful for USB communication?  Is there something similar (master/slave-wise) that would be helpful?
Assuming the serial/listen thing works, are there good ways to re-route data to different ports? Currently my best guess is something like $ echo $encoderVal > /dev/cu.usbmodem????? to each one individually ... but that might be a completely noobish notion.)
i2c keeps on coming up in searches, but looks like overkill. Is that a direction to head?
Is this all completely nuts?

Anyways, thanks to everyone in advance.

Update

Ok! Thanks to the advice of @Gerben and @chrisl I ended up routing everything around with PySerial, and (for the extremely limited purposes of this little project) it works well! Here's what is currently working:

import serial
from time import sleep
import os

# Connect to each Arduino individually
serialUno = serial.Serial("/dev/cu.usbmodem141101", 9600, timeout=0)
serialTrinket1 = serial.Serial("/dev/cu.usbmodem1414401", 9600, timeout=0)
# (+ 6 more. serialTrinket2, serialTrinket3, etc)

# Open a text file to save the encoder value in
f = open("encoderVal.txt", "w")

while True:
  # Read encoderVal from the UNO
  data = serialUno.read(9999)
  if len(data) > 0:

    # Send data to each trinket
    serialTrinket1.write(data)

    # Save val to text file to Unity
    with open('encoderVal.txt', 'r+') as f:

      # Wipe the file so it's only the most recent value
      f.truncate()
      dataStripped = data.strip()

      # Return the last int in the data stream
      dataSplit = dataStripped.split('\n')
      f.write(dataSplit[-1])

  sleep(0.05)

# Close serial connections & file on interrupt
serialUno.close()
serialTrinket1.close()
f.close()

As for the laptop end of the equation, I abandoned the serial library that I had been using in favor of this Unity-to-Python tool, which works perfectly.

The only issue thus far is that PySerial loses the occasional few bytes here and there, which outputs a wonky number ever 30 or so. That'll be tomorrow's project.  Thanks everyone for your help!


texts:
I'm using the HC-05 Bluetooth module but I'm confused about the TX,RX pins.
I want to know when should I connect the RX to a divider circuit to convert 5v to 3.3v.
Because while searching, I saw both of the following:

either RX is connected to TX of the UNO and TX is connected to RX of the UNO without a divider circuit.
or RX is connected to a divider circuit and then connected to any digital pin , TX is connected to any digital pin as well.

So can you give me a thought about both the situations?
my thought is that only digital pins needs a divider rule, but the TX,RX pins can be connected directly and operates without any problems but if so, then what's the difference between both??
Note that I'm using HC-05 to turn on a LED.
Hope to see some good explanation that suits a new Arduino learner.
Thank you..


texts:
Connecting all like shows the image, thermistor shows, that I'm going to be burnt:

The code is simple:

#define analogPin  A0 //the thermistor attach to
#define beta 4090
#define resistance 10

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

void loop()
{
  //read thermistor value
  long a =analogRead(analogPin);
  //the calculating formula of temperature
  float tempC = beta /(log((1025.0 * 10 / a - 10) / 10) + beta / 298.0) - 273.0;
  float tempF = 1.8*tempC + 32.0;
  Serial.print("Temp: ");

  Serial.print(tempC);

  Serial.print("  C");

  Serial.print("Fahr: ");
  Serial.print(tempF);
  Serial.print(" F");
  delay(200); //wait for 100 milliseconds
}

Do I have a wrong thermistor or wrong code?


texts: Record video with CMOS camera using Arduino

texts:
Is it possible to use this with Arduino to record and store videos on memory card?

Additionally, if someone has already done it, a tutorial link would be appreciated.


texts: How to install Arduino IDE on Raspberry Pi

texts: How do you install the Arduino IDE on the Raspberry Pi running an ARM version of Ubuntu or Raspbian? There doesn't seem to be any official ARM release. Both distros have an "arduino" package in their standard repos, but it only includes an ancient 1.0 version that's missing a lot of features.


texts: The PCM libary won't work on an Arduino Nano

texts: I'm using the PCM(http://highlowtech.org/?p=1963) library on the Arduino nano, I'm plugging the speaker(https://www.amazon.com/gp/product/B07WZP4QFK/ref=ox_sc_act_title_3?smid=A2O4FZXIRZDLHA&psc=1) into pin 11 and ground, but the example file won't work.


texts: how to use the decoded raw value to send IR signal in arduino

texts:
I am IR library from Ken Shirrif at https://github.com/z3t0/Arduino-IRremote/releases/download/MAJOR/IRremote.zip

It is good and I have used the examples to receive and send and to playback IR signals from the library. And they are working good.

To send Unknown signals we should use sendRaw() method with a list of integers got from the receiver.

My question is when I use the receive program, I get the decoded hexadecimal value for even the Unknown signals. And can I use this small decoded signal to send signals apart from the long list of integers.

I am trying to send these codes from android. It would be quite easy to send and store the small hexadecimal decoded value.

Is there a way to use the decoded value to send for raw signals with some encodings at arduino?


texts: All floats feedback a rounded down integer

texts:
So I am very confused at the results I am getting.
It seems that floats aren't working properly, and I don't understand why.

I was trying to read a temp sensor and convert the reading to celsius. However, when I tried to divide the value (an int between 145-165) by 1024, and multiply by 5 I would get back a float value of 0.00
Here's the code I was using

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

}

void loop() {
  int sensorVal = analogRead(A0);
    Serial.print("Sensor Value: ");
    Serial.println(sensorVal);

  float voltage = ((sensorVal/1024) * 5);
    Serial.print("Voltage Value: ");
    Serial.println(voltage);

}

This would only return values of 0.00 for voltage, even though the sensor itself is working fine, returning varying values between 146 and 165 based on how much heat I apply.
This didn't make any sense, so I tried it with some other values, eg.

Serial.print(float (10 / 6));

and

Serial.print(float (5 / 2));

which should have returned 1.67 and 2.50 respectively, but instead returned 1.00 and 2.00

I think it might be a settings thing, where all floats round down to an int, but that seems really weird.

Any help would be great!


texts: Arduino to Thingspeak using WiFly-RN171 (Firmware 4.0)

texts:
I am attempting to use an Arduino Uno+WiFly setup to send data to Thingspeak.
I have tried a few libraries by now. But nearly all of them don't have a working WebClient example (WebServer works fine).
I am using Arduino 1.6.3 IDE for Arduino UNO R3 + Wifly-RN171 with Firmware 4.0

The libraries I have tried (found through Google and forums):

https://github.com/sparkfun/WiFly-Shield/tree/master/Libraries/Arduino

A ThingSpeak example is given but the execution stops when WiFly.begin() is called. I tried WebClient and WebClient(Faster) examples from the same library and they are both stuck at the same line: WiFly.begin().
I believe this could be compatibility issue (WiFly firmware version/Arduino) but am unsure how to fix it.

Note: There seems to be a few versions for the SparkFun WiFly library from my search results. I tried whatever I found but only listed the latest one since if it is indeed a compatibility issue a newer version should be more likely to work.
https://github.com/Seeed-Studio/WiFi_Shield

This one has a http example which I am attempting to use to send data to Thingspeak through http get/post. I am getting 'Bad Request' from their nginx server. Any help in the right direction will be much appreciated.
I hosted the sketch I tried here: codebender.cc/sketch:276925

p.s. I am not allowed to post >2 links due to reputation so the last one is plain text.
p.s.s Can someone with higher reputation help me add the new tags {thingspeak, wifly, rn171}


texts:
I have an EFCom GPRS/GSM Shield
http://www.elecfreaks.com/wiki/index.php?title=EFCom_GPRS/GSM_Shield
and I am using it with a mega 2560. The problem is that the code in the wiki page

//Serial Relay - Arduino will patch a
//serial link between the computer and the GPRS Shield
//at 19200 bps 8-N-1
//Computer is connected to Hardware UART
//GPRS Shield is connected to the Software UART

#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3);
void setup() {
  mySerial.begin(19200);               // the GPRS baud rate
  Serial.begin(19200);                 // the GPRS baud rate
}

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

makes use of software serial but mega 2560 cannot use software serial on pin 2, as in the arduino reference, thus I changed the pins to 50 and 51 and used external female-male headers to connect s_tx to pin 50 "rx" , and s_rx to pin 51 "tx", still no response with the AT command...

code after update is :

#include <SoftwareSerial.h>
SoftwareSerial mySerial(50, 51);
void setup() {
  mySerial.begin(19200);               // the GPRS baud rate
  Serial.begin(19200);                 // the GPRS baud rate
}

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

Note that I am using the Arduino IDE serial monitor.


texts: Arduino Yun RFID-RC522 module not working

texts:
I have tried to use Arduino Uno with RFID-RC522 module. It is good work[1] and read rfid cards. But Arduino Yun doesn't work with RFID-RC522 module.

What is diffrent Uno and Yun?

1- http://www.grantgibson.co.uk/2012/04/how-to-get-started-with-the-mifare-mf522-an-and-arduino/


texts: Yun as a Conventional Wireless Access Point

texts: I want my YUN to act as a server in a client/server architecture so students can control their wifi robots via their desktops. I can plug the YUN directly into an ethernet port on our network and want to have robots communicate with it through a client/server architecture. Can somebody steer me in the right direction?


texts: How can I switch from ArduinoOTA to ESPhome safely?

texts:
I have an ESP8266 (ESP-12F), which I flashed with ElegantOTA, a variation of ArduinoOTA with just a different interface. I never managed to flash anything else, so it's a bare OTA I flashed using a dedicated programmer. The device has not even pins for further flashing.

The ESP is already in a device that I would like to avoid opening, and I would like to avoid soldering pins and flashing locally the ESPhome firmware (which is also configured for future OTA).

I'm not sure the bootloader or whatever is used to self-flash the chip is compatible. How can I do it?

Or should I just open the ArduinoOTA webpage, upload a ESPhome firmware and go on?


texts:
we are using 8051f387 microcontroller 8bit,
need display code for the same,
I can answer any or all question about it pls help me with the same.


texts: Connecting an Arduino Nano, Mega and LCD via I2C works but fails when shutting down Mega

texts:
I have connected an Arduino Nano, Mega and a LCD via I2C/TWI (SDA/SCL).

The Nano is playing the master while Arduino Mega and LCD are slaves. This works well till I power off the Arduino Mega. Of cause I don't expect the Mega to answer.

In particular the SCL line seems to pull-down the connection. Disconnecting SCL from the Mega will reestablish the connection to the LCD. I added two pull-up resistors 4.7k to both SDA SCL but no improvement from that.

Is there no way than physically disconnecting the lines?


texts:
I am trying to correctly power a Lilypad Arduino that is attached with an HC-05, Lilypad temp sensor, and Amped pulse sensor. So far I have found that powering by plugging the Lilypad into my laptop and using three coin cells in parallel will allow for the Pulse sensor and Temp sensor to function properly. When I attach the HC-05, the readings become extremely incorrect. To remedy this, I attached the HC-05 to a 9v battery.

As I'm sure you can tell, I am novice to say the least. How can I properly power these components without damaging them. Thank you.

Update : I failed to tweak the program to reflect voltage change when disconnected from laptop. Temperature data much better and BPM is correct. Only issue that remains is the question of how to safely power all components through Lilypad. Thanks again.


texts: Store button presses in an array and sequince it with the LEDs

texts:
Example: If the user presses the button sequence 1-2-2-1 then the LEDs light up in the order 1-2-2-1
int userAmount[4];
const int ledPins[] = {4, 5};
const int btnPins[] = {8, 9};

int buttonState_1 = 0;

void setup() {
  Serial.begin(9600);
    for (int n = 0; n < 4; n++)
     {

     }
     pinMode(PIN_BUTTON_1, INPUT_PULLUP);
}

void loop() {
  buttonState_1 = digitalRead(PIN_BUTTON_1);
   if (buttonState_1 == LOW)
      {
        for (int i = 0; i < 4; i++)
        {

        }
      }
}


texts: Fast PWM working with int main(void) but not with void setup()

texts:
board: Arduino Mega (ATMEGA2560)

I want to generate pulses using timer1 configured as Fast PWM, this is my code which works fine:

#include <avr/io.h>

int main(void)
//void setup()
{

  DDRB |= (1 << DDB5) | (1 << DDB6); // PWM outputs

  ICR1 = 0x7FFF;  // TOP
  OCR1A = 0x3FFF; // 50% of ICR1
  OCR1B = 0x3FFF; // 50% of ICR1

  TCCR1A |= (1 << COM1A1) | (1 << COM1B1);
  TCCR1A |= (1 << WGM11);
  TCCR1B |= (1 << WGM12) | (1 << WGM13);
  TCCR1B |= (1 << CS10);

}

void loop() {

}

I don't understand why it doesn't work if I use void setup() instead of int main(void). I'm working with arduino IDE 1.8.2 and always used void setup(), in this case I used int main(void) because it is used in some turorials I found like this one: https://www.youtube.com/watch?v=O_Yqf_cugwE

EDIT: When I say that it doesn't work, what happens is that instead of having PWM signals I just have a constant 5V output in both OC1A and OC1B pins


texts:
When trying to upload to my Mega r2, it simply times out during uploading.

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

I tried burning the bootloader, but that also gave an error.

Error while burning bootloader.
avrdude: usbdev_open(): did not find any USB device "usb"

I can see the arduino in my Devices and Printers in control panel, so I don't think the board is burnt.  The power light also is on.  Any ideas?


texts:
As I understand, Arduino IDE considers two paths for the libraries:

first,

  "C:\Program Files\Arduino\libraries"

and second, the "libraries" folder next to the schetchbook.

I have a configuration.h file, that I include in the main file, Test.ino, like this:

#include <configuration.h>

and in the configuration.h file I try to include SPI.h like this:

#include <SPI.h>

But I get the following error:

fatal error: SPI.h: No such file or directory

It seems that I am obliged to include SPI.h only from the ino file. But why?
And how can I do what I want here? do I have to change IDE?

P.S: the software is large and I am improving maintainability.


texts: Convert uint8_t array to ascii character for serial transmission

texts:
I am trying to send packets of via bluetooth data that include 6 bytes read from a sensor and stored in a uint8_t array. Instead of sending over the data as numerical digital, I would like to send the ASCII character of each of the bytes. I am doing this to reduce the size of my data packets and make it easier to interpret the incoming data.

uint8_t* temp = readBufferData(FIFO);

for (int i = 0; i < 6; i++)
{
    Serial.write(temp[i]);

}

Read buffer data returns a pointer to a uint8_t array read from a FIFO buffer.
When I use Serial.print, I get the following output, which makes sense.
22163226094255
One question is, when I use Serial.print on a single character, is it transmitted a single byte, or is it actually sending the decimal digital of the number, anywhere from 1-3 bytes?

When I use the Serial.write, however, I get something like the following
DÿÂ?ÁÏ?ÌÆ?Ûµ?Ë½?ÔÀ?Ð¿?ÃÕÓÑËÐTÿÀ?Ï3ÿÉ?¹4ÿÐ?Ê<ÿ½?µfÿ¼?ìNÿÐ?×Â?ÊÚ?×¿?Å
Also, these data display much more slowly on the screen, than normal.

How can I send each uint8_t value by sending over the corresponding ASCII character for serial transmission?

Thanks!


texts: How to send a message to my phone that my Arduino system is on when turning on my Arduino

texts:
i have installed a GSM shield on the Arduino to create security alarm system using PIR SENSOR when ever there motion I will receive a call to my phone.
but i want to add also a line of code which can make my system send me a txt message stating that my system is turned on so i can make sure that when ever i turn my system on i can doule check by getting a message that says that system is turned on successfully
i dont know how to start doing that.
this is the code i did:
int PIR = 6;

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

void loop() {
  // put your main code here, to run repeatedly:
if (digitalRead (PIR == HIGH)){
  Serial.println("thief detected");
  delay (200);
  Serial.println ("ATD+0197263315;");
  delay(1000);
  Serial.println("ATH");
  delay(1000);

  }
  else digitalWrite (PIR, LOW );

}


texts:
I'm looking into working with an Arduino micro, and I'd like to be able to plug it into my computer directly(without a cable). I've been looking around, and the best thing that I found was this. The reason I haven't bought the linked adapter is because I've seen a number of bad reviews of the seller with close to half of the reviews being 1-star. Anybody have an idea where I can find something similar?

EDIT: I'm going to be using this for security testing, emulating a rubber ducky usb, so I need the computer to recognize the Arduino as an HID, not an arduino, but I also (obviously) need to be able to load my code onto it


texts: Generate 5VDC signal when external sensor input changes from high to low

texts:
I am new to arduino.  I have a project in which I need an arduino to generate a +5VDC  signal in response to a change of status, (high/5VDC To low/ground) from an external source.

The external source is a stand alone receiver/transmitter set which outputs +5VDC when the transmitter is out of range and ground when the transmitter is within range.

The goal is to have the arduino output +5VDC (triggering a series of events) only when the TX is within range of the RX (signal voltage is GRND vs. +5vDC).  The series of events are controlled via a stand alone event controller which is initiated by a +5VDC signal courtesy of the arduino.

I already have a RX/TX set which outputs +5VDC when the the TX is absent and GROUND when the TX is within range.  I also have the event controller.  I only need the arduino solution.

I have an arduino UNO but I am open to other option if needed.

Solution: give me +5VDC when signal voltage (from receiver) is low (ground).

If anyone could point me in the right direction it would be greatly appreciated.  This is my first arduino project so I have much to learn.

Best regards


texts:
I would like to increase the PWM bit resolution of the Arduino Uno.
At this moment it is 8-bit which I consider too low.
Is this possible without losing the ability of interrupts and delays?

Koen

EDIT
This setup delivers a 16-bit resultion

void setupPWM16() {
    DDRB |= _BV(PB1) | _BV(PB2);        /* set pins as outputs */
    TCCR1A = _BV(COM1A1) | _BV(COM1B1)  /* non-inverting PWM */
        | _BV(WGM11);                   /* mode 14: fast PWM, TOP=ICR1 */
    TCCR1B = _BV(WGM13) | _BV(WGM12)
        | _BV(CS11);                    /* prescaler: clock / 8 */
    ICR1 = 0xffff;                      /* TOP counter value (freeing OCR1A*/
}
/* Comments about the setup
Changing ICR1 will effect the amount of bits of resolution.
ICR1 = 0xffff; (65535) 16-bit resolution
ICR1 = 0x7FFF; (32767) 15-bit resolution
ICR1 = 0x3FFF; (16383) 14-bit resolution etc....

Changing the prescaler will effect the frequency of the PWM signal.
Frequency[Hz}=CPU/(ICR1+1) where in this case CPU=16 MHz
16-bit PWM will be>>> (16000000/8)/(65535+1)=30.5175Hz
*/

/* 16-bit version of analogWrite(). Works only on pins 9 and 10. */
void analogWrite16(uint8_t pin, uint16_t val)
{
    switch (pin) {
        case  9: OCR1A = val; break;
        case 10: OCR1B = val; break;
    }
}


texts: Do Arduino Nano Every devices short out?

texts:
I have an Arduino Nano Every device that seems to have shorted out.
I use a lighted USB hub with buttons that turn connections on and off.  Each button has its own LED that indicates power state for its associated port.
Anyway, when I plug my Arduino Nano Every into that USB hub, the lighted buttons turn off for half of the hub, like the Arduino is shorting out the hub.
I use a different Arduino and have no problems, so it's definitely the Arduino.
Any idea what could have caused this?  I was using the Arduino with a TMUX1511 switch chip and using pins  D9-D12 to turn on and off the 4 internal switches in the chip.  It's using very low voltage (5v) and amperage is (25 mA).  I used the 5v and gnd pins on the Arduino to power the TMUX1511 chip, but with such low amperage, I can't see how that could have caused the Arduino to fry.
Any ideas?


texts:
I am trying to write a keyboard (Key-glove) program. There are 4 buttons, and inputs should type specific keys. when the keyboard is active, I get output, but not what I am expecting for output. I get "EnE" and "EC".
The Hardware is an adafruit Circuit Playground

Here is my source:

//keyboard control for TuxKart power Glove
#include <Adafruit_CircuitPlayground.h>
#include "Keyboard.h"

// set pin numbers for the five buttons:
const int Fire = 6;
const int Nitro = 9;
const int Eagle = 10;
const int _Esc = 12;

bool slideSwitch;

void setup() { // initialize the buttons' inputs:
  pinMode(Fire, INPUT);
  pinMode(Nitro, INPUT);
  pinMode(Eagle, INPUT);
  pinMode(_Esc, INPUT);

  Serial.begin(9600);
  // initialize mouse control:
  //Mouse.begin();
  Keyboard.begin();
}

void loop() {
  if (!CircuitPlayground.slideSwitch()) {
    return;
  }

  // use the pushbuttons to control the keyboard:
  if (digitalRead(Fire) == HIGH) {
    Keyboard.write('KEY_SPACE');
    Serial.println("A");
  }
  if (digitalRead(Nitro) == HIGH) {
    Keyboard.write('n');
    Serial.println("B");
  }
  if (digitalRead(Eagle) == HIGH) {
    Keyboard.write('KEY_BACKSPACE');
    Serial.println("Z");
  }
  if (digitalRead(_Esc) == HIGH) {
    Keyboard.write('KEY_ESC');
    Serial.println("Y");
  }
delay(700);
}


texts: Adding a custom board to the Arduino IDE

texts:
I would like to know what is the procedure for adding a custom board to the Arduino IDE?

My custom board is similar to the Arduino Zero. Instead of using the ATSAMD21G18, my board is based around the ATSAMC21G18. I also have the Atmel/Microchip SAMC21 Xplained development board.

I have found some open source code where the author has adapted/forked the Arduino SAMD21 code and made it work for the SAMC21 Xplained board (here). The author has stuck to the Arduino hardware folder structure and has added the SAMC21 Xplained to the board.txt file.

As a test, when I install the Arduino SAMD21 from the Arduino Board Manager, I noticed that it installed the hardware files in the following directory:

 %LOCALAPPDATA%\Arduino15\packages\arduino\hardware\samd\1.6.19\

I have read that to add hardware files to the board manager I need to create a .json file with the appropriate details. More information here. However, as far as I can tell, this requires me to zip the SAMC21 hardware files into a tarball and provide a URL to that tarball. I also need to generate and insert a SHA in the .json file.

Am I on the right path with the .json file?

Or should I just download the SAMC21 hardware files and place them in the %LOCALAPPDATA%\Arduino15\packages\arduino\hardware\samd\ folder next to the 1.6.19 folder?

My last resort would be to just copy the files into the existing SAMD21 hardware folder?

I have looked into the following Arduino SE questions but they do not answer the question satisfactorily.

upload.tool not used in custom boards.txt?
Arduino Due custom platform for school and library installation (I would prefer not to use the Arduino IDE in portable mode.)


texts: Controlling multiple solenoids with arduino

texts: I was wondering how I could connect multiple 12v solenoids (more than the 53 allowed on mega because of the pins) on the Arduino Mega 2560 to get it to control the keys on a piano/keyboard/organ. Would 74HC595 shift register work for it with the 12v? (Many of them) Because there are so many high voltage solenoids is it possible to control a few of them at a time? I was wondering if someone has a link to somewhere that I could refer to. Thanks


texts:
i was trying to send some data to a webpage via esp8266wifi module connected to arduino uno. My sketch contains a header file .After searching online I could get the library Arduino-master.zip from github. I extracted the files and put it in inside the directory arduino->hardware->arduino->avr->libraries.but even then it was showing me the error message like this:

 fatal error: ESP8266WiFi.h: No such file or directory

 #include

                         ^

compilation terminated.

exit status 1
Error compiling for board Arduino/Genuino Uno.

How can I remove this error. please refrain from technical words as i am new to this language. Thank you.

EDIT: After adding esp8266WiFi.h in the library i got out from that error message .But it showed me a new one

C:\Program Files (x86)\Arduino\libraries\ESP8266WiFi\src/ESP8266WiFiType.h:26:19: fatal error: queue.h: No such file or directory

 #include

                   ^

compilation terminated.

exit status 1
Error compiling for board Arduino/Genuino Uno.

I dont know how to come out of this error. some websites give a solution but it didn't worked for me.


texts: printing the analogRead() functions result crashes Arduino

texts:
I have created a curcuit which reads the analog pin 3 auf the arduino nano and does other things dependant on the returned value. However I have problems regarding the analogRead() function. Whenever I use a piece of wire to short the "Analog_UpDownHorn_Signal" and do it fast paced so that the arduino reads 0V and 5V repeatedly the serial communication stops. Sometimes it resumes. Sometimes it doesn't and when it does the value is always 1023.
I have managed to reduce the problem to the following 2 lines of code, which leads me to believe its my curcuit or a bug in the functions used. Before the arduino gets stuck it sometimes puts out random '?' or other wierd characters on the serial monitor.
void setup()
{
  Serial.begin(9600);
}

void loop()
{
  Serial.println(analogRead(A3));
}


texts: Reset Arduino by connecting vcc and gnd?

texts:
A follow up question on my previous question, if a memory card reader can be used with three pins (digispark Attiny 85):

Can I read from a memory card with three pins?

Now I came up with another idea.
Since the USB connector or the VCC pin can power an Arduino my guess is that they are in parallel and the actual Arduino is connected to both.
Kind of like this very bad schematic made on my phone: (sorry for that)

Where the blue stuff is the Arduino chip.

If that is true then adding the push button between VCC and GND with a resistor between should remove the power of the Arduino?
In that case I can have my code in setup() and use the pus button to reset the Arduino, and still have four pins to the memory card reader.

Or is this wrong? What kind of resistor value do I need to make sure I don't short the USB connector but still have less resistance than the Arduino chip?


texts: Problem while writing sketch for GSM module sim800

texts:
I wanted to my GSM to recieve SMSs. I have written a sketch for it. But while verifying the sketch an error pops out in this part:

if (sms.available()) {
      sms.remoteNumber(senderNnumber, 20);
      if (senderNumber == "09432167015") {
        c = sms.read();
      if (c == "yes") {
          alarm_police();
          }
        }
      }
The error message:

  Arduino: 1.6.5 (Windows 8.1), Board: "Arduino/Genuino Uno"

  GuardDog_v2.5.ino: In function 'void loop()':
  GuardDog_v2.5:201: error: 'senderNnumber' was not declared in this scope
  GuardDog_v2.5:204: error: ISO C++ forbids comparison between pointer and >integer [-fpermissive]
  'senderNnumber' was not declared in this scope

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

I have checked the receiving sms example and have written the sketch according to the example.I need help regarding this error and how to fix it


texts: Alternative IDE for compiling and running arduino code?

texts:
I am not super experienced with c++ and I know that the syntax for C++ and the code written/compiled by the arduino IDE are slightly different.

I would like to be able to write code, compile it the same way the arduino IDE does, and run it, without uploading it to a board.

I dont need to test any code that interacts with any hardware. I simply want to be able to test basic syntax to make sure my concepts work before integrating with the full program.

I have written a few Arduino programs and I think the most complicated thing I've used were pointer functions, but I'd like to be able to test out code without needing to upload to a board for every change, while relying on Serial.print.

I have found alternatives that help with debugging and although that is helpful, I'd like to avoid the need to upload to a board every time I want to test changes for basic concepts


texts:
We are doing a project and have to use around 25 temperature sensors. Is there a way to shift through them on one Arduino similar to using a shift-register?

It is a set of analog sensors in a fridge.


texts: I want to send the last 10 minute data via bluetooth

texts:
This was for photocell data logging for 30 sec intervals, now I want to write a code which commands from the cellphone and sends back the last 10 minute data.

At first I thought if I make an array of 20 buckets and put it in a loop, then send the loop function to android would make it right. But it just sends me continues data. I only want the last 10 minute data of the program.

float sensorvalue[20];

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

    for (int i = 0; i < 20; i++) {
        pinMode(sensorvalue, OUTPUT);
    }
}

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

    if(Serial.available()) {
        c=Serial.read();
        if (c=='t')
            sendvalues();
    }
}

void sendvalues()
{
    for (int i=0 ; i<20 ; i++) {

        Serial.println(sensorvalue);
        sensorvalue   = analogRead(A0);
        delay(30000); //every 30 seconds read data

        if (i>=20) {
            i=0; //reset to beginning of array, so you don't try to save readings outside of the bounds of the array
        }
    }
    Serial.println("***********************************");
}


texts: How to wire up and trigger this SPDT relay?

texts:
How do I connect a SPDT relay to an Arduino?

It's a DC 5V Coil 6 Pin relay and ultimately what I want to do is have the Arduino trigger the relay to allow voltage to pass through.

I couldn't find a data sheet, but apparently this is the layout...

----------------------------------
|....1......2..............3.....|
|................................|
|....4......5..............6.....|
----------------------------------

2 and 5 are the 5v relay coil
3 and 6 are shorted together
3 and 1 are normally closed
3 and 4 are normally open


texts:
I have been trying to get a button matrix to work but im not experienced enough in programming.
I Have tried to read up but i don't know how to execute so some help would be greatly appreciated.
I want the keypad to function as a game controller of sorts. when i pres the 1 key on the keypad i want the read light to light up and only go out when i release the button. code was copied from "mstanley" on arduino forum.
Q: How do i use the Keypad.h library to get my keypad press to run one line of code when i press a button and another line when i release the button.
I Was testing with leds now, the code is identical, digitalWrite(1, HIGH); then digitalWrite(1, LOW); this can easily get exchanged for joystic.PressButton 1 and Joystick.ReleaseButton 1

#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {9,8,7,6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5,4,3,2}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

char holdKey;
unsigned long t_hold;

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

  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
}

void loop(){
  char key = keypad.getKey();

   if (key){
     holdKey = key;
     Serial.println(key);
   }

   if (keypad.getState() == HOLD) {
      if ((millis() - t_hold) > 100 ) {
          switch (holdKey) {
              case '1':
                  digitalWrite(11, HIGH);
                  delay(200);
                  digitalWrite(11, LOW);
                  break;
              case '2':
                  digitalWrite(12, HIGH);
                  delay(200);
                  digitalWrite(12, LOW);
                  break;
              case '3':
                  digitalWrite(13, HIGH);
                  delay(200);
                  digitalWrite(13, LOW);
          }
          t_hold = millis();
      }
   }
}


texts: Opening a program in administrator with Arduino (DigiSpark/DigiSparkKeyboard)

texts:
I am quite new to Arduino and DigiSparkKeyboard so I don't know much about them. I am trying to get by DigiSpark to open CMD in administrator mode but it just doesn't work. I know that I need to get it to press control, shift and enter at the same time in order for it to run as administrator but it doesn't work.
At the moment my code looks like:

#include "DigiKeyboard.h"
#define MOD_SHIFT_LEFT      (1<<1)  //00000010
#define MOD_GUI_LEFT        (1<<3)  //00001000
#define MOD_CONTROL_LEFT    1
#define KEY_ENTER   40
#define KEY_C       6
#define KEY_M       16
#define KEY_D       7
void setup() {
  // put your setup code here, to run once:
  DigiKeyboard.update();
  DigiKeyboard.sendKeyStroke(0);
  DigiKeyboard.sendKeyStroke(0, MOD_GUI_LEFT);
  DigiKeyboard.delay(1000);
  DigiKeyboard.sendKeyStroke(KEY_C);
  DigiKeyboard.sendKeyStroke(KEY_M);
  DigiKeyboard.sendKeyStroke(KEY_D);
  DigiKeyboard.delay(1000);
  DigiKeyboard.sendKeyStroke(MOD_CONTROL_LEFT + MOD_SHIFT_LEFT + KEY_ENTER);
}

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

}


texts: Trying to understand bitbanging, shiftIn(), reading EEPROM

texts:
Alright, so I have an Atmel 93C66, http://www.atmel.com/Images/doc0172Z.pdf Datasheet and I'm wanting to read whatever is in it.

I copied the following code from this thread http://forum.arduino.cc/index.php?topic=96411.0 and made some changes to it, mainly I deleted the part where it writes:

//difining pins for eeprom
int CLOCK =4;
int DATA_OUT =3;
int DATA_IN = 2;
int CHIP_SEL =5;

int low =0;     //low address

byte READ  = 0b1100;                //read instruction

void setup(){

  pinMode(CLOCK ,OUTPUT);
  pinMode(DATA_OUT ,OUTPUT);
  pinMode(DATA_IN ,INPUT);
  pinMode(CHIP_SEL ,OUTPUT);
  digitalWrite(CHIP_SEL ,LOW);
  digitalWrite(CLOCK, LOW);
  Serial.begin(9600);
}

void loop()
{

  for (int i=0;i<=511;i++)
  {
    digitalWrite(CHIP_SEL ,HIGH);
    shiftOut(DATA_OUT,CLOCK,MSBFIRST,READ); //sending READ instruction
    shiftOut(DATA_OUT,CLOCK,MSBFIRST,low);   //sending low address
    byte incoming = shiftIn(DATA_IN,CLOCK,MSBFIRST); //receiving data
    digitalWrite(CHIP_SEL ,LOW);

    Serial.print(low);
    Serial.print("/t");
    Serial.print(incoming, BIN);
    Serial.print("/t");
    Serial.print(incoming, HEX);
    Serial.println():

    low++;       //incrementing low address

  }
  while(1);
}

What I'm trying to understand is:

In the 93C66 datasheet page 5, table 6, it says that to read the contents of memory I need to send SB 1, OPCODE 10, and memory address, which I don't know exactly how to do, but I guess the chip wants a 110 (or a HIGH, HIGH, LOW signal) plus memory address (variable “low”=0). The SB and OP CODE are similar to the BYTE variable READ in the code above, but this variable has an extra 0 (1100). I tested the code with 110 and I get different incoming data. I also thought if BYTE is 8 bits then why not make the BYTE variable READ 11000000, but it changes the incoming data. So now I don't really know how exactly to send SB 1 and OP CODE 10. Need help with that.

Also, as you can see I'm printing the variable "low" and the variable "incoming" (in Binary and Hex) on one line, I thought it would be printing 1 bit per line, but it prints varying amounts of bits. Sometimes it would print 4 bits, 6 bits, or 8 bits, as in 1110, 11111111, 111100. I thought the line byte incoming = shiftIn(DATA_IN,CLOCK,MSBFIRST);
would get filled with 8 bits all the time, so when I Serial.print() it would have 8 bits, but it's not happening, why?

Also I thought the shifting in of the bits into the variable "incoming" occurs once in the for loop, or is there an inner loop in shiftIn()? I ask because I first made the for loop go for i=<4095, since there are 4096 bits in this EEPROM, but the increment of I doesn’t match the amount of bits I’m getting on each Serial.print() line.
i.e. I would get something like this:

1   10111111    BF

I thought it would be getting something like this. (I’m thinking the shiftIn() of the 1st bit at address 0 happens when i=0, then 2nd bits gets shiftIn() when i=1, and so forth)

1   1
2   1
3   0
4   1
Etc, etc

How is shiftIn() shiftinf in the bits into the BYTE variable?

Thanks and sorry if it’s so many questions.


texts: Use Higher Resistance Than Instructed in a Circuit

texts:
I'm following the "Get Started with Arduino" Guidebook, and I'm at the part where pulse width modulation (PWM) is discussed.

The instructions say to create a simple circuit with a breadboard, red LED, arduino (connected at pin 9 and ground) and a 270 ohm resistor. My power source will be the usb connection.

I have a 510 ohm resistor.

May I use it instead?
In general, will using a resistor with a higher resistance than intended in a circuit fry the arduino?

Thanks very much for your help. I'm new to arduino and electronic circuits. I have a Uno R3.


texts: Can i run my python based virtual Assistant using esp32 I want it use it as a user endpoint?

texts: I have a working project which is python based virtual assistant and now I am thinking to make it more accessible than carrying my laptop. I want to make a device like alexa echo dot more or less.. Can anyone tell me is it possible?


texts: Casting a struct member between uint8_t and char, with regard to serial transfer

texts:
Im simply trying to pass my payload to another device that has the same architecture and struct. I'm using UART to transfer, and modeling the protocol from EasyTransfer.
When I call Serial.print((char*)mydata.data); in Transfer it prints Hello World as expected.
Calling that same line in Receive prints a '?' to console. This may be some background behavior with Arduino, or I'm just not casting/handling the pointers correctly. How can I get this print out to function properly?
Transfer Sketch
#include <EasyTransfer.h>

//create object
EasyTransfer TransferObject;

//Struct contents must be idential to struct from other board
#define PAYLOAD_SIZE 255
struct SEND_DATA_STRUCTURE
{
  int blinks;
  int pause;

  uint8_t data[PAYLOAD_SIZE];
};

//give a name to the group of data
SEND_DATA_STRUCTURE mydata;

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

  //#define details(name) (byte*)&name,sizeof(name)
  TransferObject.begin(details(mydata), &Serial);

  pinMode(13, OUTPUT);

  //initalize not so random number generator
  randomSeed(analogRead(0));

}

void loop()
{
  //mydata.blinks = random(5);
  //mydata.pause = random(5);

  //Create payload to transfer
  char* payload = "Hello World!";

  //Fill array with data
  strncpy((char *)mydata.data, payload, PAYLOAD_SIZE);

  //Print sample
  Serial.print((char*)mydata.data);

  //send the entire struct
  TransferObject.sendData();

  delay(5000);
}

Receive Sketch
    #include <EasyTransfer.h>

//create object
EasyTransfer TransferObject;

//Struct contents must be idential to struct from other board
#define PAYLOAD_SIZE 255
struct RECEIVE_DATA_STRUCTURE
{
  int blinks;
  int pause;

  uint8_t data[PAYLOAD_SIZE];
};

//give a name to the group of data
RECEIVE_DATA_STRUCTURE mydata;

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

  //#define details(name) (byte*)&name,sizeof(name)
  TransferObject.begin(details(mydata), &Serial);

  pinMode(13, OUTPUT);

}

void loop()
{
  //check and see if a data packet has come in.
  if(TransferObject.receiveData())
  {
    Serial.print("active");
    //print data payload
    Serial.print((char*)mydata.data);
    }

  //you should make this delay shorter then your transmit delay or else messages could be lost
  delay(250);

This is an exerpt and variant from this library


texts:
iam currently working on a new project, where i would like to detect the existence/closeness of several objects around the arduino up to like 1 meter. I was thinking about an rfid setup, but as the objects could have different sizes like 5 centimetre tall and only 3 centimetre wide, i think this won't work for the max distance. I was also thinking about a ble beacon, but as this one has to be activley powered all the time, it wouln't be the perfect solution. As the base could be fully customized, it may have some kind of sensors/wires overall the surface, but iam a bit lacking of a good idea for this.
I hope someone might had a similar setup, or a good idea to go.
PS: When i think about it twice, it would be better, if it can be differentiate between some areas within the one meter and the different objects, entering each area. I've added some image, hope this helps to understand, what i want to archive at the end.

Thank you and greetings,
Sebastian


texts:
I am trying to call a function that will turn a stepper motor a number of steps depending on the value submitted through the serial console. For an example, if I submit 50, the motor should turn 50 steps clockwise (and counter clockwise for  a negative value).

#include <Stepper.h>
#define STEPS 200
Stepper stepper(STEPS, 8, 9, 10, 11);

int serial_input = Serial.read();

void setup() {
Serial.begin(9600) ;
stepper.setSpeed(30);
}

void loop() {
}

void turnMotor(serial_input){
  stepper.step ( serial_input ) ;
}

And here are the errors I get:

Motor4.ino:12:28: error: variable or field ‘turnMotor’ declared void
Motor4.ino:12:16: error: ‘serial_input’ was not declared in this scope
Motor4.ino:117:28: error: variable or field ‘turnMotor’ declared void

Thank you


texts: Running Arduino Code without opening serial monitor

texts:
I have a GSM module connected to arduino. I wrote a code that sends a command to GSM module but the code starts executing only when I open Serial Monitor.
Minimal Reproducable Code -
#include <SoftwareSerial.h>    //Library required for serial communication
SoftwareSerial sim800l(3, 2);
void setup() {
  Serial.begin(9600); //Start the serial interface on 9600
  sim800l.begin(9600);
  delay(100);
   sim800l.println("AT+CMGF=1");
   delay(100);
}

void loop() {
sim800l.println("AT+CCLK?");
}

What can I do to run the code as soon as I upload it without opening serial monitor?


texts: Set acceleration for stepper motor with no ending

texts:
I have a problem. I am using a stepper motor with 2 buttons. In my code I am trying to rotate the stepper motor clockwise while holding button1 and counter-clockwise while holding button2. To do that, I had the following code:
#include <AccelStepper.h>

// Define button pins
#define btnLowerPin 5
#define btnRaisePin 6

// Define stepper motor connections and motor interface type.
#define dirPin 2
#define stepPin 3

int btnLowerState = 0;
int btnRaiseState = 0;

// Create a new instance of the AccelStepper class:
AccelStepper stepper = AccelStepper(AccelStepper::DRIVER, stepPin, dirPin);

void setup() {
  // initialize the button pins as an input:
  pinMode(btnLowerPin, INPUT);
  pinMode(btnRaisePin, INPUT);

  // Set the maximum speed in steps per second:
  stepper.setMaxSpeed(1000);
}
void loop() {
  // read the state of the button values:
  btnLowerState = digitalRead(btnLowerPin);
  btnRaiseState = digitalRead(btnRaisePin);

  if (btnLowerState == LOW) {
    stepper.setSpeed(-1000);
    stepper.runSpeed();
  }
  else if (btnRaiseState == LOW) {
    stepper.setSpeed(1000);
    stepper.runSpeed();
  }
  else {
    stepper.setSpeed(0);
    stepper.runSpeed();
  }
}

This code worked, but I have to accelerate the motor to the speed of 1000. I found this article that explains how to do that: https://www.makerguides.com/28byj-48-stepper-motor-arduino-tutorial/. In code #3 they use the following code:
void setup() {
  // Set the maximum steps per second:
  stepper.setMaxSpeed(1000);
  // Set the maximum acceleration in steps per second^2:
  stepper.setAcceleration(200);
}
void loop() {
  stepper.moveTo(8192);
  stepper.runToPosition();

  delay(1000);

  stepper.moveTo(0);
  stepper.runToPosition();

  delay(1000);
}

Now I tried combining it, but the problem is that I don't know how far the motor has to rotate, because its While holding the button. Here was my code:
void loop() {
  // read the state of the button values:
  btnLowerState = digitalRead(btnLowerPin);
  btnRaiseState = digitalRead(btnRaisePin);

  if (btnLowerState == LOW) {
    stepper.moveTo(8000);
    stepper.runToPosition();
  }
  else if (btnRaiseState == LOW) {
    stepper.moveTo(0);
    stepper.runToPosition();
  }
  else {
    stepper.setSpeed(0);
    stepper.runSpeed();
  }
}

But this code stops when the loop is over and restarts the acceleration. How can I fix this?
So in short:

The motor needs to accelerate when you start holding the button.
The acceleration has to be 300 and max speed 1000.
When you release the button it decelerates to 0.


texts: How esp8266 gets response from server..?

texts:
#include <SoftwareSerial.h>

const byte rxPin = 2;
const byte txPin = 3;

SoftwareSerial ESP8266 (rxPin, txPin);

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

void printResponse() {
  String s="";
  while (ESP8266.available()) {
    s+=ESP8266.readStringUntil('\n');
  }

  Serial.println(s);
  // now here you can parse and look for "+IPD" look for another line ending (if there is) and then extract the numeric value.
}

void loop() {

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

  ESP8266.println("AT+CIPSTART=4,\"TCP\",\"www.tcpss.000webhostapp.com\",80");
  delay(1000);
  printResponse();

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

  ESP8266.println(cmd);
  delay(1000);
  ESP8266.println();
  delay(1000);
  printResponse();

  delay(5000);
}

i have run this code and i am able to get this  response from server like "+ipd 4,41".... what does it mean?
here is the response after run the code in arduino......
WIFI GOT IP
AT+CIPLUX=1

OK
AT+CHPSTART=4,"TCP","www.tcpss.000webhostapp.com",80

4,CONNEC
AR)CR5NB⸮b⸮⸮k

j⸮L⸮⸮
Recv 27 bytes

SEND OK

+IPD,4,41

Thanks in advance.....


texts:
I'm trying to use nRF24L01 module to send a messages between 2 arduinos

Transmiter code:

  const char text[] = "Hello World";
  radio.write(&text, sizeof(text));

  delay(1000);

Reciver code:

char text[32] = {0};
radio.read(&text, sizeof(text));

Serial.println(text);

How I can put into char array an int value?
I tried doing it in this way

For example:
      int a = 60;
      const char text[] = String(a);
      radio.write(&text, sizeof(text));

  delay(1000);


texts: error using String class to convert a double to a string

texts:
i wanted to convert a double to a string i tested several examples online i allawys get the same error.

the code :

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

}
void loop()
{
  double val =3.2222;
  String stringOne =  String(val, 3);
  Serial.print(stringOne);
}

the errors :

sketch_jun02c.ino: In function ‘void loop()’:
sketch_jun02c.ino:10:36: error: call of overloaded ‘String(double&, int)’ is ambiguous
sketch_jun02c.ino:10:36: note: candidates are:
In file included from /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:192:0,
                 from sketch_jun02c.ino:2:
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:70:11: note: String::String(long unsigned int, unsigned char)
  explicit String(unsigned long, unsigned char base=10);
           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:69:11: note: String::String(long int, unsigned char)
  explicit String(long, unsigned char base=10);
           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:68:11: note: String::String(unsigned int, unsigned char)
  explicit String(unsigned int, unsigned char base=10);
           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:67:11: note: String::String(int, unsigned char)
  explicit String(int, unsigned char base=10);
           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:66:11: note: String::String(unsigned char, unsigned char)
  explicit String(unsigned char, unsigned char base=10);
           ^


texts: Reading Serial Data sent from PC to Arduino with help of another Arduino

texts:
I am trying to sniff the Serial Communication between the PC and Arduino MEGA 2560. For trying to check what my PC is sending to my Arduino. I am using another Arduino MEGA 2560 to read this data since my serial monitor is busy.
To this I have connected RX pin of my arduino to RX Pin of my second arduino and both have common ground. In this way i thought i can use serial monitor of my second arduino to see the data what my pc is sending to Arduino.
But when i upload the program to Arduino, I am getting the following error

avrdude: stk500v2_ReceiveMessage(): timeout avrdude:
stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage():
timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude:
stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage():
timeout avrdude: stk500v2_getsync(): timeout communicating with
programmer

I dont have any problems when i use only one Arduino.
One Arduino uses COM Port 4 and other uses COM Port 5. I am not sure what is going wrong. I googled this problem and found few things but none of them were quiet working for me.
The main issue which i am not sure is if i can use Arduino IDE instance twice(one for each arduino with different com port) and check what my pc is sending to first arduino with the help of second arduino.
Can anyone suggest some other alternative on how to see serial data when serial monitor is busy or when we cant use serial monitor?


texts: What is the correct folder structure for including local headers in my Arduino project?

texts:
I am designing a "project" with 5 Arduino's (each with separate codes), communicating with each other using NRF24. All the 5 codes are different except they share a common header "MyHeader.h". The Arduino IDE forces the .ino filename to be same as the folder-name it is in. I currently have the following structure:

[parentfolder]
    MyHeader.h
    [arduino1]
          arduino1.ino
    [arduino2]
          arduino2.ino
    [arduino3]
          arduino3.ino
    [arduino4]
          arduino4.ino
    [arduino5]
          arduino5.ino

Now, if I use the following, I get an error that the IDE cannot find the header file:

#include "../MyHeader.h"

I am forced to use the above structure due to the IDE folder naming restrictions, whereas I would definitely like to have a structure like the following:

[parentfolder]
    MyHeader.h
    arduino1.ino
    arduino2.ino
    arduino3.ino
    arduino4.ino
    arduino5.ino

How should I organize my project so that I can include my header (without obviously duplicating the file inside every folder)? Thanks.


texts:
I have a ESP8266_01, and I wired up. It does not work for me.

I have connected the ESP to an Arduino Uno. I am using a 5V pin from uP with a 3.3V regulator, and I have a voltage divider between RX(ESP) and TX(uP). And I am sure that the wiring is correct. The thing is, I am not getting anything back from ESP, not even errors. And I tried to use different baudrates as well. There is a blue LED flashing from ESP only when I am using 115200, and red LED lights up constantly at any other baudrate.

What have I done wrong here?

I did 4 hours of research already and don't know what else I can do now.
If you have any idea, please leave me a word.


texts: I need to make my program run immediately on a reset or power up. However, the bootloader delays program startup by around 2.5 seconds. How can I get over this? Is there a way to turn off the bootloader wait period?


texts:
I am relatively new to Arduino and I am looking to implement a simple system that uses a MIDI keyboard to

(i) detect key presses (via MIDI messages) from the keyboard

(ii) store the information of the MIDI messages (note pressed, velocity)

(iii) Light up LEDS on the keyboard based on what key was pressed

I am currently in the planning stage and I am considering using an Arduino Mega. I have two issues I am not sure about:

(i) My keyboard only has a Male USB A to Male USB B connection with the former connecting to the computer and the latter to the keyboard. So far in my search, I have seen that all Arduino-MIDI projects require a 5 pin MIDI cable to interface with the Arduino using the circuit in this webpage (https://www.instructables.com/id/Send-and-Receive-MIDI-with-Arduino/). Is there any way to detect MIDI messages that does not require the additional circuit and just uses the USB cable?

(ii) Although in theory control of the LEDs should be easy in the program, I am concerned that the delays in the serial communication and hardware interrupts would make it difficult to simultaneously receive the MIDI messages and control the LEDs.

One way I thought of avoiding these problems is to use MATLAB MIDI package (https://uk.mathworks.com/help/audio/ug/midi-device-interface.html#mw_80dc54f4-867c-43c0-a159-e56ee62ec4ab) to interface with the MIDI device and use the MATLAB Arduino package to control the Arduino. I am not sure, however, if MATLAB is suboptimal compared to the standard Arduino IDE.

This is my first question in Arduino StackExchange (or any StackExchange site), so I appreciate the answers and feedback on my question.


texts: Uno pin 13 LED mysteriously always ON at 0.14V unless pinMode OUTPUT

texts:
I upload a blank sketch: pin 13 LED is on. Why?
I connect pin 13 to GND: it turns off until I remove the connection
I connect multimeter between pin 13 and GND: measures 0.14V and LED turns off until multimeter is removed
I press hard reset: LED blinks a few times, turns off for a second then turns on
I upload a sketch that on setup sets pinMode(13, INPUT): pin 13 LED is on
I upload a sketch that on setup sets pinMode(13, OUTPUT): pin 13 LED is off 0.01V
I upload a Blink example: Everything works fine, LED cycles from 4.84V to 0.01V

Why is the LED on unless I set pinMode to output? Have I broken my UNO or is this normal?
I swear it wasn't like this a few days ago.


texts: Powering Arduino Pro Mini with different voltage, fuse setting

texts:
Arduino Pro Mini commonly comes in two packages, 5V 16MHz and 3.3V 8MHz.

The only difference between those two boards are regulator and clock crystal, right?
What happens if I supply 2V to VCC pin of 5V 16MHz board?
What happens if I supply 2V to RAW pin of 5V 16MHz board?
What happens if I supply 5V to VCC pin of 3.3V 8MHz board?
What happens if I supply 5V to RAW pin of 3.3V 8MHz board?

I read from some websites stating that Arduino Pro Mini power consumption can be reduced by removing regulator.

Does removing regulator cause VCC pin = RAW pin?

Jean created a custom board for Arduino Pro Mini rated at 1MHz 1.8V.

Which pin should I supply voltage after changing fuse setting? (Jean changed the fuse setting but I am not sure where to connect the supply voltage of 1.8V)
Related to question 7, is there a need to remove regulator to supply 1.8V?
Can I supply higher voltage (3V) on board with 1.8V fuse setting?

Reason for question/ Confusion

I want to power Arduino Pro Mini using 3V coin cell. Battery voltage decreases after usage to around 2V. I am thinking of simply inserting 3V coin cell to Arduino with 1.8V setting. But regulator may hinder the operation. That is why I am confused. Sites I visited states the possibility of using lower voltage after changing fuse setting but did not mention where to connect and whether regulator need to be removed.

Furthermore, ATmega328p datasheet states the VCC range is 1.8V to 5.5V. If that is so, why not just plug those voltage to VCC pin of Arduino Pro Mini instead of specifically 5V or 3.3V. Question 1-5 should clear my confusion on this.


texts: How can I find and specify the address of my adafruit MMA8451 accelerometer in arduino code?

texts: I am trying to use four of the same accelerometer on the same bus and acquire data from each of them using an SD card. Because I am using four of the same accelerometer I need to be able to differentiate between them and I dont know how to find their specific address. I need the specific address so I can tell my arduino which accelerometer to pull data from. essentially it would pull data from 1 then 2 then 3 then 4 and loop back to 1.


texts:
I'm trying to communicate some numbers between a Linux program and my Ardunino Uno. To this end I wrote a C++ program which somehow contains:

#include <stdio.h>

int a,b;
a = 1;
b = 2000;

File* serial = fopen("/dev/ttyACM0","w");
fprintf(serial,"%d,%d\n",a,b);
fclose(serial);

Now out of standards I guess, the baud rate is 9600 bit/s. If I use stty -F /dev/ttyACM0 115200 I can change the baude rate of that port to 115200 bit/s. However the communication does not work anymore. My arduino program waiting for number,number does not show any action to the same code as before. Oh, and in the Arduino program of course I changed the code to serial.begin(115200);.

How can I change the baude rate in such a setup? If it is a concern, I'm using Ubuntu and an Arduino Uno.


texts: Any possible way to stack Motor Driver shield L293D with Xbee Shield v03 on arduino?

texts: So i am trying to stack these two shield on arduino, now the problem here is that i guess there is a conflict between the pins of arduino being used by both shields, so can anyone suggest a solution?


texts:
I've been trying to send a put request from my esp8266 for a while not but I can't figure out why it doesn't work and there are barely any posts about put requests online
I keep getting errors around int httpCode = http.sendRequest("PUT", String(data));

Error log: https://gist.github.com/dkbay/ab3fedf5e89d841d25b24fb829df74ef

#include <ESP8266HTTPClient.h>

#define LED_BUILTIN 2

const char* ssid     = "Some SSDI";
const char* password = "Some wifi password";

int wifiStatus;

void setup() {

  Serial.begin(115200);\
  pinMode(LED_BUILTIN, OUTPUT);
  delay(200);

  // We start by connecting to a WiFi network

  Serial.println();
  Serial.println();
  Serial.print("Your are connecting to;");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    digitalWrite(LED_BUILTIN, LOW);
    delay(500);
    digitalWrite(LED_BUILTIN, HIGH);
    Serial.print(".");
  }

}

void loop() {
  wifiStatus = WiFi.status();

  if(wifiStatus == WL_CONNECTED){

    HTTPClient http;

    http.begin("http://google.com/");
    http.addHeader("Content-Type", "application/json");
    String data = "{\"on\":false}";
    int httpCode = http.sendRequest("PUT", String(data));
    String payload = http.getString();

    Serial.println(httpCode);
    Serial.println(payload);

    http.end();
     Serial.println("");
     Serial.println("Your ESP is connected!");
     Serial.println("Your IP address is: ");
     Serial.println(WiFi.localIP());
  }
  else{
    Serial.println("");
    Serial.println("WiFi not connected");
  }
  delay(1000); // check for connection every once a second

}


texts: Sending data from Processing and receiving as uint32_t

texts: I need to send data from a processing sketch to an Arduino to pass to a function that takes a uint32_t.  How to I send the data in Processing to be run on the Arduino


texts: What to with reset pin when laying out Arduino PCB?

texts: I'm designing a PCB with a standard arduino ATMEGA328 DIP IC. Do I need to make a connection to the reset pin?


texts: MIDI controlled analog RGB LED strip (code problem)

texts:
I have a an Arduino Uno doing PWM on an RGB analog LED strip ala the Adafruit guide: https://learn.adafruit.com/rgb-led-strips?view=all. I've written a sketch that accepts MIDI data over USB and uses it to control the LEDs.

#include <MIDI.h>
#include <midi_Defs.h>
#include <midi_Message.h>
#include <midi_Namespace.h>
#include <midi_Settings.h>

#include <MIDI.h>

MIDI_CREATE_DEFAULT_INSTANCE();

#define REDPIN 5
#define GREENPIN 6
#define BLUEPIN 3

byte commandByte;
byte noteByte;
byte velocityByte;

byte noteOn = 144;
byte noteOff = 128;

int colorGroup;
int pColor;
int sColor;

void setup()
{
    pinMode(REDPIN, OUTPUT);
    pinMode(GREENPIN, OUTPUT);
    pinMode(BLUEPIN, OUTPUT);
    MIDI.begin(1);
    Serial.begin(115200);
}

void checkMIDI(){
  do{
    if (Serial.available()){
      commandByte = Serial.read();//read first byte
      noteByte = Serial.read();//read next byte
      velocityByte = Serial.read();//read final byte
      }
    }
  while (Serial.available() > 2);//when at least three bytes available
}

void updateLights(){
  colorGroup = noteByte/42;
  pColor = noteByte%41*127/41;
  sColor = 127 - pColor;
  pColor = pColor*velocityByte/127;
  sColor = sColor*velocityByte/127;
  if (commandByte == noteOn && velocityByte > 0){
    if (colorGroup == 1){
      analogWrite(REDPIN, pColor);
      analogWrite(GREENPIN, sColor);
      analogWrite(BLUEPIN, 0);
    }
    else if(colorGroup == 1){
      analogWrite(GREENPIN, pColor);
      analogWrite(BLUEPIN, sColor);
      analogWrite(REDPIN, 0);
    }
    else{
      analogWrite(BLUEPIN, pColor);
      analogWrite(REDPIN, sColor);
      analogWrite(GREENPIN, 0);
    }
  }
  else if(commandByte == noteOff || velocityByte == 0){
    analogWrite(REDPIN, 0);
    analogWrite(GREENPIN, 0);
    analogWrite(BLUEPIN, 0);
  }
}

void loop()
{
    checkMIDI();
    updateLights();
}

Currently this code will turn the lights on and off in accordance with noteOn and noteOff messages. However, the color doesn't seem responsive to the note value and the brightness doesn't seem responsive to the velocity value. I suspect that the problem has to do with my arithmetic combined with the data type (maybe a problem with the order of operations), but I haven't been successful in debugging this.

The idea behind the RGB control is that I take the possible note values (0–127) and map it onto three different combinations of colors: R+G, G+B, and B+R. That's three groups of 42 values: 0-41, 42-84, and 85-127. Then I rescale the 42 values onto 0-127 for the intensity values of the LEDs. Finally I scale the intensity of all the colors by the velocity value over its possible max value.


texts: Problem reading input data using SoftwareSerial library

texts:
I can't read data using SoftwareSerial library, because SoftwareSerial.available() is always 0, no matter what I do.
I'm trying to communicate 2 Arduinos Uno, the 1 Serial (name of the first Arduino Uno) and 2 Serial (name of the second Arduino Uno). The 2 Serial will send data to 1 Serial, and 1 Serial will receive this data through a Software Serial port, and then re-write the data received to Hardware Serial Port, but I can't read this, and when I try to print what is available is software serial port, always shows 0. I know that I can do the otherwise, but I'm testing this, because in my future project I will need to use this software serial port to read input data, so this is just a test.
The pic of my simulation with the circuit is this:
My code is:
For 1 Serial (the data receiver):
#include <SoftwareSerial.h>

SoftwareSerial portOne (7,8);

String str1;

void setup()
{
  // Start the hardware serial port
  Serial.begin(9600);
  portOne.begin(9600);

}

void loop()
{
  while (portOne.available() == 0)
  {

  }
  str1 = portOne.readString();
  Serial.println(str1);
}

For 2 Serial (the data sender):
String str;

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

}

void loop()
{
  Serial.println("Testing from serial port2");
  delay(2000);
}

I have already read in another topics of this forums and in the internet, but any of them worked for me.
Thanks in advance.
EDIT 1: I'm only simulating both of Arduinos on Proteus, I don't have the hardware with me right now. The image wasn't clear enough, so I hope this one is better to see the wiring diagram. I'm using Virtual Terminal at the Serial Ports so I'm able to see what is being written at the Serial Ports.


texts:
Apologies if I have missed a relevant post somewhere, but have search for days to try figure this out...

I have written some C# code to send a Byte Array over Serial from my PC to an Arduino Nano board (Through a USB to Serial Converter)

Why would I not receive the same HEX Values (in the Arduino serial monitor) as the Values I sent?

(The Values should be the HEX for numbers 0 - 9)

C# Code:

if(!serialPort1.IsOpen)
    {
        serialPort1.BaudRate = 9600;
        serialPort1.DataBits = 8;
        serialPort1.StopBits = System.IO.Ports.StopBits.One;
        serialPort1.Parity = System.IO.Ports.Parity.None;
        serialPort1.PortName = "COM" + cbCOMPort.Text;

        serialPort1.Open();
    }

    byte[] ByteArr = new byte[10];
    ByteArr[0] = 0x30;
    ByteArr[1] = 0x31;
    ByteArr[2] = 0x32;
    ByteArr[3] = 0x33;
    ByteArr[4] = 0x34;
    ByteArr[5] = 0x35;
    ByteArr[6] = 0x36;
    ByteArr[7] = 0x37;
    ByteArr[8] = 0x38;
    ByteArr[9] = 0x39;

    serialPort1.Write(ByteArr, 0, ByteArr.Length);
    serialPort1.Close();

Arduino Code:

void loop()
{
while (Serial.available()) {
delay(250);

byte thisByte = Serial.read();

Serial.print(thisByte,HEX);
Serial.print(" | ");
}
}

Values received in Arduino Serial Monitor:

D6 | B6 | 96 | 76 | 56 | 36 | 16 | F6 | 8D | 0 |

COMPLETE ARDUINO CODE WITH BLINKING LED TEST CODE

void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
}

void loop()
{
while (Serial.available()) {
delay(250);
// get the new byte:
byte thisByte = Serial.read();
// add it to the inputString:
//inputString += char(intChar);

if(thisByte == 0x30 || thisByte == 0x39)
{
digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
delay(50);             // wait for a second
digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
}
Serial.print(thisByte,HEX);
Serial.print(" | ");
}
}


texts:
On the instructions for this motor driver, it says that motors can be put to sleep by "pulling a pin low".

  SLP - Logic Input. When pulled LOW, outputs are disabled and power consumption is minimized.

I'm guess this means connect to ground? How could I trigger that via my Arduino board?


texts: 6 + 1 motors connected to an arduino uno?

texts:
Is it possible to connect 6 dc motors and 2 dc servo motors to an Arduino Uno? I intend to control the Uno with a Raspberry pi connected through USB.

Assuming every motor to be bidirectional, how many L293 or L298 motor driver boards do I need? Is there any other better option than using multiple driver boards?


texts: Updating a sketch to work with IDE 1.6.6

texts:
I've got a MAX7456 chip and I am using this (this is the unmodified one) library with it.
There's a sketch inside the examples folder (Max7456WriteTable) that I need to get to work to update the character table.

I modified three lines and then I got really stuck as I do not know how to continue. This is the modified one.

In file included from Max7456Write.ino:2:0:
/tmp/build4608284042510222737.tmp/sketch/Max7456WriteTable.h:29:69153: warning: narrowing conversion of '243' from 'int' to 'const char' inside { } is ill-formed in C++11 [-Wnarrowing]

This happens for every item in the array. But that is not the only problem. (I'll skip a few hundred lines)

/tmp/build8855411239666100148.tmp/sketch/Max7456Write.cpp.o: In function `setup':
/home/t/Max7456Write.ino:13: undefined reference to `Max7456::Max7456(unsigned char)'
/home/t/Max7456Write.ino:19: undefined reference to `Max7456::activateOSD(bool)'
/home/t/Max7456Write.ino:44: undefined reference to `Max7456::getCARACFromProgMem(char const*, unsigned char, unsigned char*)'
/home/t/Max7456Write.ino:46: undefined reference to `Max7456::sendCharacter(unsigned char const*, unsigned char, unsigned char)'
collect2: error: ld returned 1 exit status
Error compiling.

It takes a huge amount of time for it to abort the compilation.


texts: How to get a hex file for Samd21 from .ino file

texts:
Can you generate a .hex file from an .ino file for the Atsamd21-zero?
I can generate a .bin file but not a .hex file.


texts:
I have an Arduino-like device with few GPIO pins (DigiSpark clone). It is based on an 8-pin AtTiny85 IC so there are Power, Ground and six other pins, two of those six are being used for USB keyboard simulation which leaves 4 GPIO which I want to connect 4 buttons to with minimal circuitry. The normal way to do this is to enable the internal pullups and have the buttons connect the pin to ground. This works well for most pins.

The problem is the equivalent to Pin 13 (Pin 1 in this case) which is connected via a resistor and LED to ground. The internal pullup is too weak to raise the voltage enough. Consequently that pin always appears to be in a "button pressed" state.

One solution is to cut the tracks connecting the LED, but the board is so tiny and crowded that I doubt I have the eyesight and steadiness of hand to do this.

Problematic resistor + LED are at bottom right of AtTiny85 IC

It occurs to me I could either

Add an external pullup to this input,
Change the button wiring so when pressed, it connects the pin to 5v. Change the code to look for high, not low.

Are there any problems with either of these approaches?


texts: Reason for warning "avr:build doesn't define a 'build.board' preference" when build.board is explicitly set in boards.txt?

texts:
I am trying to set up a custom board under the Arduino IDE, but I can not figure out why I am getting the warning...

Warning: Board Move38:avr:build doesn't define a 'build.board' preference. Auto-set to: AVR_BUILD

I think am following the recommendations and template in the official spec here...
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#boardstxt

My "vendor/maintainer" is move38 and my platform is avr, so the path to the boards.txt is...

Arduino\hardware\Move38\avr\boards.txt

Here is my boards.txt that defines the blink board...

blink.name=Blinks Tile
blink.upload.tool=avrdude
blink.upload.protocol=avrisp
blink.upload.maximum_size=15872
blink.upload.maximum_data_size=1024

blink.build.core=blinks
blink.build.board=AVR_Blink

blink.build.mcu=atmega168pb

blink.c.extra_flags=-Wextra -flto
blink.c.elf.extra_flags=-w -flto
blink.cpp.extra_flags=-Wextra -flto
blink.ltoarcmd=avr-gcc-ar

# set F_CPU to 1Mhz for all boards on this platform
build.f_cpu=1000000L

...which would seem to define build.board as AVR_BLINKS.

I think am following the recommendations and template in the official spec here...
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#boardstxt

...but nonetheless the warning persists.

I am using Arduino IDE version 1.8.3 on Windows.

What am I missing here? Is there something special about the value, format, or position of the build.board key that I am missing here?

Thanks!

More notes

Adding the following lines to a working boards.txt file...

build.name=testname
build.f_cpu=4000000L
build.core=blinks
build.board=AVR_BOARD

Will create a menu entry for a new phantom board called testname, but this is not a real board with usable keys. If you compile while that board is selected, you get the warning...

Using board 'build' from platform in folder: C:\Users\passp\Documents\Arduino\hardware\Move38\avr
Using core 'arduino' from platform in folder: C:\Users\passp\Documents\Arduino\hardware\Move38\avr
Warning: Board Move38:avr:build doesn't define a 'build.board' preference. Auto-set to: AVR_BUILD

...despite the fact that the key build.board is explicitly defined.