texts: Why is my SRAM so quickly filled? There are not more than 60 bytes

texts:
I have just gone through all my code. At max I use 60 bytes. I have done everything in order to minimize its usage - I even store booleans as bits, not bytes! What could be happening here?

The only thing that comes to my mind are extremely large arrays, like this:

const uint8_t SBoxes[8][4][16] PROGMEM;

However, these are stored in the program memory as you can see. How can I check they are really there and my memory usage? My code is too large to post it here.

EDIT:

IDE tells me (even though I believe it's very inaccurate):

  Sketch uses 7,898 bytes (24%) of program storage space. Maximum is 32,256 bytes.
  Global variables use 1,023 bytes (49%) of dynamic memory, leaving 1,025 bytes for local variables. Maximum is 2,048 bytes.

All my literal strings use F() and there are not many of them.

EDIT2:

Code on pastebin. Just for a quick glance, it is really large.

EDIT3:

My Serial prints

ready
some numbers (that's ok I ask it to print out an array)
ENready
again numburs
Enready
...

I ask it to print ready at the very beginning of my program. I ask it to println End of encr near the end of my setup funciton, but as you see it never finishes the printing.

It always behaves like that when I run out of SRAM.


texts: Rc switch library transmit using protocol 5

texts:
I'm trying to transmit using mode 5 with the rc switch library, but my reciever tells me that the data is using protocol 2. I'm using the RecieveDemo_simple example as a sniffer for 433 MHz and I'm recieving data with protocol 5 from a wireless electric plug that I want to replicate.

I am able to send the data, but it is using the wrong protocol most of the time.

Here's some output from the reciever:

Received 15766156 / 24bit Protocol: 2
Received 15766156 / 24bit Protocol: 5
Received 15885740 / 24bit Protocol: 2
Received 15885740 / 24bit Protocol: 2
Received 15766156 / 24bit Protocol: 2
Received 15766156 / 24bit Protocol: 2
Received 15766156 / 24bit Protocol: 5
Received 15885740 / 24bit Protocol: 2
Received 15885740 / 24bit Protocol: 2
Received 15885740 / 24bit Protocol: 5

The code:

/*
  Example for different sending methods

  https://github.com/sui77/rc-switch/

*/

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {

  Serial.begin(9600);

  // Transmitter is connected to Arduino Pin #10
  mySwitch.enableTransmit(10);

  // Optional set pulse length.
  // mySwitch.setPulseLength(320);

  // Optional set protocol (default is 1, will work for most outlets)
  mySwitch.setProtocol(5);

  // Optional set number of transmission repetitions.
  // mySwitch.setRepeatTransmit(15);

}

void loop() {

  /* Same switch as above, but using decimal code */
  mySwitch.send(15885740, 24);
  delay(1000);
  mySwitch.send(15766156, 24);
  delay(1000);

}


texts: How to connect dual brushless motors to arduino

texts:
I'm planning on making a Force Feed Back racing wheel with arduino.Saw a lot of tutorials but it uses brushed DC motors ,couldn't find how to connect dual brushless motor for force feed back.

This the motor I want to use :
http://www.dx.com/p/chrgm25bl2418-dc-brushless-motor-with-built-in-drive-24v-12v-470930#.WkurLcvhVAg

.                       .


texts:
I'm really at my wits end. For a couple of hours I have been programming a custom board that uses everything as on the Arduino Leonardo. A few hours ago I am not able to upload anymore.

I get the following error:

   avrdude: error: buffered memory access not supported.
   Maybe it isn't a butterfly/AVR109 but a AVR910 device?

I've tried everything from re-installing the IDE, re-installing the board in Device Manager, changing the COM Port. I really just don't know anymore.

Here is some more data that might be relevant or useful:

     Using Port                     :\\.\COM6
     Using Programmer              : avr109
     Overriding Baud Rate          : 57600
     AVR Part                      : ATmega32U4
     Chip Erase delay              : 9000 us
     PAGEL                         : PD7
     BS2                           : PA0
     RESET disposition             : dedicated
     RETRY pulse                   : SCK
     serial program mode           : yes
     parallel program mode         : yes
     Timeout                       : 200
     StabDelay                     : 100
     CmdexeDelay                   : 25
     SyncLoops                     : 32
     ByteDelay                     : 0
     PollIndex                     : 3
     PollValue                     : 0x53

[EDIT]
I've now checked the battery (yes with a multimeter), it is fully charged, as it charges when the USB is connected. I've also tried a different computer, along with a different USB cable.


texts: Recently I was checking out the Atmel's AVR series and I found the Atmega328PB. I am really familiar with Arduino's environment. So I thought if somehow we could bootloader it with Arduino bootloader. My doubt is how can I make a Arduino bootloader for it.


texts: Not able to receive the operation results from the slave after the command being sent by Master - SPI

texts:
Brief - I am using two arduino Uno's. One acts as a master and the other as slave using Arduino IDE.  Below is the Master Code:

// Taken from Nick Gammon's Forum//

#include "SPI.h"
#include"pin_arduino.h"
int ss = 10;
void setup()
  {
    pinMode(ss,OUTPUT);
    Serial.begin(9600);
    Serial.println();
    digitalWrite(ss,HIGH);
    SPI.begin();
    SPI.setClockDivider(SPI_CLOCK_DIV8);
   }
byte transferAndWait(const byte what)
 {
   byte a = SPI.transfer(what);
   delayMicroseconds(20);
   return a;
 }
void loop()
 {
   byte a,b,c;
   digitalWrite(ss,LOW);
   transferAndWait('a');
a = transferAndWait(17);
b =  transferAndWait(33);
c = transferAndWait(0);
digitalWrite(ss,HIGH);
Serial.println(a,DEC);
Serial.println(b,DEC);
Serial.println(c,DEC);
delay(1000);
 }

Before I go into the details of the results I obtained and the problem, below is the Slave code:

//Taken from Nick Gammon's Forum//

#include "SPI.h"
#include "pins_arduino.h"
int slave = 10;
int miso = 11;
byte c = 0;
void setup()
  {
    pinMode(miso,OUTPUT);
    pinMode(slave,INPUT);
    Serial.begin(9600);
    SPR|= BV_(SPE);
    SPR|= BV_(SPIE);
 }
ISR(SPI_STC_vect)
 {
   c = SPDR;
  switch(c)
    {
      case 0:
      SPDR = 0;
      break;

     case 'a':
     SPDR = c + 15;
     break;
   }
  }
  void loop(void)
   {
     if(digitalRead(slave)==HIGH)
     c = 0;
   }

My Results : After dumping the master and slave codes into their respective arduino uno's, then when I open the serial monitor of the master code, It displays the number 17, 33, 0 and the same goes with the slave, meaning that the data is being sent to the slave and received back successfully, and hence I presume the SPI bus is working properly!. But why isn't the add operation happening?

Problem: Now the problem is, when the command 'a' is sent from the master to the slave, the slave has to interpret this 'a' command as Addition command and perform the addition of a number 15 to the incoming byte from the master as shown in the slave code, and return the results to the master, which should display the addition results in the  masters serial monitor. I am having problem performing this task and looking forward to suggestions on how to test or where I am doing wrong or make changes to the code or methods in order to get this working. I am expecting answers relevant to the below codes and method.


texts: Good way to get automatically generated code into a sketch

texts:
Situation:

Mac OS, Arduino IDE 1.5.6r2

I've got a sketch with several files, all classic .cpp and .h source and header files except the main sketch file. As the project goes more complex I started to generate code automatically by another program. Now I have hard times integrating the generated code it into my sketch. The arduino IDE seems to load the code on opening the sketch. After that, the source files aren't beeing checked for external changes by the IDE (as I would expect it from a real editor like vim). On top of that, when I verify my code the IDE seems to save the files from RAM into a temporary build directory ignoring the contents of the sketch directory further. So if I let my code generator change a source file while the sketch is opened in the IDE, the changes won't reach the build. I had to close the IDE and reopen it. The next thing I tried is to include my autogenerated file from an existing and opened code file inside the IDE. But the IDE ignores files, which aren't opened completely. Hence, the file is missing in the build directory.

Is there a trick to let the IDE take the code unknown to itself along into the build directory? Or how else can I deal with this situation? I don't want to close and open the IDE a hundred times a day.


texts: nrf24l01 fried when supplying 6.5V to VIN?

texts:
I have two Arduino Unos (One clone, one genuine) and I'm trying to make a remote and a base station. Got everything working flawlessly, (Using RF24 library) and the last piece of the wiring was to get the remote Arduino off the USB and powered by battery. I have a 4 AA battery holder which I put 4 brand new alkaline batteries in. Soldered up some connectors, plugged it in and...nothing?

Ran the demos everyone seems to use. Nothing again. Ran the "diagnostic script at the end of that thread...results seemed fine...

CheckConnection Starting

FIRST WITH THE DEFAULT ADDRESSES after power on
  Note that RF24 does NOT reset when Arduino resets - only when power is removed
  If the numbers are mostly 0x00 or 0xff it means that the Arduino is not
     communicating with the nRF24

STATUS       = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1     = 0xe7e7e7e7e7 0xc2c2c2c2c2
RX_ADDR_P2-5     = 0xc3 0xc4 0xc5 0xc6
TX_ADDR      = 0xe7e7e7e7e7
RX_PW_P0-6   = 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA        = 0x3f
EN_RXADDR    = 0x03
RF_CH        = 0x4c
RF_SETUP     = 0x07
CONFIG       = 0x0e
DYNPD/FEATURE    = 0x00 0x00
Data Rate    = 1MBPS
Model        = nRF24L01+
CRC Length   = 16 bits
PA Power     = PA_MAX

AND NOW WITH ADDRESS AAAxR  0x41 41 41 78 52   ON P1
 and 250KBPS data rate

STATUS       = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1     = 0xe7e7e7e7e7 0x4141417852
RX_ADDR_P2-5     = 0xc3 0xc4 0xc5 0xc6
TX_ADDR      = 0xe7e7e7e7e7
RX_PW_P0-6   = 0x00 0x20 0x00 0x00 0x00 0x00
EN_AA        = 0x3f
EN_RXADDR    = 0x03
RF_CH        = 0x4c
RF_SETUP     = 0x27
CONFIG       = 0x0e
DYNPD/FEATURE    = 0x00 0x00
Data Rate    = 250KBPS
Model        = nRF24L01+
CRC Length   = 16 bits
PA Power     = PA_MAX

Ran test on the working arduino, and got a similar result. Checked continuity on all pins twice. Can't think of what could have suddenly gone wrong? Definitely didn't change my code, but just to be sure tried the examples from the above thread...

The only thing I did different was supplying power from VIN at 6.5 V (Measured with multimeter). Should be well within range for the linear voltage regulator? Definitely correct polarity. Hooked in a servo and wrote a quick sketch to drive it then powered the PWM from the battery powered arduino. Other function from my code (rotary encoder, OLED, etc) all seem to be functioning perfectly.

Fried module?

EDIT

I was powering the module through the 3.3V regulated output pin on the Arduino.

Noticed with the battery plugged in whenever I check the voltage with my meter 3.3 pin bounces to 3.7 then settles to 3.3. Not sure if that's the meter, or just the regulator catching up to the (what should be very low with a multimeter) load. Same behavior occurs with USB.


texts: How do I program the Arduino Primo Core using the Arduino Primo?

texts:
the Arduino Primo Core website (https://store.arduino.cc/usa/arduino-primo-core) says that I can program the Arduino Primo Core using an Arduino Primo.

I have no idea how to do this!

Can you do it through the Arduino IDE? Which pins on the Arduino Primo Core should I connect to which pins on the Arduino Primo?

Thanks for your help!


texts:
What should I do to have an Arduino Pro Mini 5V (clone) powered by a 5V solar panel during the day and by battery during night which will be charged during the day by the solar panels.

is there any guide out there?
is it possible with the 5V version of Arduino Pro Mini or will I have to buy the 3.3V
I prefer to make the circuits by myself rather than buying them (for example: the charging circuit.)


texts:
As you may can I see on the picture. I try to display the word "goodbye". Yet the problem is that the cursor positions are to bright. I hooked up a 10k ohm potmeter to the Anode. To change the backlight. Is there a way to make the cursos positions less visible?

Kind Regards,

Q


texts: How to: Connecting 4-pin Joystick to Arduino board

texts:
I am completely new at Arduino. I have a joystick:

It is however quite different from all the other joystick-tutorials, as their joysticks have 5 pins, not just 4. So I am quite at loss here. How do I connect it?


texts: Subscribing to Bluefruit LE Friend with ArduinoBLE not working

texts:
I've been using an Arduino Nano 33 BLE to communicate with my PC over the BlueFruit LE Friend's UART characteristic. Using the default ArduinoBLE library, I'm able to connect to the BlueFruit from the Nano 33 as a central device, and write to the BlueFruit and have it show up in a serial terminal. I can get the Nano 33 to read from the Bluefruit as well, by sending a Characteristic.read() request and a subsequent Charcterisitc.readValue() command. Subscribing to the rx characterisitic on the Nano 33 does NOT work, however, even though the Bluefruit's info page says that the rx characterisitc (address 0x0003) is capable of Notify. I need to be able to subscribe, so that I can use the characteristic.valueUpdated() function to know when new data is available. Here is the relevant code:

if (peripheral.connect()) {
Serial.println("Connected");
} else {
Serial.println("Failed to connect!");
return;
}

// discover peripheral attributes
Serial.println("Discovering attributes ...");
displayNum('A');
if (peripheral.discoverAttributes()) {
  Serial.println("Attributes discovered");
  displayNum(-1);
} else {
  Serial.println("Attribute discovery failed!");
  peripheral.disconnect();
  displayError('A');
  return;
}

// retrieve the TX characteristic
BLECharacteristic txCharacteristic = peripheral.characteristic("6e400002-b5a3-f393-e0a9-e50e24dcca9e");
BLECharacteristic rxCharacteristic = peripheral.characteristic("6e400003-b5a3-f393-e0a9-e50e24dcca9e");

// make sure BlueFruit UART characteristics have been loaded properly are of
// proper format
if (!txCharacteristic) {
  Serial.println("Peripheral does not have TX characteristic!");
  peripheral.disconnect();
  return;
} else if (!txCharacteristic.canWrite()) {
  Serial.println("Peripheral does not have a writable TX characteristic!");
  peripheral.disconnect();
  return;
}
if (!rxCharacteristic) {
  Serial.println("Peripheral does not have RX characteristic!");
  peripheral.disconnect();
  return;
} else if (!rxCharacteristic.canSubscribe()) {
  Serial.println("rxCharacteristic is not subscribable!");
  peripheral.disconnect();
  return;
} else if (!rxCharacteristic.subscribe()) {
  Serial.println("rxCharacteristic subscription failed!");
  peripheral.disconnect();
  return;
}

What's strange is that Characteristic.canSubscribe() method returns true, and it is only when I actually try to subscribe that my error message is triggered. This code is also basically taken directly from the ArduinoBLE SensorTag example, so I'm not sure if this is an issue with the Arduino library or the Bluefruit, so any input would be appreciated.


texts: Detect button press inside a for() cycle

texts:
I was working on a project with an LED strip, where I'd like to cycle through various effects with just a press of a button. The problem is that I don't know how to detect the press of the button to change effect while in for() cycling colors to have a rainbow effect (so it's a multitasking problem, I think).
Could you help me? :)

#include <Adafruit_NeoPixel.h>

#define pin 5
#define led 15
#define button 7
Adafruit_NeoPixel strip = Adafruit_NeoPixel (led,pin,NEO_RGB+NEO_KHZ800);

int doggo=0;

void setup(){
 strip.begin();
 pinMode(button,INPUT);
}
void loop(){

 int buttonVal=digitalRead(button);

 if(buttonVal==HIGH){
  doggo++;
  delay(300);
 }
 if (doggo>2){
  doggo=0;
 }
 while (doggo==0){
  //whole strip red
  for (int i=0;i<led;i++){
   strip.setPixelColor(i,255,0,0);
   strip.show();
  }
 }
 while (doggo==1){
  //rainbow effect
  uint16_t i, j;
  int rainbowSpeed=10;
  for(j=0; j<256*5; j++) {

   for(i=0; i< strip.numPixels(); i++) {

    strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    strip.show();

   }

  }

 delay(rainbowSpeed);

 }

 while (doggo==2){
  //whole strip blue
  for (int i=0;i<led;i++){
   strip.setPixelColor(i,0,0,255);
   strip.show();
  }
 }

}

uint32_t Wheel(byte WheelPos) {
 WheelPos = 255 - WheelPos;

 if(WheelPos < 85) {
  return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
 }
 if(WheelPos < 170) {
  WheelPos -= 85;
   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
 }
 WheelPos -= 170;
 return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}


texts: Advice needed for powering Multiple HX711 with Arduino Mega

texts: I have a project where I need to use multiple load cells (6-8), with individual HX711 for each load cell, which need to be powered simultaneously. I am not sure if I can power all the HX711 with 5V and GND pins of Arduino Mega or I need to use a separate 5V DC power supply and connect the VCC and GND of HX711 pins to it and connect the DT and SCK pins to the digital pins of the Mega. Will such an arrangement work?  Thanks for your time in advance. The link to the HX711 datasheet is here.


texts: Mac won't detect Serial Port for Leonardo

texts:
EDIT: The problem was the cable I was using (see answer below).

I have a MacBook Pro running OS X Yosemite (10.10.1). I connected my Arduino Leonardo to my computer for the first time today (using a Micro USB to USB cable), but my computer isn't detecting it.

When I opened the Arduino IDE I selected Tools > Board > "Arduino Leonardo", but when I try to choose a Serial Port the only options are:

/dev/tty.Bluetooth-Incoming-Port
/dev/cu.Bluetooth-Incoming-Port
/dev/tty.Bluetooth-Modem
/dev/cu.Bluetooth-Modem

I have tried closing and relaunching the Arduino IDE, disconnecting and reconnecting my Arduino Leonardo, and restarting my computer, but I still only see the four Bluetooth ports.

System Information (aka System Profiler) doesn't show anything connected to any of my USB ports.

Thanks in advance!


texts:
I have written the following code for RGB LED:-

const int RED =11;
const int GREEN = 10;
const int BLUE= 9;
void setup() {
  pinMode(RED,OUTPUT);
  pinMode(GREEN,OUTPUT);
  pinMode(BLUE,OUTPUT);
}

void loop() {
  analogWrite(RED,0);
  analogWrite(GREEN,255);
  analogWrite(BLUE,0);
  delay(1000);
}

Now according to my understanding if I run the above code then only  pin named GREEN i.e. 10th pin will give me current not 9, 11th pin. But when I upload the code and run it I see that 9 and 11 pin are giving me current not 10th pin as it is supposed to. Is there a problem in my code? I have checked my circuits are correct. To check current I took jumper wire that was connected to one of my colour and tried inserting it's other end at pins(9, 10 or 11) of Arduino board. If there is current bulb will glow. For above code the bulb was glowing when I inserted the wire at 9 and 11th pin.


texts: Compiling for Wemos D1 mini with Visual Studio Code

texts:
I'm giving Visual Studio Code (VSC) a try and am getting unexpected results. I have a program (sketch) that compiles fine in the Arduino IDE. I create a workspace in VSC, initialize the project, and after some more mucking about I get a compile there appears to succeed:
[Done] Finished verify sketch - RanchMonitor2.ino

But the console pane shows four "problems":

How can the compilation have succeeded if there are problems?
The same sort of thing is happening with one of the samples - HelloServer.ino
In this case the problems are an incomplete type and memcpy_P not defined.
I wouldn't think it should make a difference, but I'm working without a board physically attached to the USB port.
UPDATE:
I think "Problems" are issues identified by Intellisense. They appear even before a compilation is attempted. All I have to do is open the workspace and wait a few seconds, then the "problems" appear. Hence my conjecture they are Intellisense warnings, not compilation errors.
Adding "ESP8266" to the Defines section of c_cpp_properties.json got rid of the error "WiFiManager" is undefined.


texts:
So I'm aware the Arduino Uno can take 6-20 volts, with a recommended voltage of 7-12. But I have an unregulated 12v power adapter, which puts out about 18v with no load.

Most of the time the Arduino won't be doing much of anything but powering a 16x2 LCD, which should take only a couple mA.* I have a 10k ohm resistor on the back light, so it should only take 0.5mA.
*I don't have a datasheet, but from what I've read 1-2mA is reasonable

The Arduino won't be doing anything else that would draw any meaningful amount of current (except looping to check for input, etc). Online sources generally indicate the power draw when not doing anything is a little under 50mA, so I'm guessing that's about what the current draw will be. Using the formula in this answer, I calculate the power dissipation by the voltage regulator to be (18v-5v)*0.05A=0.65 Watts.

Is this correct?
Is the voltage regulator likely to overheat?

I'm not really concerned about power usage, because it will be plugged into the wall all the time. Also, the Arduino will be out of sight, but will have plenty of air around it to disipate heat (though not access to a breeze).


texts: How to attach interrupts to Arduino UNO timers?

texts:
I understand there are 3 timers on the Arduino UNO.  What specific registers do I need to use to access them?

My goal is to use these timers to poll different sensors I am using with a ms period. Are there any pre-made libraries out there to do this?


texts: Proper wiring for a HiLetgo DAC to Arduino

texts:
I have been having trouble finding any recourses for a DAC chip that I bought. It is the HiLetgo PCM5102 DCA.
https://www.amazon.com/gp/product/B07Q9K5MT8/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1
There are 6 ports to be routed. VIN, GND (I know these) LCK, DIN, BCK, SCK, but the rest are a mystery to me. The Adafruit version has tutorials online but I got this one because of the built in 3.5mm jack is what I really needed. Any and all help is greatly appreciated. Let me know if I need to post any other resources.
I am trying to read the audio data coming in from songs through the 3.5mm jack.
Here is the data sheet for the Adafruit version of the DCA with a 3.5mm audio jack
I am asking for help in reading audio data from the input jack.
https://cdn-learn.adafruit.com/downloads/pdf/adafruit-i2s-stereo-decoder-uda1334a.pdf


texts: Trouble operating Servo and GPS at the same time

texts:
I have a problem using a servo and a GPS board at the same time on an Arduino Uno.

For the servo, I use the following code:

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}
void loop() {
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}

For the GPS module, I follow the guidance on this webpage describing the NEO-6M GPS Module

#include <SoftwareSerial.h>

// The serial connection to the GPS module
SoftwareSerial ss(4, 3);

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

void loop(){
  while (ss.available() > 0){
    // get the byte data from the GPS
    byte gpsData = ss.read();
    Serial.write(gpsData);
  }
}

I combine these two code blocks into one *.ino file (combining the declarations, placing all the setup portions in the void setup(){...} function and the rest in the void loop(){...} part).

Here is the problem:
Each block by itself runs fine. The "GPS block" returns GPS messages and the "Servo block" runs smoothly through its position sweep. However, when this code is combined the servo starts to act erratically and "jerks" back and forth.
After some testing, it appears that starting the serial connection (ss.begin(9600);) changes the behavior of the servo control pin (here 9) and it looses its pulse width modulating (PWM) capability. The servo then starts to "jerk" to random positions.

Does anybody have insight into this phenomenon? Is there a way to operate the servo and the GPS module together?

Here is a functional code block that sweeps through the servo positions smoothly, by commenting out the line //ss.begin(GPSBaud); and replicates the erratic behavior by uncommenting the same line ss.begin(GPSBaud);.

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

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  Serial.begin(GPSBaud);
  //ss.begin(GPSBaud);
}

void loop() {
  for (pos = 20; pos <= 160; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 160; pos >= 20; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}


texts: DC-DC converter with Arduino not working

texts:
I've got a program running on the Arduino that is supposed to turn on and off a pump.  currently, I am outputting the reads of the components that need to be read and it shows when the port (port 13) is supposed to turn on and when it's supposed to turn off.  When I use a multimeter between the port 13 and ground, everything works as expected.

When I start the program and the port is off, I get a reading of 0.03v @20v max (to be more precise, I get 14.0 at 200mV) - Shouldn't this be zero? or is there always going to be some electricity flowing?

When the port is turned on: digitalWrite(airPump, HIGH); (and yes, airPump is set to 13), the voltage reads between 4.0 and 4.51 with spikes down to 3.65 on my multimeter set at 20v max.  is it ever stable? (pictured below)

So, the main question is: I'm supposed to be sending the power from port 13 to a DC-DC converter.  I tested the converter on a separate bread board just by itself.  I used a DC power supply and set it to 4.5v, then ran the power through the vIn, grounded the ground pin and ran the vOut to the multimeter (then to ground with the multimeter) and I got it set to output only 2.5v with a constant 4.5 running into it. (pictured below)

I also tested whether or not changing the voltage input would change the output at all and it seems it does not, from 1.5-15v, the converter stays steady at 2.5v

Now when I do the exact same set up on the arduino with the power from port 13 running into the voltage in on the DC-DC converter, it gives me a reading of 0.01v.  Any idea why this is happening?

I've checked probably over 30 times and rearranged everything just as many, but nothing seems to help.  I can't get a stable 2.5V output from the converter with the arduino...

UPDATE: Below is a simple wiring diagram:

The image shows what it is supposed to do, but for testing purposes I made it so if the rH is higher than average (I just breath on it) then the pump will turn on.


texts: How do I transfer more than 1 byte at once via SPI bus?

texts:
I have an AD5685R DAC that I am trying to communicate with over SPI. Per the datasheet,

  ...These [24] bits are transferred to the input register on the 24 falling edges of SCLK and are updated on the rising edge of /SYNC

where /SYNC is used as chip-select.

I believe Arduino's SPI.transfer waits to receive 8 bits after sending 8 bits. But for this particular DAC, I need to send 24 straight bits on 24 clock edges before releasing the chip-select. Is this possible?


texts: How to control speed of 28BYJ-48 stepper motor without using library?

texts: Iam using 28byj-48 stepper motor and I want to know how to control its speed without using any library. I got to know that we need to add delays in between steps but I don't know how much delay I need to add and how delay effects the rpm. It is very much helpful if anyone suggest me how to do this.


texts: Arduino IDE 1.8.13 won't launch properly

texts:
Recently I have been trying to install Arduino IDE 1.8.13, and I have ran into according problem.
When trying to launch Arduino IDE with ./arduino command it shows according error:
./arduino: line 35: /home/wiktor/Downloads/arduino-1.8.13/java/bin/java: No such file or directory

I have checked and java file does indeed exist.
I am using 32 bit version of Arduino IDE and 32 bit version of Linux Alpine 3.13.3.
Thanks for all answers


texts:
I'd like to write a JavaScript function that lights up an led light for X milliseconds depending on the response from the JavaScript function.

function HowManySeconds() {
   setTimeout(HowManySeconds,5000)
   return 1000
}

The JavaScript function will come from a website, so I suppose I would need an Internet enabled device that connects to my router and can 'browse' to my website.

Q: What do I need to buy? A tessel? An Espruino?


texts: How to get rid of low quality sound out from DFPlayer plus amplifier?

texts:
I use my Seeeduino V4, DFPlayer mini, and this speaker module from AliExpress to create an automatic doorbell.  The problem is that it seems that this speaker module's Yurobot amplifier is not powerful enough to create a noise-free loud sound. Also, the bundled speaker is 0.5W, 8 Ohm.
There is a volume selector on the speaker module. If it is selected to a value a bit higher than 0 then the sound's quality is quite high (click here to listen), but the volume is not enough by far for a doorbell, even though the DFPlayer's programmed volume is set to maximum. But if I increase the amplifier's volume selector to something near maximum, I start hearing some very scary noises (please click here to listen).
How can I increase the volume without having hard-to-listen-to noises? Maybe I need to buy another, better amplifier?


texts: Arduino GPS Simulator: SoftwareSerial Issues

texts:
For my project, i need my Arduino Uno to simulate a GPS. To do this, I need to:

Generate a 5V Pulse once a second (no problem)
Send a $GPRMC NMEA sentence with the current time over RS-232 (i've got an RS-232 shield)

The GPRMC message i need to send is the following:

$GPRMC,075832.293,A,4042.695,N,07400.796,W,,,080120,000.0,W*63

Where the first part is the time, and needs to change.
I basically implemented it as:

// Setup
String prefix = "$GPRMC,";
String gprmc  = "075832.293";
String suffix = ",A,4042.695,N,07400.796,W,,,080120,000.0,W*63";
String all = prefix + gprmc + suffix;
char* buff = (char*) malloc(sizeof(char)*all.length()+1);

Then, in the loop-code i update the time and want to send the message:

//...inside the condition that gets executed once a second
gprmc = String(gprmc.toFloat()+1);
all = prefix+gprmc+suffix;
all.toCharArray(buff, all.length()+1);
mySerial.write(buff);

I'm using an RS-232 shield, which shows me when a message is being sent by blinking an LED.
However, is only seems to work, if i shorten the all string, i.e.:
Works:

all = prefix+gprmc;

Does not work:

all = prefix+gprmc+suffix;

Is it possible that the message is just too long to send? Is there a way I can fix this? Because it's crucial to send the whole message.

Note: I'm currently working on an Arduino Uno, but I'm switching to an arduino Leonardo today. I currently have low memory available (77% used). could this add to the problem?

Thank you so much for your help!! :)


texts:
I have a working project built around ATTiny85 on a breadboard running at 5V. Now I want to move this prototype on a PCB where it will be powered from batteries. All components used are capable of running 3.3V so I want to run the ATTiny85 at 3.3V as well.

I don't have a programmer so I use ArduinoISP to program the ATTiny. If I change the fuses on Tiny to run it at 3.3V can I still use the 5V Arduino to program the tiny?

Since the ATTiny can easily run at 5V I don't see any problem with programming it at 5V levels and then run it at 3.3V. Is that correct?


texts:
my first post here.

Anyway I'm working on a Simon Says game.
I have a weird bug with the function that reads button input.

This is the code:

int deBounce(int count){
  int pressed=-1;
  int laastButtons[3]; // save the previous deBounce read.
  for(int x; x<4; x++)
  {
    laastButtons[x] = lastButtons[x];
    lastButtons[x] = !digitalRead(button[x]);
    if(lastButtons[x] == true)
    {
      delay(50);
      lastButtons[x] = !digitalRead(button[x]);
      if(lastButtons[x] == 1){ pressed = x;}
      nt("Pressed!, Button ID: ");nt(x); nt(" pressed:  ");nt(pressed); nt(" state "); ntln(lastButtons[x]);
    }
  }
  if((lastButtons[0] + lastButtons[1] + lastButtons[2] + lastButtons[3]) > 1)
  {
    ntln("ERROR: dont press more than one button at a time. ");
  }
  if( ((lastButtons[0] + lastButtons[1] + lastButtons[2] + lastButtons[3]) == 1 ) && !laastButtons[pressed] && (pressed != -1) ) {
    pressButtons[count] = pressed;
    nt("Pressed!, ID: ");nt(count); nt(" Button ID ");ntln(pressed);
    return count++;
  }else return count;
}

This is what I recieve in the Serial Monitor if I press one of the buttons.

  Pressed!, Button ID: 3 pressed: -1 state 1

How is that possible? Note the lines where that line is printed and the line above it.
Seems like that if should run, but the line pressed = x; doesn't function.
Note that, nt and ntln are just a short for Serial.print.
I have this weird bug and sometimes it seems like the chip is glitching!

Another question is- I tried attaching interrupt and it didn't worked,
Is it possible that my board is not compatiable with them? (It's not original).

Thanks.

EDIT:

After Majenko helped me figure it out,
The thing that created the bug was that I expected a x==0, but I didn't define it in the for loop.

Before:

for(int x; x<4; x++)

After:

for(int x=0; x<4; x++)

Thanks again Majenko!


texts: Relational Database for Arduino on SD card?

texts:
I have been searching for some sort of library that can create, query, and insert data into a SQLite style database from an Arduino to an SD card.

I have looked at the Arduino Extended Database library. But I don’t think it will quite fill this role.

I don’t need all the features of sql. But a simple query system would go a long way.

Does anyone know of a library like this?


texts: How to re-solder the resistor in order to reprogram the Atmega8U2

texts:
As I see here I need to reprogram the ATMEGA8u2: https://www.arduino.cc/en/Hacking/DFUProgramming8U2 I need to solder a 10k resistor into a specific place.

In a previous attempt I did that and resulted the following marks:

So How I can resolder the resistor in order to reprogram the atmega8u2?


texts:
I am currently working on a robotics project that requires 16 PWM outputs to control 16 servos. Is it possible to use Arduino Uno's digital pins as PWM output pins through code?

If it is not possible, what microcontrollers do you suggest to use on such a project?


texts: I can't control my DC motors speed with analogWrite()

texts:
I have Arduino Uno and I attached it to 2 DC motors with L298N bridge.
I want to control the speed of the motors so they don't move at maximum speed.
I use analogWrite() but it does nothing,and the motors move at maximum speed

Here is my code:

//motor A
int enA = 9;
int in1 = 8;
int in2 = 7;

//motor B
int enB = 3;
int in3 = 5;
int in4 = 4;

void setup() {
  Serial.begin(9600);
  pinMode(enA, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
}

void loop() {

  analogWrite(enA, 0);

  analogWrite(enB, 0);

  digitalWrite (in1, HIGH);
  digitalWrite (in3, HIGH);
  digitalWrite (in2, LOW);
  digitalWrite (in4, LOW);

  delay(50);
}


texts: Powering from 3V coin cell to VCC, using I/O pin as supply GND

texts:
I'm thinking of creating a "small" electronic dice.
(I will solder the button a little different though xD)

But there are some concerns on my design:

Powering from a coin-cell

It's a 5V arduino Pro mini, but it should be able to run (per datasheet) on 2.7V to 5.5V, can I just put the 3V of the coin-cell battery on VCC. (I'm aware I'll have to use the internal 8Mhz clock on this voltage though). I won't need the regulator, since the coin-cell will never exceed 5V?

Can I use a I/O as (input/supply) GND?

You can actually use outputs as positive voltage, and you can sink currents.
But does that mean I can connect the negative side of the coin-cell to an output, and sink it?
This way it should power my arduino's VCC pin through the "digital GND"

Using the reset button

I could use the reset button, but would it still give me "random enough" numbers? Since the seed is reset every time?

(I probably won't use it though, it's placed inconveniently for this project, but I am wondering.)

A crude drawing below:

The fun thing is, polarity of the LED's/segments doesn't matter, since I can change which side is high or low? :)
Also, I've only drawn half the LED's/segments. And I know it's better to use a resistor on every pin, but I don't want to make it any more bulky.

(btw, battery GND pin should be pin 4, not pin 2)


texts:
I want to do WiFi GeoChaching box. I'll use cheap ESP01, but problem is it will work in forest 24/7 in cycle of 1 min of work 5 in deep sleep and waiting for those who will find that.
How I can get power?


texts:
I am trying to program an adafruit pygamer (which says it's compatible with Arduino). I have added the ZIP folder for the library into the library folder om my PC where all of my folders are supposed to be stored, one thing I managed to find out for a start was that the library folder for the library itself that was installed from GitHub contained a dash in the filename so I replaced that for an underscore. The actual error message that seems to come up now is this:
'Adafruit_Arcada' does not name a type; did you mean 'Adafruit_SPITFT'?

This error comes up from when I try to use the:
#include "Adafruit_Arcada.h"

Adafruit_Arcada arcada;

lines
Within the library folder that I want to try and use there are the code examples within the library folder inside the examples sub-folder
I have tried following a step by step guide into one potential way of trying to solve this problem by looking at a tutorial by adafruit on how to step by step install zip folder libraries. Something tells me though that this error that I am getting is to do with one of the .h or .cpp files within the library itself.
The link for the library itself is here: https://github.com/adafruit/Adafruit_Arcada
In addition, when I look in the Adafruit_Arcada.h file I can actually see that there is no Adafruit_Arcada class but there is an Adafruit_SPITFT one. I know this point might seem like a bit of a no-brainer but I just thought it would be useful to try and find out what could potentially be going on and provide evidence of what I have already tried to do.
When I changed the Adafruit_Arcada arcada; to Adafruit_SPITFT arcada; (thinking this could potentially resolve the issue because within the Adafruit_Arcada.h file there is a class called Adafruit_SPITFT and notAdafruit_Arcada`), this brought up another error which was the following:
simpletest:2:17: error: no matching function for call to 'Adafruit_SPITFT::Adafruit_SPITFT()'


texts: ESP32-S2 Brownout Detector Randomly Triggered in Deep Sleep

texts:
I have thoroughly searched for answers on this over the past couple weeks, and have not been able to find a solution for Arduino.
I'm using an ESP32-S2-Saola-1M Dev board that needs to store a sensor reading in RTC memory, go to sleep for 5 min, and then wake up again and store another reading. Every few hours, it shares its data and starts over.
The issue I'm having is that about 2/3 of the devices I have will randomly wakeup with a POWERON event instead of from the timer, and all of the RTC memory is lost. From searching online, this seems to be a hardware issue that causes the brownout detector to trigger incorrectly.
The accepted solution in the esp-idf is turning off the brownout detector , but this doesn't seem to be implemented in the ESP32 Arduino core, and using code I've found for turning off the brownout detector in Arduino causes constant brownouts rather than turning the detector off.
There seem to be solutions if I switch my development environment, but I'd rather not do that at this point in development. Has anyone had luck fixing this issue in Arduino?


texts: I would like to shutdown the LED of my GY-85 (gyroscope) component. Is it possible?


texts: Arduino zero Error: unable to find CMSIS-DAP device

texts:
I am uploading a test sketch(Blink) to my new Zero(with Wifi101 shield) and when I press Upload in the IDE, the Console says the following:

Arduino: 1.6.10 (Linux), Board: "Arduino/Genuino Zero (Programming Port)"

Open On-Chip Debugger 0.9.0-gd4b7679 (2014-10-03-00:26)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
debug_level: 0
adapter speed: 500 kHz
adapter_nsrst_delay: 100
cortex_m reset_config sysresetreq
Error: unable to find CMSIS-DAP device
Error: No Valid JTAG Interface Configured.
Error: No Valid JTAG Interface Configured.

I am using the Zero programming port.


texts: How can I use separate power source for the Arduino and the motors

texts:
How can use a separate power source for powering Arduino, and another battery for powering the motors?
How can I make connections through the motor driver module L298N? I know how normally we use one battery to power the Arduino as well as the motors. But I am facing the problem while using different power sources.


texts:
I'm trying to connect my nodeMCU to my WiFi network but it keeps printing ........ which means is not connecting to the network. Here is my code used to connect to WiFi. Any reason why it isn't connecting to WiFi network?.

#include <ESP8266WiFi.h>

        // Replace these with your WiFi network settings
        const char* ssid = "******"; //replace this with your WiFi network name
        const char* password = "******"; //replace this with your WiFi network password

        void setup()
        {
          delay(1000);
          Serial.begin(57600);

          WiFi.begin(ssid, password);

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

          Serial.println("success!");
          Serial.print("IP Address is: ");
          Serial.println(WiFi.localIP());
        }

        void loop() {
        }


texts: What if I detach AVR micro controller from the Arduino Board after uploading program?

texts:
What if I detach AVR microcontroller from the Arduino Board after uploading program? Does the microcontroller still have the program on it? Or the program will be deleted?

On the board where does Arduino store hex file?

I am very beginner in Embedded Programming. I am learning about microcontroller and Arduino. While learning about programming Arduino-Uno I got these question in my mind.


texts: Storing data (strings) if ethernet fails to send it

texts:
Flow goes something like:

Read sensors
Send data
If send fails store the data in eeprom/flash/sd
If sent check if any previous ones have failed and send those

So my question is what's the best storage option to save the data? Is there an easy way to save strings or am I going to have to write it byte by byte?


texts:
I am playing around with this Tinycircuits 16 LED board and I can figure out how to persistently light two LEDs at the same time. The page comes with an example that i can modify but I can only do 1 at a time

How do I light more than one LED at a time?

/*
TinyDuino Edge LED Demo

April 9 2014, by Ben Rose

This example code is in the public domain.

http://www.tiny-circuits.com

*/

void setup()
{
  LedOn(0);//Pass a zero to turn all LEDs off
}

void loop()
{
  for(int i=1;i<16;i++){
    LedOn(i);
    delay(20);
  };
  for(int i=16;i>1;i--){
    LedOn(i);
    delay(20);
  };
}

void LedOn(int ledNum)
{
  for(int i=5;i<10;i++){
    pinMode(i, INPUT);
    digitalWrite(i, LOW);
  };
  if(ledNum<1 || ledNum>16) return;
  char highpin[16]={5,6,5,7,6,7,6,8,5,8,8,7,9,7,9,8};
  char lowpin[16]= {6,5,7,5,7,6,8,6,8,5,7,8,7,9,8,9};
  ledNum--;
  digitalWrite(highpin[ledNum],HIGH);
  digitalWrite(lowpin[ledNum],LOW);
  pinMode(highpin[ledNum],OUTPUT);
  pinMode(lowpin[ledNum],OUTPUT);
}


texts:
So i am trying to make the servo follow my face which will end up my camera following my face
But the servo isnt doing anything please look at this
(Also im only using Horizontal because I would like to start off with that first)
Question : how do i make it so it can move, what am i doing wrong?
Python code : https://pastebin.com/V6SegsQj
Arduino code :
#include<Servo.h>
Servo servoHor; //Horizontal Servo
int x;
int prevX;
void setup()
{
  Serial.begin(9600);
  servoHor.attach(6); //Attach Horizontal Servo to Pin 6
  servoHor.write(90);
}

void Pos()
{
  if(prevX != x)
  {
    int servoX = map(x, 600, 0, 70, 179);
    servoX = min(servoX, 179);
    servoX = max(servoX, 70);
    servoHor.write(servoX);
  }
}

void loop()
{
  if(Serial.available() > 0)
  {
    if(Serial.read() == 'X')
    {
      x = Serial.parseInt();
    }
    while(Serial.available() > 0)
    {
      Serial.read();
    }
  }
}


texts: I can't scroll Arduino IDE's example & scketch lists down

texts: I have Arduino IDE 1.0.5 in win7 x64. I have so many library units. A pity that I can't scroll down to my other options. Is it Arduino.exe's problem or something else? How can I add triangle to scroll down and scroll up to see whole Sketchbook and Examples list? Thanks.


texts: Combining 2 IF statements, getting nowhere and pulling hair out! ;)

texts:
I`m new here so just wanted to say hi!

I have been messing about with Arduino now for about 2 weeks, picking and trying different sketches for a greenhouse project I need.

Trying all sorts with LCD, temperature etc.

But what I actualy wanted was just a simple multiple timer say setting for every hour 9-6 activate for 2 mins to turn on a misting system for my plants, and that is now what I present in the following sketch, simple enough and it works, I have just removed some of the timings to keep the code compact on here.

Now the tricky bit, I want the misting system to come on in those hours chosen, but only if the Humidity is below a certain thresh hold, thats where I`m running into issues.

If anyone can look over the code and advise me where to put "if(h < humLowTrigger){"

I have tried before the times, included it in each line of the times and after the times and still not working.

So all help and knowledge greatly appreciated.

Cheers for now Alan

#include <Wire.h>
#include "RTClib.h"
#include "DHT.h"

#define humLowTrigger 70
#define DHTPIN 7
#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);

RTC_DS1307 rtc;

void setup () {

Serial.begin(9600);
dht.begin();
Wire.begin();
rtc.begin();

pinMode( A2, OUTPUT);
digitalWrite(A2, LOW);
}

void loop () {

float h = dht.readHumidity();
float t = dht.readTemperature();

DateTime now = rtc.now();

if (now.hour() == 15 && now.minute() == 5) {
digitalWrite(A2, HIGH);
}
if (now.hour() == 15 && now.minute() == 8) {
digitalWrite(A2, LOW);
}
if (now.hour() == 15 && now.minute() == 10) {
digitalWrite(A2, HIGH);
}
if (now.hour() == 15 && now.minute() == 12) {
digitalWrite(A2, LOW);
}

Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %");
Serial.println();
Serial.println();
delay(2000);

}


texts: JSON woes: parsing JSON with esp8266, can this be more elegant?

texts:
A few years back I wrote a program that pulled bus time data from the NYC MTA's "bus time" API and posted it on a wifi-connected OLED on my wall. All was well for a few years, but they changed the format and the code broke.

https://www.hackster.io/futurebird/esp8266-lcd-ce41fc

Today I got around to updating the code and the hardware as well. The new version is much sleeker:

But, not one to be easily satisfied I decided I would do the code "right" this time. Last time I pulled the XML file from the MTA and use a string search to find the bits that I needed. The XML looks like this:

<ExpectedArrivalTime>2018T14:13:46.August 12</ExpectedArrivalTime>

So I did this:

while(client.available()){
String line = client.readStringUntil('\n');
delay(60);

//pull and print the "expected arrival times" from XML
//This is just a text search, not fancy.

if ( client.findUntil("ExpectedArrivalTime>","") ) {
client.findUntil("T","");
String nextBus = client.readStringUntil('.');
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Next 2 Bx1 buses:");
lcd.setCursor(0, 1);
lcd.print(nextBus);

client.findUntil("/ExpectedArrivalTime>","");
client.findUntil("ExpectedArrivalTime>","");
client.findUntil("T","");
String nextBus2 = client.readStringUntil('.');
lcd.setCursor(0, 2);
lcd.print(nextBus2);
 delay(3000); }
 }

To isolate the time. It always felt like a kludge. I decided to pull up the JSON verson of the page and do it "correctly" using a JSON parsing library. I loaded up ArduinoJson and soon discovered that I would need code that looks like this to parse the JSON since the MTA's formatting has a lot of extra stuff in it.

DynamicJsonBuffer jsonBuffer(bufferSize);
  JsonObject& root = jsonBuffer.parseObject(http.getString());

JsonObject& Siri_ServiceDelivery = root["Siri"]["ServiceDelivery"];
const char* Siri_ServiceDelivery_ResponseTimestamp =
 Siri_ServiceDelivery["ResponseTimestamp"]; // "2018-08-12T00:09:36.888-04:00"

 JsonObject& Siri_ServiceDelivery_StopMonitoringDelivery0 = Siri_ServiceDelivery["StopMonitoringDelivery"][0];

You get the idea. There are about 20 lines of this and none of them can be removed because the time that I want to display is so deeply nested.

So, I guess I'm just wondering if there is a better way. Both of these methods "work" just fine, but I want this to be elegant.

Is there any way that I could make the JSON file less complex? Am I overlooking a more direct and simple parsing method?

Thanks!


texts:
I want to print text and numbers mixed in a table with Serial.print(); from a char array. My problem is the conversion between the different data types. My idea is to print the data of the rows in a for loop with the variable i and the columns in a for loop with the variable j.

I have in the following example two variable, one is type integer and the second is a double. Now i want to add the values of the variables into the char-array, but I can't find a way to do this...

In my main program the variables need to have this data types and should be inserted later into the char array.

Does someone have a solution for this challenge?

Here is a small example code:

int a = random(0, 100);
double b = random(0, 100);

char* myStrings[][6] = {"This is string 1", "This is string 2", "This is string 3",
                        "This is string 4", "This is string 5", "This is string 6"
                       };

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

void loop() {

  //now put the integer and double variables into the char array in the second column

  //Print the values
  for (int i = 0; i < 2; i++)
  {

    for (int j = 0; j < 6; j++)
    {
      Serial.print(myStrings[i][j]);
      Serial.print("  ");
      delay(100);
    }
    Serial.println();
  }

}

Many thanks in advance.

Guss

EDIT:
The output should look like this:
Headline (in this example it is the text "This is string 1", "This is string 2"...)
and then the values of the variables in the next row. It should be like this:

This is String 1     This is String 2     This is String 3

Variable a           Variable b           Variable int

Variable double      Variable double      Variable int


texts:
I recently moved all in for Linux and have no intentions of going back to Windows, but programming for Arduino is a little annoying as I cannot find a way to have multiple instances.

In Windows you create individual shortcuts for several Arduino IDE instances. When you launch these from the desktop they are autonomous, meaning you can set a board/port combination for each one.

I have yet to find a way to do that in Ubuntu. Is there some form of isolation I can use? I tried using workspaces but they all still see just the one setting.

I do not want to have a bunch of VMs and switch from one to the other unless that is the only option left.

Is there some way I can emulate the Windows autonomous shortcut approach in Ubuntu?


texts: convert 16 bit into array of two 8 bits by use of union

texts:
I want to transmit a 16 bit data through I2C between STM32 and Arduino.
But STM32 HAL command of I2C data is of 8 bits.
Can I please get any suggestions to do that?
Should I use union or just typecast as uint16_t?
I'm thinking to use following code.
union Analogcount
  {
     uint16_t count16;
     uint8_t count8[2];

  }Anacnt;


texts:
I'm working with VirtualWire and I'm trying to get a string value out of the Serial.println in the loop. I've tried create a string and add the message[i] , but surprisingly message[i] becomes an int when added. Serial.println outputs the string correctly, but the string that I get from message[i] is just numbers...

#include <VirtualWire.h>
byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages
byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message
String sensorname;
void setup(){
  Serial.begin(9600);
  Serial.println("Device is ready");
  // Initialize the IO and ISR
  vw_setup(2000); // Bits per sec
  vw_rx_start(); // Start the receiver
  }
void loop(){

  if (vw_get_message(message, &messageLength)){
    Serial.print("Received: ");
    for (int i = 0; i < messageLength; i++){
      Serial.write(message[i]);
      sensorname += message[i];
      }
      Serial.println();
      Serial.pintln("Name of sensor: " + sensorname);
      sensorname="";  //Reestart the string
      }
}

I'm quite new with VirtualWire so I don't know if there is command to get the message and pass it directly to string...Any help will be appreciated!

EDIT
I think I dind't express myself well. In my original question I didn't add the String sensor name

The Response I get in the Serial is the following:

Device is ready
SensorA
Name of sensor: 8310111011511111465

My aim is to instead of having as sensorname=8310111011511111465, have sensorname=SensorA


texts: How do I know how many memory that Arduino is use after my code is running for a few time

texts:
When I upload my program to Arduino it says the memory that the program is used. But what if I use a bad management of dynamic memory, or any object is created several times in use a lot of memory and the Arduino memory overload.

How do I know the current size of memory that Arduino is use?

I am thinking about to create a function in Arduino that return me this information if I send it a request command, but also I don't know how do I inspect the Arduino memory.

Note: I am using the Board: Arduino Mega 2560.

I read the question and the answer for Measure SRAN usage

In the question @fuenfundachtzig ask:

Can I determine how much SRAM I have left in the live system?

In my question I am asking about how do I know or monitoring my program memmory. Ok the Measure SRAN usage answer give me the tips or tools to develop my idea, but the question is not the same.

I am tryin to know in an specific time what is the size of my memmory.

example...

void setup() { //doing some configuration };

void loop() {  // invoke some functions and evil function  };

// in other place a evil function

void evil(){
MyClass * instance = new MyClass();
//play with the instance and it class create other instances....
//and a dynamic memmory is used but not deleted.
}

I am trying to know if it happens and how do I detect with Arduino? I am not talking about how much memmory do I left in the live system.


texts: Communication code between nrf24l01's suddenly not working. Hardware is fine

texts:
I specifically had saved code for the purpose of checking the connection, but it doesn't seem to work anymore.
All the examples from this simple tutorial work, so it can't be a hardware issue.
Maybe someone can find a reason why the code wouldn't work? It returns radio.available() as false
//Transmitter
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8); // CE, CSN
const byte addresses[][6] = {"00001", "00002"};
float valueTransmit;
float valueRecieved;

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(addresses[1]); // 00002
  radio.openReadingPipe(1, addresses[0]); // 00001
  radio.setPALevel(RF24_PA_LOW);
  valueTransmit = 0
}
void loop() {
  radio.stopListening();
  radio.write(&valueTransmit, sizeof(valueTransmit));
  delay(5);

  radio.startListening();
  if (radio.available() ) {
      radio.read( &valueRecieved, sizeof(valueRecieved) );
  Serial.print(valueRecieved);
  valueTransmit = valueRecieved + 0.01;
  }
}

//Reciever
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8); // CE, CSN
const byte addresses[][6] = {"00001", "00002"};
float valueTransmit;
float valueRecieved;

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(addresses[0]); // 00001
  radio.openReadingPipe(1, addresses[1]); // 00002
  radio.setPALevel(RF24_PA_LOW);
}
void loop() {
  radio.startListening();
  if (radio.available() ) {
    radio.read( &valueRecieved, sizeof(valueRecieved) );
    Serial.print(valueRecieved);
    valueTransmit = valueRecieved + 1;
  }

  radio.stopListening();
  radio.write(&valueTransmit, sizeof(valueTransmit));
  delay(5);

}


texts: Interfacing a stepper motor with arduino

texts:
I am having issues with interfacing my stepper motor, connected to a control board being this one

Due to some reason I am not able to move it, unless I remove the enable signal. I can change the direction either unless I manually change by either plug it or unplug it. If codewise change the state of the dir_pin,would the motor keep spinning in the same direction.

The control board need has a timing diagram, specifying when the en, and dir signal should be enabled.

the code I am using to interface it is as below:

stepper_motor.cpp:

#include "stepper_motor.h"

stepper_motor::stepper_motor()
{
  pinMode(BUILTIN_LED,OUTPUT);
  pinMode(step_pin,OUTPUT);
  pinMode(dir_pin,OUTPUT);
  pinMode(en_pin,OUTPUT);

  alive_bool = true;
  position_bool = false;
  step_count = 0;
}

void stepper_motor::alive()
{
  if(alive_bool == true)
  {
    digitalWrite(BUILTIN_LED,HIGH);
    alive_bool = false;
    delay(2000);
  }
  else if(alive_bool == false)
  {
    digitalWrite(BUILTIN_LED,LOW);
    alive_bool = true;
    delay(2000);
  }
}

void stepper_motor::step_pwm()
{

    digitalWrite(en_pin,HIGH);

    delay(0.005);

    digitalWrite(dir_pin,LOW);

    delay(0.005);

    while(1)
    {
      digitalWrite(step_pin,LOW);
      delay(1);
      digitalWrite(step_pin,HIGH);
      delay(1);
    }

}

stepper_motor.h

/* Class: stepper_motor
 * Info: contains the setup, and primary interface to control
 * the stepper motor
 *
 * stepper_motor(): constructor -  setup the connection to the control board
 * void step_pwm():  Moves the tilt - uses the bool to determine the direction.
 * bool alive_bool: Is either high (1) or low (0), used for the alive void.
 */

#ifndef stepper_motor_h
#define stepper_motor_h

#include "Arduino.h"
#include "pins_arduino.h"

#define step_pin  D1
#define dir_pin   D2
#define en_pin    D3
#define max_step  200

 class stepper_motor
{
  public:
    stepper_motor();
    void alive();
    void step_pwm();
  private:
    bool alive_bool;
    bool position_bool;
    int step_count;
};

#endif

main:

#include "stepper_motor.h"

stepper_motor motor;
int state = 0;
void setup() {
  // put your setup code here, to run once:
}

void loop() {

      motor.step_pwm();
}

The motor moves, so the step signal seem to be correct.
But enable and dir seem to incorrect, or are pretty sure that they are.

So what is wrong with those signal? do they not follow the required timing?


texts: 5V 1A vs 5V 5A power supply for 6 LED + Arduino

texts: If I want to power up 6 normal 3mm LED with the appropriate series limiting resistor, do I need the 5V with 1A or 5A power supply? Same goes to the Arduino, if I want to power it externally, do I go for the 1A or 5A?


texts: Uploading my code gets an error : permission denied on Ubuntu 16.04

texts:
I have faced this problem for few years ago and I solved it on Ubuntu 14.04 but I don't know why my solution doesn't work right now on Ubuntu 16.04

The Error :

  avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied

I'm using the same solution from The guide

Here what I've done :

  ls -l /dev/ttyACM*
   from the result : The owner is "root" and the group with access is " dialout
  Then I applied

  sudo usermod -a -G dialout UserName
  sudo chmod a+rw /dev/ttyACM0  Finally logged out and logged in .

After all should be worked but  I still have the same Error , it doesn't work at all , I removed the software and re-installed it didn't work as well


texts: Arduino Adafruit playground: Adafruit_CPlay_LIS3DH.cpp:27:35: fatal error: Adafruit_CPlay_LIS3DH.h: No such file or directory

texts:
I've tried installing the Arduino Adafruit playground but came across the same error.

sketch\src\Libraries\Adafruit_Circuit_Playground\utility\Adafruit_CPlay_LIS3DH.cpp:27:35: fatal error: Adafruit_CPlay_LIS3DH.h: No such file or directory

 #include <Adafruit_CPlay_LIS3DH.h>

                                   ^

compilation terminated.

exit status 1

I don't really know what else I can try. I've tried reinstalling the library and
different versions of the Arduino IDE but is doesn't seem to work.

IDE version: 1.8.7

Playground version: 1.8.1


texts: line following IR sensor not giving readings at 3m wire length?

texts:
I am using line following IR sensor with arduino mega. I need the sensor 2-3m away from arduino since the length of rover is 2m (sensor front & motor back). However, I cannot get accurate analog reading due to voltage drop so that is giving me a problem.

What I tried:-

1) I tried to supply 5.4V to the sensor but had no effect and it might damage the sensor so avoided it.
2) tried to keep the controller close to Arduino and let the wire between controller and BLDC motor be long but didnt work

More info about the project:-
-> Using 2 BLDC motor at the back and caster wheels in front with sensor
-> car length is 2m

What could be the best way to solve this problem?

Note:- if the short wire is the only way then is keeping the motor in front with sensor and caster wheels at back a good idea?


texts: Nodemcu ESP12-E (ESP8266), Can I reprogramming when the UART pins are defined as GPIO?

texts:
I wonder if there may be any problems using the pins that the UART are using as GPIOs, if now I want to be able to reprogram the circuit?
(Of course I will detach the ESP12-E from the mainboard before so)


texts:
I am trying to create a sketch that utilizes two arrays, one array to hold five buttons as input, assigned to pins, and another array to hold five musical notes.  I have attached a RGB LEDs with pull-down resistors and attached a 8 ohms resistor speaker.

The code is as followed:

 //Pentatonic Piano
 // C D E G A

 #define NOTE_C   262 //HZ
 #define NOTE_D   294 //HZ
 #define NOTE_E   330 //HZ
 #define NOTE_G   392 //HZ
 #define NOTE_A   440 //HZ

 const int SPEAKER = 9;   //speaker on pin 10
 const int BLED = 10;      //Blue LED on pin 9
 const int GLED = 6;      //Green LED on pin 6
 const int RLED = 5;      //Red LED on pin 3

 int buttonState = 0;

 //Button Array
 int Buttons[]= {11, 8, 7, 4, 3};

 //Tone Note Array
 int Notes[] = {NOTE_C, NOTE_D, NOTE_E, NOTE_G, NOTE_A};

 void setup()
 {
 pinMode(BLED, OUTPUT);
 pinMode(GLED, OUTPUT);
 pinMode(RLED, OUTPUT);
 pinMode(Buttons, INPUT);
 }

 void loop()
 {

   buttonState = digitalRead(Buttons);

   if (buttonState = Buttons[0])
   { tone(SPEAKER, Notes[0]);
    digitalWrite(BLED, LOW);
    digitalWrite(GLED, LOW);
    digitalWrite(RLED, HIGH);

   }
   else if (buttonState = Buttons[1])
   {tone(SPEAKER, Notes[1]);
    digitalWrite(BLED, LOW);
    digitalWrite(GLED, HIGH);
    digitalWrite(RLED, LOW);
   }
   else if (buttonState = Buttons[2])
   {tone(SPEAKER, Notes[2]);
    digitalWrite(BLED, HIGH);
    digitalWrite(GLED, LOW);
    digitalWrite(RLED, LOW);

   }
   else if (buttonState = Buttons[3])
   {tone(SPEAKER, Notes[3]);
    analogWrite(BLED, 127);
    analogWrite(GLED, 0);
    analogWrite(RLED, 127);

   }
   else if (buttonState = Buttons[4])
   {tone(SPEAKER, Notes[4]);
    analogWrite(BLED, 0);
    analogWrite(GLED, 127);
    analogWrite(RLED, 127);

   }

   else
   {
    digitalWrite(BLED, LOW);
    digitalWrite(GLED, LOW);
    digitalWrite(RLED, LOW);
    noTone(SPEAKER);
   }
 }

The problem is no matter what button I press, the RGB only emits a green light and there is absolutely no sound coming from the speaker.  I am truly stumped.


texts: Problem receiving CAN messages using arduino, MCP2515 CAN module and multiprotocol radio shield

texts:
I am using an arduino UNO and a Cooking Hacks CAN BUS module through a Cooking Hacks Multiprotocol radio shield. I plan to read the CAN messages through the car's OBD-II port. I have connected the components according to the tutorial and though there is no LED to indicate that the shield and CAN bus module are ON, I verified that they are indeed ON by using a multimeter. Also, when the reset button is pressed on either the shield or the CAN module, the arduino resets so I guess they are powered up. Coming to my problem, I uploaded the code and connected the setup to the OBD-II port and turned the ignition ON. I expected to see the CAN messages on the arduino serial monitor but I didn't see anything. I also took up this issue with the cooking hacks support team who told me that the libraries were updated and that I should use the updated ones. So I downloaded the revised libraries to use with my code but I am unable to upload the code itself to the arduino because of an error during compilation.
C:\Users\user\Documents\Arduino\libraries\arduinoCANBUS\arduinoCAN.cpp:26:49: fatal error: ../arduino-api/arduinoMultiprotocol.h: No such file or directory
The major difference as far as I can tell between the old and the new libraries is the addition of two lines in the arduinocan.cpp file :
include "../arduino-api/arduinoMultiprotocol.h"
include "../arduino-api/arduinoUtils.h"
Both of these are header files in another library that was included as part of the whole library that you can download from their website.
I realise I might have confused whoever's reading but please have a look at the arduino code. Hopefully, that should clear things up. Any help would be highly appreciated. Thanks.
Code:
    #include <arduinoCAN.h>
    #include <arduinoClasses.h>
    #include <arduinoMultiprotocol.h>
    #include <arduinoUART.h>
    #include <arduinoUtils.h>
    #include <Wire.h>
    #include <SPI.h>

    // Create an instance of the object
    CAN myCAN = CAN();

    // Setting up our devices and I/Os
    void setup() {
    // Using the Socket 0 onto which Can bus module is plugged in
    Utils.setONSocket0();
    Utils.setMUXSocket0();
    // Initializes the UART
    Serial.begin(115200);
    delay(100);

    myCAN.begin(500); // Start talking to the BUS. Speed= 500 Kbps
    }

    void loop() {
    // 1. Receive data

    if (myCAN.messageAvailable()) {
    // Read the last message received.
    myCAN.getMessage(&myCAN.messageRx);
    // Print in the serial monitor the received message
    myCAN.printMessage(&myCAN.messageRx);
     }
    }

EDIT: PROBLEM SOLVED!
Putting the header file's full path in the sketch did not solve it. The compiler still displayed the same error. I then made a backup copy of all the files containing the #include "arduinoMultiprotocol.h" statement and edited them to contain the full path. Initially, the error didn't change and I moved onto the next suggestions, all of which did not change the error. However, I went back to the edited files and replaced the backslash() with the slash(/). This time, the compiler did not throw the same error, instead saying it cannot find arduinoUtils.h.
So I proceeded to do the same thing with arduinoUtils.h, editing all the files containing it to mention the full path. And this time it worked and the sketch works as well. Thanks for your help!


texts: How to write a library that support both HW and SW Serial communication and allow user to chose which one to use?

texts:
I'm working on a library for Arduino/ESP8266/Teensy that use serial to send AT commands. I want to make it as customizable as possible, so I avoided to hardcode the serial and I ask for a reference in the startup method:

void MyClass::init(HardwareSerial* hwSerialPtr)
{
   _serialPtr = hwSerialPtr;
   ...
}

On some devices, it will be useful to use SoftwareSerial instead of the HW one, due to only one serial is available and so keep it for debugging purposes or other features.

So my question is: how can I accept both types? I read both HW and SW serial have Stream as base-clase, but it does not have methods like begin() etc.

A possible solution I though is so have two pointers (one for HWSerial and one for SWSerial) then wrap some methods like begin(), println(), ... in my class and, ond the base of which pointer has been set, use one or the other.

Something like this:

class MyClass{
   public:
      void init(HardwareSerial* hwSerialPtr);
      void init(SoftwareSerial* swSerialPtr);

   private:
      HardwareSerial* _hwSerialPtr;
      SoftwareSerial* _swSerialPtr;

      void begin(long baud);
      void println(const String &s)
};

then

void MyClass::begin(long baud)
{
   if( _hwSerialPtr != null ){ _hwSerialPtr->begin(baudrate); }
   else if( _swSerialPtr != null ){ _swSerialPtr->begin(baudrate); }
}

...etc...

but this solution seems to me very tricky and not optimized.

Any better ideas?


texts:
Using Servo.h it is possible to run a servo from just about any pin.....obviously the more pins the more servos...hence the question
" how can I do this with a MCP23017 ? ".
I have searched the web a fair bit but no luck.
Is there a modified Servo library out there??
It's such an obvious solution i figure it must have been done before.
Any suggestions..Thanks.


texts:
I'm trying to use the watchdog timer to prevent the atmel from being stuck in a loop.

Right now, I have the watchdog timer in System Reset Mode, with a 8sec timer. I reset the timer in every loop while the system is active. But when it goes to sleep, it cannot clear the timer and the whole system resets. Essentially, the system sleeps > System Reset every 8 sec > goes back to sleep.

While this works, I initialize a lot of other hardware with the atmel, and doing it every 8 second seems like a waste of resources.

I want to use the watchdog interrupt somehow only to wake the system up briefly and stop the full system reset. Only if it's truly stuck, it will do a full system reboot. But i'm not sure how the ISR will work or how to reset the timer or toggle.

Here a basic rundown of what I was thinking about.

ISR(wdt_timer)
{
    how to stop the full system reboot?
    how to make the interrupt start again?
}
ISR(button_press)
{
      gotoSleep=0;
}

void watchdog_init()
{
    /* Reset the wdt. */
  wdt_reset(); //from wdt.h

  /* In order to change WDE or the prescaler, we need to
   * set WDCE (This will allow updates for 4 clock cycles).
   */
  WDTCSR |= (1<<WDCE) | (1<<WDE);

  /* set new watchdog timeout prescaler value */
  WDTCSR = 1<<WDP0 | 1<<WDP3; /* 8.0 seconds */

  /* Enable the WD interrupt (note both interrupt and reset). */
  WDTCSR |= (1<<WDIE) | (1<<WDE);
}

void main ()
{
    watchdog_init();
    //and initialize all the other hardware and power supply

    while (true) //no need to step out of this loop
    {
        reset_watchdog();

        //
        //main program
        //

        if(go_to_sleep=1)  //command received through serial
        gotoSleep();

        //wake up here

    }

}


texts: How do I remotely acquire data from Arduino based portable device?

texts:
I am making a device which will have an Arduino board and a sensor attached to it. The sensor will acquire data every 10 minutes and the data will be uploaded to my server. The size of every upload is about 200 characters. I'd like this device to work anywhere in my city (US).

What are my options for uploading data to my server? Keep in mind that it will work without human intervention. FYI... this is NOT for reconnaissance device! ;)


texts: Serial1 is not reading the Xbee on a Arduino Due

texts:
I am trying to test simple communication between a Xbee on my Arduino Due and a Xbee linked to XTCU. I attached jumper wires from RX and TX to RX1 and TX1 (Serial 1 hardware port) but I cannot send or receive data between the Xbees. I tested the Xbees previously with an Arduino Zero talking to the XTCU and it worked flawlessly.

Extra information: I am using a Xbee Shield on my Arduino Due (as shown in the picture)

char c,d;

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

}

void loop()
{
// put your main code here, to run repeatedly:
if (Serial1.available())
{
 c = Serial1.read();
 Serial.print(c);
}
else if (Serial.available())
{
 d = Serial.read();
 Serial1.print(d);
}

}

My wiring is attached. What am I doing wrong?


texts: Arduino not working on cell phone power bank

texts:
I'm trying to power my Arduino Uno using a basic power bank (5V/2.1A Output), the Uno lights up for around 20 secs. and then stops taking power from the bank. What can be the issue? Am I making a huge mistake here?
Further details:
1. The power bank has a LED that lights up during the charging process, it doesn't light up when I connect jt to Arduino though (but powers the Arduino for a short span, after which the Arduino goes off)
2. The power bank is 10,000 mAh, 5V/2.1 Amps, charges my cell phone normally.

Edit: As requested, adding a photo of the whole setup.


texts: Constructing my own serial command syntax to control arduino

texts:
I know this is a basic question, but as a hardware electronics guy and not a programmer I cannot seem to fathom how to do this - so any examples of code would be greatly appreciated:

I want the arduino to spit out some initialization chatter on startup - (ok, done easy).

Then I want it to listen for serial commands, they can all be same length if that helps but I want them to be strings. i.e. identifier followed by value

Command --- Result

PWR_TRUE --- Power on device

PWR_FLSE --- Power off device

REP_FREQ --- Print frequency over serial

SP000752 --- Set power value to 752

SP016675 --- Set power value to 16675

Obviously the commands are two types, the first two being booleans and then integers, but I cant seem to find any examples not working off a single ascii character value, which is useless to me. I need more information and then from the message be able to break it down into something the arduino does.

An example of how to import whole commands and either do something, and / or chop the command up to get the value out, would be most useful.

Many thanks in advance :)

EDIT/UPDATE:
I now seem to have found a solution thanks to Edgar as given in the comments. However I now have another question relating to updating the variables so as to effect the loop, as well as performing actions upon receipt of commands (which itself now works)
LINK HERE


texts: Bluetooth connection to HC-05 paired but not connected (in Linux)

texts:
I have an Arduino Uno connected to an HC-05 Bluetooth sender/receiver chip. I am trying to create a Bluetooth connection between my Acer laptop running under Ubuntu 14.04 LTS and the HC-05 chip.

Ubuntu detects the HC-05 chip, as can be seen below.

phodor@ubuntu: hcitool scan
Scanning ...
    11:22:33:44:55:66   HC-05

I am able to create a pair between my laptop Bluetooth device and the HC-05 chip. However, I am unable to create a connection with that pair from the Ubuntu interface. The "Connection" button cannot be clicked on, as you can see on the figure below.

I tried creating a connection using the terminal, but after that the terminal still did not detect any connection.

phodor@ubuntu: sudo hcitool cc 11:22:33:44:55:66
[sudo] password for phodor:
phodor@ubuntu: hcitool con
Connections:

I also checked that my computer Bluetooth device was working.

phodor@ubuntu: hcitool dev
Devices:
    hci0    AA:BB:CC:DD:EE:FF

Any idea why the connection cannot be created ? Any idea on how to do it using the Ubuntu interface or the terminal ?


texts: Making Servo Motor Automatically Move Based on Input

texts:
sorry if I sound incompetent, but I know nothing about coding. I have a group project where I must sort various balls into different tracks. The final issue I have is that I must use an arduino for this portion. However, none of us know how to program, and the only experience we have is from doing the lessons from adafruit (copy and paste written code).

What I am attempting to do is attach a paddle to the tip of a high torque servo motor. I will then automatically feed the servo signals, ranging from 0 to 5. Each signal tells which position for the servo to turn to. Could anyone please help guide me in how to write this code? I was thinking of using
this guide for my motor. However it uses a POT. My project must be completely automated. The positons also are all within 180*.

Thank you!


texts: Remote Arduinos polling a master Ardrino over ethernet/wifi

texts: I'm setting up a "Panic Button" for our Front Office. The concept is to have a master Arduino with the button and 4 other Arduinos with Strobes and/or alarms to alert the rest of the staff. The bells and whistles are fairly straight forward. My only block is how to have the remote Arduinos poll the master and receice a simple on/off value over the existing ethernet/wifi network (necessary because we are physically 2 different buildings so bluetooth or standard serial communicaitons would be prohibitive). Master will be hardwired to ethernet while the remotes will need to be wifi. Any and all suggestions would be greatly appreciated.


texts: Is it possible to measure the velocity of a Unmanned Aerial Vehicle using only accelerometer?

texts: Our project is about dropping a payload from a UAV on the specified area. We are using an accelerometer (connected to the Arduino board) to measure the velocity of the plane (assuming the initial velocity to be zero). Is it possible to accurately measure the velocity of a plane moving in the air for a time t? Will this method be feasible?


texts:
I want to know if there is a way to install/use the PBC library on Arduino UNO. I want to implement some cryptographic primitives using PBC library.

Thank you.


texts:
I'm trying to get a strip of Neopixels to circle through its length, one LED at a time, I want it to do it faster as the value received from the sensor increases

#include <FastLED.h>
#define NUM_LEDS    34
#define DATA_PIN    6
#define SENSOR_PIN  A0

int airPressure,
    barometricToRGB,
    frequency       = 0,
    high            = 0,
    low             = 600,
    interval        = 50;

long previousMillis = 0;

CRGB leds[NUM_LEDS];

void setup() {
  Serial.begin(115200);
  pinMode(SENSOR_PIN,INPUT);
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}

void loop() {
  airPressure = analogRead(SENSOR_PIN);
  autoTune();

  unsigned long currentMillis = millis();
  Serial.print("frequency ");
  Serial.println(frequency);
  Serial.print("Time to beat ");
  Serial.println(frequency*interval);
  Serial.print("Last Called ");
  Serial.println(currentMillis - previousMillis);

  if(currentMillis - previousMillis > (frequency/interval)) {
    previousMillis = currentMillis;

    for (int i=0; i<NUM_LEDS; i++) {
          leds[i].setRGB( barometricToRGB, 68, 255/barometricToRGB);
          FastLED.show();
        }
  }
}

void autoTune() {
  if (airPressure < low) {
    low = airPressure;
  }
  if (airPressure > high) {
    high = airPressure;
  }
  barometricToRGB = map(airPressure, low, high, 1, 255);
  barometricToRGB = constrain(barometricToRGB, 1, 255);
  frequency = map(airPressure, low, high, 1, 100);
  frequency = constrain(frequency, 1, 100);

}

While I had managed to cause the color to change based on the sensor, I can't seem to understand how to control how fast it will go, every how long.


texts: Using an ATTiny85 and DigiKeyboard.h, can I detect when USB HID is connected?

texts:
I am building a project to send HID keystrokes to a computer with an ATTiny85. I want to detect when the USB communication is working, in order to turn on a LED saying that everything is good. If USB stops working, I want a watchdog to turn the LED off. Ideally it would also attempt to reconnect automatically.
DigiUSB has the DigiUSB.available() method, but DigiKeyboard does not, and I can't seem to use both headers in the same program because of conflicts. How can I do this without DigiUSB?


texts:
I work with a marching band, and we want to use fog machines for a particular part of the show. I know how to code/program in Arduino, however I am not great in the electrical and technical end. I own two fog machines, and the issue is that we need them to start fogging on command without delay (at least not a long delay, just not early and not late). We cannot exactly stop the show in the middle of a competition to say "wait, the fog is coming soon." We also need them to stop fogging on command.

I have read this article, Motion Triggered Fog Machine and it seems simple enough, however, I do not need or want it to work with a motion sensor. I suppose the easiest way you could help me is to either point me to a tutorial or tell me how to modify that tutorial to my own needs.


texts: NodeMCU (Arduino IDE) 'DynamicJsonBuffer' was not declared in this scope

texts:
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ArduinoJson.h>
#include <ESP8266HTTPClient.h>
#define USE_SERIAL Serial

ESP8266WiFiMulti WiFiMulti;
String url = "http://192.168.31.170/api/mode/qwertyui";

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

  USE_SERIAL.println();
  USE_SERIAL.println();
  USE_SERIAL.println();

  for (uint8_t t = 4; t > 0; t--) {
    USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
    USE_SERIAL.flush();
    delay(1000);
  }

  WiFi.mode(WIFI_STA);
  WiFiMulti.addAP("Robotics Incubator", "XXXXXXX");
}

void loop() {
  // wait for WiFi connection
  if ((WiFiMulti.run() == WL_CONNECTED)) {
    HTTPClient http;
    http.begin(url); //HTTP
    int httpCode = http.GET();

    if (httpCode == 200) {
      // Parsing
      const size_t bufferSize = JSON_OBJECT_SIZE(1) + 50;
      DynamicJsonBuffer jsonBuffer(bufferSize);  //This was not declared error.
      JsonObject& root = jsonBuffer.parseObject(http.getString());
      // Parameters
      int Mode = root["mode"]; // 1
      Serial.print("Name:");
      Serial.println(Mode);
    }
    http.end();
  }

  if (Serial.available()) {
    url = Serial.readString();
  }
  delay(100);
}

How can I solve this problem?
I followed this tutorial - ESP8266: Parsing JSON


texts:
I Have 2panstamp. I can program the first but not the second with the arduino program.

When I upload the sketch (a simple blink) on the second, I got this

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x004e22
avrdude: Expected signature for ATmega328P is 1E 95 0F
Double check chip, or use -F to override this check.

avrdude done.  Thank you.

And if I retry, I got this.

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x81f014
avrdude: Expected signature for ATmega328P is 1E 95 0F
Double check chip, or use -F to override this check.

avrdude done.  Thank you.

The device signature is not the same anymore ...
I've changed the wire and re-open arduino program. But it don't change, the device signature change (often 0xE1E1E1). I've check the connection between the ATmega and the wire and everything is ok.

Is the Panstamp broken ? or should I do a kind of factory reset?


texts: Pulling the enable pin on Adafruit PowerBoost to low (It's connected to VBatt!)

texts:
I am working on an Tonuino (tonuino.voss.earth), and I am using a PowerBoost-module from Adafruit (https://www.adafruit.com/product/1944) for it. The powerboost-module needs the enable pin driven to LOW(GND) to turn the output 5V off. Currently I have a rocker switch which allows me to permananently connect EN to GND.

I would like to implement a auto-off functionality for this combination, i.e. the arduino can drive the enable pin LOW and in this manner kill its own power. In addition to the auto-off, I want the user to be able to turn on the device via a button press. I come from a software background and my last connection to electronics is from a time long, long ago, which is why I am struggeling.

This shows my initial thoughts:

The user presses the button to start the Tonuino. The switch disconnects EN from GND, EN goes to UBATT(HIGH) and 5V to the arduino is enabled. By enabling the arduino, a GPIO is set to high and thus EN is maintained high
To turn off, the arduino sets the GPIO to LOW, thus setting EN to LOW, 5V are disabled and so forth...

My problem: 5V from the Arduino GPIO will always be at 5V and thus higher than the reference voltage of EN (UBATT 3V - 3.7V). I really am afraid that this will damage my lipo. For me this means, I ideally should switch UBATT for EN (safely) and am failing to come up with a solution.

Any pointers are greatly welcome


texts:
I recently read this piece of code and I dont know what is the use of "<<=" in the for loop:

for (mask = 0x01; mask>0; mask <<= 1) {
    if (data & mask){ // choose bit

This is the entire code:

//Created August 23 2006
//Heather Dewey-Hagborg
//http://www.arduino.cc

#include <ctype.h>

#define bit9600Delay 100
#define halfBit9600Delay 500
#define bit4800Delay 188
#define halfBit4800Delay 94

byte rx = 6;
byte tx = 7;
byte SWval;

void setup() {
  pinMode(rx,INPUT);
  pinMode(tx,OUTPUT);
  digitalWrite(tx,HIGH);
  delay(2);
  digitalWrite(13,HIGH); //turn on debugging LED
  SWprint('h');  //debugging hello
  SWprint('i');
  SWprint(10); //carriage return
}

void SWprint(int data)
{
  byte mask;
  //startbit
  digitalWrite(tx,LOW);
  delayMicroseconds(bit9600Delay);
  for (mask = 0x01; mask>0; mask <<= 1) {
    if (data & mask){ // choose bit
     digitalWrite(tx,HIGH); // send 1
    }
    else{
     digitalWrite(tx,LOW); // send 0
    }
    delayMicroseconds(bit9600Delay);
  }
  //stop bit
  digitalWrite(tx, HIGH);
  delayMicroseconds(bit9600Delay);
}

int SWread()
{
  byte val = 0;
  while (digitalRead(rx));
  //wait for start bit
  if (digitalRead(rx) == LOW) {
    delayMicroseconds(halfBit9600Delay);
    for (int offset = 0; offset < 8; offset++) {
     delayMicroseconds(bit9600Delay);
     val |= digitalRead(rx) << offset;
    }
    //wait for stop bit + extra
    delayMicroseconds(bit9600Delay);
    delayMicroseconds(bit9600Delay);
    return val;
  }
}

void loop()
{
    SWval = SWread();
    SWprint(toupper(SWval));
}


texts:
I bought the CAN-Shield from Sparkfun https://www.sparkfun.com/products/13262 and I also got the Uno from Sparkfun just to be sure everything works fine.

Some info about my car:

BMW E91 2006
OBD2 is available
KWP 2000 and other lines are available
like the ones with the same baud rates from the demo

I tried the SparkFun_CAN_Demo which is available on their website and GitHub.

My output is that
CAN init is successful but I don´t know if that´s true...
If I try to read the RPM, for example, I get a buffer with a size of 1 -> " ".

My questions are:

Did I something wrong with the MCP2515 how do I know if it´s dead?
Does anybody know if the demo is working properly or not?
What´s the right way to get data from an BMW with OBD2?


texts: What are the implications of running an ATmega328P at 8 MHz and 3.3 V with the Arduino system?

texts:
I'm working on a custom arduino that will run at 3.3 V with no regulators or USB chips (for power consumption).  I've heard that overclocking the chip at 16 MHz/3.3 V is generally fine, but I'd like to stay within spec anyway.

First: to run at 8 MHz, do I just need to replace the crystal?  Or is there anything else I have to do?

Second: Do I need to make any code changes to reflect the new speed?  I'm using serial, SPI, and I2C connections in this project, along with the NilRTOS operating system and millis/delay functions.  Will any of these be broken?  Will the code run noticeably slower?

Third: How can I program the chip?  Is it ok to program it in an Arduino Uno at 16 MHz, then transplant it to the custom arduino?

Fourth: Will power consumption change at 8 MHz?

Thanks!


texts:
Before bothering anybody, I've been Googling this issue for the last three weeks and have not been able to solve the issue, so must reach out for help.

My son has done multiple Arduino projects after having a Creation Crate subscription, and now we're working on a project together.  We bought a 28BYJ-48 stepper with driver, and figured it'd be just a question of copy-and-paste coding and we'd be in business.

I've tried the Arduino library, the AccelStepper library, countless other sketches from various websites and for some reason the stepper only vibrates when it's supposed to turn CCW.  There was one sketch we were using that used Serial Monitor to enter in the number of steps, and when i'd do a minus number of steps, it'd go CCW, but the next day no longer would!  I thought this was a motor or driver issue, but we've bought three more motor/drivers and still have the same problem.  In researching an answer, I've seen some people say to switch IN 3 & 4 but I still get same results.

We've been connecting 8 to IN1, 9 to IN2, 10 to IN3 and 11 to IN4.  Using a separate 5V power supply to the driver which is also grounded to the Arduino (have tried both ground pins just in case that makes a difference, but no).  We've also tried changing for another Arduino and this hasn't made a difference either.

we've tried multiple sketches from multiple sources, here's one as an example:

#include <Stepper.h>

const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

void setup() {
  // set the speed at 60 rpm:
  myStepper.setSpeed(60);
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
  // step one revolution  in one direction:
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(500);

  // step one revolution in the other direction:
  Serial.println("counterclockwise");
  myStepper.step(-stepsPerRevolution);
  delay(500);
}

The Serial Monitor will state that it's turning CCW, but it isn't.  Any help would be much appreciated!  What we thought would be a simple step in our project has become a major roadblock!


texts: CH34x board fails with avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00 Atemel Mega328P AU1640

texts:
I have been given a board(Atmel ATmega328P-AU 1640) to program. I googled and found category of board Arduino Uno/ CH34x-based clone.

But when I program an empty program:

void setup() {
  // put your setup code here, to run once:

}

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

}

I get this error:

Sketch uses 444 bytes (1%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

These are all the ports that are available to me. I have connected my Arduino with one of the USB ports on my Macbook running MacOS Sierra


texts: I have an atmega328p (running on it's internal 8mhz clock) receiving data over rf. I need the data received to be communicated to the raspberry pi 2 using its gpio pins, I cannot use USB. I don't have the budget for a gertduino. Is there any way to do this directly? I only need to be able to receive serial output on the pi, no uploading sketches.


texts: RFID reader code to identify more than one tag

texts:
I'm new to using Arduino and I have managed a few changes to this sketch. But I want to check for a second tag if the first one is not correct. I just can't seem to get it to work. I think it would be good if the tag is not a match to ask it to check the next tag and carry on, but I'm not sure how to make this happen.

//RFID Password Typer
//If a matching tag is found, the keyboard types
//CTRL-ALT-DEL, then types the password and presses enter
//Which should log you on to a Windows computer
//Or Lock the computer if you're already logged in

#include <SPI.h>
#include <MFRC522.h>
#include "Keyboard.h"
#include <Mouse.h>

#define RST_PIN 9
#define SS_PIN 10

byte tag[10]={0x64,0xAE,0xDD,0xFC,};
char pswd[]="********\n";      //password, end with just \n
MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance

void setup() {
  SPI.begin();              //start SPI
  mfrc522.PCD_Init();       //start RC522 module
  Keyboard.begin();         //start USB keyboard
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);     //LED off
}

void loop() {
  if (!mfrc522.PICC_IsNewCardPresent()){ return; }
  if (!mfrc522.PICC_ReadCardSerial()){ return; }
  for(byte i = 0; i < mfrc522.uid.size; i++) {
    if(mfrc522.uid.uidByte[i]!=tag[i]){ return; }
  }
  mfrc522.PICC_HaltA(); //stop tag so we don't get repeats
  digitalWrite(13, HIGH); //LED on so we know we've got tag match
  Mouse.click();
  delay(1000);
  Keyboard.press(KEY_LEFT_CTRL);
  delay(1000);
  Keyboard.releaseAll();
  Keyboard.press(KEY_LEFT_CTRL);
  Keyboard.press(KEY_LEFT_ALT);
  Keyboard.press(KEY_DELETE);
  delay(100);
  Keyboard.releaseAll();
  delay(300);
  Keyboard.print(pswd);
  delay(100);
  digitalWrite(13, LOW); //LED off
}


texts: Is it right to connect Serial module directly?

texts:
I find a strange thing that the led is on when power is off. And it's the problem of my serial module. Arduino may get power from my serial module. My serial module use max2322. I don't if it will harm my arduino or has influence to my program.
Is it needed to add a resistance?


texts: The basic Arduino IDE lacks a lot of the sophistication present in other IDEs such as code completion, code collapsing, folder organisation, etc. Are there other IDEs that allow programming in C or C++ and improve on these aspects?


texts: How to slow ADC clock speed to 1MHz on Arduino Due?

texts:
I know that the ADC on the Arduino Due has a clock speed from 1 MHz to 20 MHz. I have two questions: 1. What is the default clock speed when I run a sketch, and 2. How can I change it? (I am using Arduino 1.6.4.)

The reason why I want to slow down the ADC as much as possible is to obtain the maximum source impedance. Is this logic correct? (i.e., if I slow down the ADC in the arduino code to kHz values, then the source impedance will reach MΩ values?)


texts:
I'm pretty new to Arduino programming and i'm trying to connect this ESP8266 module to my FTDI programmer but constantly getting this error on my ARDUINO IDE:  esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header.
My guess is that its not in flashing mode and that i have to connect GPIO0 to ground or sompthing else.


texts: How to use parameteric function arguments

texts:
I have a function defined as follows:

void turn_leds_on(int col_indx, int bright_1 = BRIGHTNESS, int del_1 = 5, bool dir_1 = true )

This function is called using MQTT from user to define led's properties, which only first is mandatory ( has no default value ) - MQTT format is : 1,50,40,0, but can be 1,10.

Now, to implements this - I read MQTT message and store os into parameters as follows:

splitter(incoming_msg, 4, parameters); // read 4 parameters

when it defined as:

    void splitter(char *inputstr, int x, char *output[]) {
  char * pch;
  char *pnts[x];
  int i = 0;

  pch = strtok (inputstr, " ,.-");
  while (pch != NULL)
  {
    output[i] = pch;
    pch = strtok (NULL, " ,.-");
    i++;
  }
}

The problem starts when the user enters only 2 parameters and when passing parameters into :

if ( atoi(parameters[0]) <= tot_colors - 1 && isDigit(*parameters[0])) { // color num
      if (atoi(parameters[1]) <= 100 && isDigit(*parameters[1])) { //brightness
        if (atoi(parameters[2]) <= 100 && isDigit(*parameters[2])) { //delay between leds
          if (atoi(parameters[3]) <= 1 && isDigit(*parameters[3])) { //direction
            turn_leds_on(atoi(parameters[0]), atoi(parameters[1]), atoi(parameters[2]), atoi(parameters[3]));

So the question is: how to pass arguments, and on the other hand when they are not given, to use their default values as defined inside the function?