texts:
So, I'm working on RedBear Blend Micro V 1.0, and I must use the function:

ble_write(Serial.read());

To read some input from the serial monitor(Input being stuff I type in the Serial Monitor) and send it via bluetooth.
It works perfectly this way!

Now what I need to do is create a random double data type number, and insert it in the place of Serial.read()

Read This:

ble_write

Syntax:
    void ble_write(unsigned char data);
  ble_write sends a single byte data to the BLE Central.

So, can you please help me, to:

1)Generate a random double

2)Send it using the ble_write() function?

For a full list of function sin the ReadBear Library click on the link:
https://github.com/RedBearLab/nRF8001


texts: 74HC595N shift register with separate power supply

texts:
I have wired up a 74HC595N with an Uno, and the standard 8 LEDs and resistors, per the usual youtube "shift register tutorial" and written a sketch that works.  For example, I wrote a routine to walk from values 0 through 255 and light up the LEDs as a hex number.  So my wiring and code are correct.

As an experiment, I tried disconnecting the pin on my breadboard's power rail that goes to the Arduino 5V, and the pin that goes to Arduino ground, and instead plugged in a breakout (if that's the right word) that plugs into the breadboard and provides 5V on the power rail when a 9V battery is plugged into it.  (It's been checked with a multimeter, it's just under 5V.)  The only pins still going to the Arduino are for DS, SHCP and STCP.

Things sort of work, but not really.  It seems clear to me that the shift register keeps getting reset. (All of the LEDs briefly light back up in each iteration as I'm running my hex number display routine.) All of the other wiring remains the same; specifically OE-bar is still connected to ground on the power rail.  But it still seems to reset.

Can someone explain why the shift register keeps resetting?  Also, am I doing anything that might burn up the Arduino and/or shift register?


texts:
I'm using an Arduino Uno. "Regular" serial is plugged into my computer, and I can receive just fine.

I'm using AltSoftSerial (tried SoftwareSerial, same results) with RX and TX on pins 8 and 9 to interface with a BR-355S4 GPS module. According to the data sheet on that module, the RX and TX are at 5v, which I believe is what the Arduino expects.

I combined the Serial and SoftwareSerial examples to test the connectivity from the Arduino to my PC and from the GPS to the arduino.

#include <AltSoftSerial.h>
AltSoftSerial altSerial;

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

  printAsciiTable();

  altSerial.begin(4800);
}

void printAsciiTable(){
  Serial.println("ASCII Table ~ Character Map");
  int thisByte;
  for(thisByte = 33; thisByte < 127; thisByte++){
    Serial.write(thisByte);
    Serial.print(", dec: ");
    Serial.print(thisByte);
    Serial.print(", hex: ");
    Serial.print(thisByte, HEX);
    Serial.print(", oct: ");
    Serial.print(thisByte, OCT);
    Serial.print(", bin: ");
    Serial.println(thisByte, BIN);
  }
  Serial.println("~~Done with ASCII Table~~");
}

void loop() {
  char c;
  if(altSerial.available()){
    c = altSerial.read();
    Serial.print(c);
  }
}

The data coming into the Serial Monitor tool looks fine until it starts pulling from the GPS serial stream (ellipses added by me):

  ...
  |, dec: 124, hex: 7C, oct: 174, bin: 1111100
  }, dec: 125, hex: 7D, oct: 175, bin: 1111101
  ~, dec: 126, hex: 7E, oct: 176, bin: 1111110
  ~~Done with ASCII Table~~
  4™5f3y=›ùÙ)É9Ó¦Ì™¦ ...

I would like to receive the correct NMEA strings from the GPS module on altSerial and push them out to Serial. The garbled nature of the serial data looks like a baud rate issue, but I've tried a handful of combinations for Serial and altSerial speed with no success. Any ideas?


texts: Why am I not receiving codes from IR receiver over the serial monitor?

texts:
I'm using the Keyes Infrared Receiver Module on an Arduino Uno R3 with the IRemote library included and running the IRrecvDemo example sketch included in the library.

I wired the IR receiver incorrectly the first time I ran the program. I wired the data pin to 5V and wired the Vcc pin on the module to the digital I/O pin. The ground was wired correctly.

Did I destroy the IR receiver by doing this? There was no noticeable overheating.

I corrected the wiring and tried again but still nothing over the serial monitor while pushing buttons on the IR remote that came with it. I wondered if the issue was with the remote so I hooked up a IR LED to flash using the following code:

#include <IRremote.h>

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

IRsend irsend;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop()
{
  for (int i = 0; i < 3; i++) {   //// for statement controls IR LED
    irsend.sendSony(0xa90, 12);
    delay(40);
    if (irrecv.decode(&results))    //// if statement controls the receiver
    {
     Serial.println(results.value, HEX);
     irrecv.resume(); // Receive the next value
    }
  }
}

Nothing showed up on the serial monitor. However, the LED on the IR receiver module began flashing when the receiver was exposed to the IR LED, leading me to believe that I did not destroy the module when I wired it incorrectly.

Update:

I took the IR led and simply lit it with a coin cell battery and the IR receiver detected it and sent data over serial monitor. The remote powered by that same coin cell battery will not trigger the IR receiver. Can I conclude that this is a problem with the remote?


texts:
I need to write and read some data from SD card. I link SD card(LC STUDIO) to Arduino (UNO). I use this link for create my project. In first day I don't have any problem and data correctly save to file. But now my circuit isn't work nicely. When Arduino is running the sketch I don't saw any error message.But when I link the SD card to my laptop, I don't saw any file on card!!
The code is here:

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

const int chipSelect = 10;

File file;

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

  Serial.print("Initializing SD card...");
  pinMode(10, OUTPUT);

  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
  }
  Serial.println("card initialized.");
  //creating file
  file = SD.open("test.txt",FILE_WRITE);
  file.close();
  //write data to file
  file = SD.open("test.txt",FILE_WRITE);
  if(file){
    file.println("OK!!");
    file.println("1");
    file.println("2");
    file.println("3");
    file.println("OK!!");
    file.close();
  }
}
void loop()
{
}


texts: How to get average of 16bit ADC readings?

texts:
I have an Adafruit ADS1115 analog-to-digital converter, configured in single ended mode. I want to average over 3 sensor readings to increase the reading stability.

  //initialize variables
  int16_t rawData, ambient;
  int i=0;

  // start loop
  while(i<3) {
      rawData = ads.readADC_SingleEnded(0); //read from ADC
      // divide sensor reading by three
      // (doing so after summation will lead to an overflow)
      rawData=rawData/3;
      Serial.println(rawData); // print data to serial for debugging (OK)
      ambient+=rawData;
      i+=1;
      delay(100);
      Serial.println("I LIVVVVEEE"); // print text to serial for debugging (OK)
  }

  // Print signal (NOT OK)
  Serial.print("Ambient is ");
  Serial.println(ambient);

The "rawData" is printed correctly on the serial monitor. However, the value for "ambient" can be crazy: the resulting output is over an order of magnitude higher. Somehow, the summation doesn't seem to be performed correctly.


texts: Does the compiler generate intermediate assembler?

texts: My source files are *.ino, but after compilation there aren't any other files placed in the folder. Does the compiler generate intermediate assembler, and if so, where does it leave them? Or is the machine code available somewhere?


texts: why of 2 identical micro-controllers, only one can connect to a given device?

texts:
I am working with 2 identical (Arduino) Adafruit Feather M0 Bluefruit LEs. Only one of them can connect to a Universal Windows Platform app running on a  Windows 10 machine. The other connection fails with Unreachable status.

I am only trying to connect with one MCU at one time. Both MCUs are loaded with the same program which resets the Bluetooth Unit. Both MCUs can connect to an Android app. Neither board appear damaged.

Why could a UWP app be able to connect to one board but not another?


texts: Watchdog timer/deep sleep loop for Atmega 328 Pro Mini 5v 16 mhz

texts:
I have been struggling to get my Adafruit 5v pro mini to loop in deep sleep mode several times, then awake to perform something then return to the deep sleep mode loop. While it is out of deep sleep mode I want the watchdog timer to be active to protect against system hangups. Although I can get in and out of deep sleep mode easy enough, and I can also use a loop that performs one deep sleep/awake cycle. I want to maximize the power savings by having a prolonged deep sleep period of several minutes. I have read many posts related to this subject, but have not yet found a response works for me.  Attached is my code, which loops through the sleep cycle twice, but not if ISR(WDT_vect) on row 85 calls my hardwareReset() function. If my call to hardwareReset is used, my test loop on rows 25-30 times out as expected, but my waitSleep function no longer loops twice. Can anyone please offer guidance? Many thanks
// thanks to KeyChainino for basic code. I added ADC disable to further reduce power from 0.67mA to 0.54mA
//
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/wdt.h>
const int ledPin = 13;
const int resetPin = 9;

// the setup function runs once when you press reset or power the board
void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(resetPin, OUTPUT);
  digitalWrite(resetPin,HIGH);
  Serial.begin(9600);
  Serial.println("Resetting..");
  delay(100);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  for(int i=0; i<9; i++){; //set up loop to force timeout of WDT
  delay(1000);
  Serial.print("Loop ");
  Serial.println(i);
  delay(100);
}
  waitSleep(2); //go sleep for x loops of WDT settings (8 sec max per loop)
}

void waitSleep(int sleep_cycles) {
  while (sleep_cycles) {
    goSleep();
    sleep_cycles--;
  }
}

void goSleep() {
  watchdogSetup(); //enable watchDog
  // disable ADC (analog to digital conversion)
  byte old_ADCSRA = ADCSRA;
  ADCSRA = 0;
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  sleep_mode();
  //disable watchdog after sleep
  wdt_disable();
  ADCSRA = old_ADCSRA;
}

void watchdogSetup() {

  //WDP3 - WDP2 - WPD1 - WDP0 - time
  // 0      0      0      0      16 ms
  // 0      0      0      1      32 ms
  // 0      0      1      0      64 ms
  // 0      0      1      1      0.125 s
  // 0      1      0      0      0.25 s
  // 0      1      0      1      0.5 s
  // 0      1      1      0      1.0 s
  // 0      1      1      1      2.0 s
  // 1      0      0      0      4.0 s
  // 1      0      0      1      8.0 s

  // Reset the watchdog reset flag
  bitClear(MCUSR, WDRF);

 //The following bit have to be set at the same time otherwise the system doesn't set the right value

 /* Start timed equence */
 //Watchdog Change Enable to clear WD (by setting the WDCE bit) and Enable WD (by setting the WDE bit)
 WDTCSR |= (1 << WDCE) | (1 << WDE);

 //Set new watchdog timeout value to 8 seconds (WDP3 and WDP0 to 1) and enable interrupts instead of reset (WDIE to 1)
 WDTCSR = (1 << WDIE) | (1 << WDP3) | (1 << WDP0) ;
}
void hardwareReset(){;
  digitalWrite(resetPin,LOW);
}

ISR(WDT_vect) {
  //hardwareReset();
}


texts: How long should TinyMPU6050.h calibration run for?

texts:
I just found a lightweight library for the MPU6050 gyro. Example below.
mpu.Calibrate() never seems to end. I'm keeping it very still. When I take this out, the rest of the code works fine.

https://github.com/gabriel-milan/TinyMPU6050/blob/master/examples/ArduinoIDE_All_Gets_Example/ArduinoIDE_All_Gets_Example.ino


texts: Can an Arduino Micro receive commands from another microcontroller when hardwired together?

texts:
I plan to build functioning reaction wheels, controlled by an Arduino Micro. Ideally, I'd like to have the reaction wheels, and the micro, be a single unit which would receive external commands from another microcontroller.

I know you can link Arduino microcontrollers, and every time I've seen it done it has been with a RC module such as XBee. Is it possible to link units using something like the micro-usb on the Arduino Micro?

If this is possible, is it as simple as connecting the micro-usb ports on my microcontrollers, and then working out the programming?


texts: Unable to access SD Card when using GPS and MS5611 sensors

texts:
I'm trying to connect multiple sensors to an arduino and write the retrieved data in to a SD. When I test each module separately it works properly, but when I put everything together the SD card module doesn't work, can anybody help me?

This is the code that I'm using:

#include <Arduino.h>
#include <SPI.h>
#include <SD.h>
#include <Wire.h>
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <MS5611.h>

// SD
#define GPS_STORED_DATA_FILE_NAME "gps.txt"
#define SDCARD_PIN 10
bool _sdError = false;

// GPS
#define GPS_RX_PIN 9
#define GPS_TX_PIN 8
#define GPS_BAUD 9600
TinyGPSPlus _gps;
SoftwareSerial _ss (GPS_RX_PIN, GPS_TX_PIN);
unsigned long _timeLastMeasurementGps;

// MS5611
MS5611 _ms5611;

void sdTest(double latitude, double longitude, float elevation, double time) {
  if (_sdError) {
    //Serial.print("SD ERROR. Stopping writing");
    return;
  }
  String fileName = GPS_STORED_DATA_FILE_NAME;
  File myFile = SD.open(fileName, FILE_WRITE);

  if (myFile) {
    Serial.print("Writing to ");
    Serial.print(fileName);
    Serial.print("...");
    //myFile.println("testing 1, 2, 3.");
    myFile.print(latitude);
    myFile.print(" | ");
    myFile.print(longitude);
    myFile.print(" | ");
    myFile.print(elevation);
    myFile.print(" | ");
    myFile.println(time);
    myFile.flush();
    // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening");
    Serial.print(fileName);
    _sdError = true;
  }

  // re-open the file for reading:
  myFile = SD.open(fileName);
  if (myFile) {
    Serial.print(fileName);
    Serial.println(":");

    // read from the file until there's nothing else in it:
    while (myFile.available()) {
        // Serial.write(myFile.read());
      myFile.read();
    }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.print("error opening ");
    Serial.println(fileName);
  }
}

void smartDelay(unsigned long ms)
{
  unsigned long start = millis();
  do
  {
    while (_ss.available())
      _gps.encode(_ss.read());
  } while (millis() - start < ms);
}

void setupSd() {
  Serial.print("Initializing SD...");
  pinMode(SS, OUTPUT);

  if (!SD.begin(SDCARD_PIN))
    Serial.println(" ERROR");
  else
    Serial.println(" DONE");
}

void setupGps() {
  Serial.print("Initializing GPS...");
  _ss.begin(GPS_BAUD);
  smartDelay(1000);
  _timeLastMeasurementGps = millis();
  Serial.println(" DONE");
}

void setupMs5611()
{
   Serial.print("Initializing vario...");
   while(!_ms5611.begin(MS5611_ULTRA_HIGH_RES))
  {
    Serial.println("Could not find a valid MS5611 sensor, check wiring!");
    delay(500);
  }
  // Serial.print("ms5611 Oversampling: ");
  // Serial.println(_ms5611.getOversampling());
  Serial.println(" DONE");
}

void setup()
{
  Serial.begin(115200);
  setupMs5611();
  setupSd();
  setupGps();
}

void loop()
{
  delay (100);
   sdTest(1, 2, 3, 4);
}

Thanks in advance!


texts: 9 volt battery not being able to power motor driver

texts:
Currently I am using a 9 Volt Duracell A one like this:

I am using it to power a motor driver which contains 2 motors within. I  can see where the main problem is coming and that is to do with that the voltage is not big enough. But I don't understand why this is. I see in the manual for the robot that I am building it is using a smaller voltage battery than what I am using. I tried using another set of batteries but the motors did not move at all then. The 9V Duracell battery that I am currently using has only been used for about a week (so it probably hasn't ran out), its practically brand new.


texts: How can I analyse large packets on an Arduino?

texts:
I'm trying to send a large packet to an Arduino with an ethernet shield on it. I'm using the built-in RX buffer of the W5100 controller to store the data, but I need more memory (at least 16K of buffer space, the W5100 only has 8K of RX buffer space). I have control over the server side of things as I'm writing the server process myself, so I can take solutions on that side.

Is there some hack I can use in the TCP protocol to have the packet broken up?

Edit: I'm using the SFML 2.1 network API on the server side.


texts: Arduino Uno + Ardumoto + BT robot works from USB but not from baterries

texts:
My Arduino UNO board is part of a small robot that works when connected to the laptop by USB but it does not when plugged to the batteries. The baterries plug seems okay, it outputs 7.8 V. My UNO is connected to an ArduMoto board that manages the robot motors as well as a bluetooth chip. I have little experience with Arduino or electronics in general so I am stuck on the best course of action.

1) Can I find out what is wrong with the power supply without completely isolating UNO from the robot?

2) If I separate UNO, how can I find out with certainty if my UNO power supply is damaged or not? Is there something in particular that I could measure with my multimeter?

UPDATE

After fully charging my batteries I observed that the LEDs attached to the motor outputs are blinking fast. They blink for about one minute then nothing happens anymore. On USB everything works as expected. Those LEDs show that signal is going towards the motors, but why is it so different to USB? On USB power, the LEDs blink only when I command the robot to move through the BT board while under baterries they blink furiously for a minute and that is all that happens.

I also don't know what happened to the batteries, they seem to be fully drained in just one minute, but I don't know how to test that, they appear to still have high voltage.

I use two LC 18650 4800 mAh 3.7 V UltraFire baterries. The motor shield is Ardumoto Keyes_L298P, very similar to Sparkfun's Ardumoto shield.

I do not have the actual code that is on my Arduino. It must be similar to the code on this page, since I am using their Android app for BT communication with my robot, and it works on USB power supply.


texts: Dshot implementation on Arduino (ESC protocol)

texts:
Does anyone one know if it's possible to implement Dshot on Arduino? I want to interface the Arduino with ESCs (electric speed controllers). These ESCs use Dshot,
 (https://oscarliang.com/dshot/) a digital protocol. From what I read online, you can make PWM follow a duty cycle. However, I want to change the duty cycle after each pulse and not just repeat the same duty cycle. I understand this requires DMA (direct memory access) but it's a bit over my head.


texts: Driving multiple LED arrays with shift registers

texts: The project I'm building requires multiple LED arrays. I'm going to wire these LEDs in parallel and then connect the arrays to individual pins on a shift register. In addition to the LEDs running in parallel I've connected resistors in series to each LED. I've been prototyping this on a couple of breadboards and I've noticed my parallel LEDs are much more dim then my LEDs I have in series. The resistors I'm using are around 550 OHMs and I'm powering the registers through my arduino uno. I think this may be part of the reason why they're so dim, as the arduino is only providing 5V. My question is, can I/should I have my registers connected to my arduino via the data connections and power them using an external source? Will this provide me with brighter LEDs? I don't want to dump the resistors, and I have around 21 arrays, if it matters, each with a varying number of LEDs


texts:
I'm absolutely new to arduino, so please excuse me if this is a noob question.
I want to use a ESP8266 esp-03 Wifi module with a HC-05 bluetooth module together with my arduino uno.
Unfortunately both use the TX and RX pins on the board.
Is there a way to use both, the wifi and the bluetooth modules?
Or do I have to purchase a wifi board?


texts:
I am trying to use I2C to communicate between my XBee3 (controller) and an adafruit trinket m0 (peripheral). I'm pretty confident I have the modules connected properly (trinket SCL/pin 2 to xbee SCL/pin DIO1 & trinket SDA/pin 0 to xbee SDA/pin DIO11, and both grounds are connected). Here is my arduino code on the trinket:
#include <Wire.h>

void setup()
{
Wire.begin(72); // join i2c bus
Wire.onReceive(receiveEvent); // register event
Serial.begin(9600); // start serial for output
Serial.print("Waiting for data...");
}

void loop()
{
delay(100);
}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
(void)howMany; // avoid compiler warning about unused parameter

while(1 < Wire.available()) // loop through all but the last
{
char c = Wire.read(); // receive byte as a character
Serial.print(c); // print the character
}
int x = Wire.read(); // receive byte as an integer
Serial.println(x); // print the integer
}

and here is my code on the XBee:
from machine import I2C

# Instantiate an I2C peripheral.
i2c = I2C(1)
slave_addr = 72
i2c.writeto(slave_addr, b'123', False)

Additionally, when I run an i2c.scan() on the xbee with an ISM330DHCX connected to the xbee's I2C, the address pops right up. But when I use the exact same code with the xbee connected to the trinket m0, the xbee cannot find any devices. (Code pasted below)
from machine import I2C

# Instantiate an I2C peripheral.
i2c = I2C(1)

# Scan for I2C slaves connected to the interface and print their address.
for address in i2c.scan():
    print("- I2C device found at address: %s" % hex(address))

Does anyone have any ideas what I'm doing wrong with configuring the trinket m0 to be an i2c peripheral? Thank you!


texts: Light up more than one LED connected to 74HC595 Shift Register

texts:
I have a 74HC595 Shift Register with a LED (and resistor) on each of the 8 output pins.
I can light them all up
I can light one up

How do I light two up?
For example the one on pin 2 and the one on pin 7

I used this a my starting point.
https://learn.adafruit.com/adafruit-arduino-lesson-5-the-serial-monitor?view=all

Is 74HC595 Shift Register  the correct componet to use?


texts: Creating a keypad matrix that will communicate wirelessly with an Arduino Uno

texts: I have a 30 button matrix and I would like to use a keyboard encoder to decipher what button was pressed. I would like that information (what button was pressed) to be wirelessly sent to my arduino uno nearby. What is the easiest solution? Can/how can I incorporate Arduino's Bluetooth shield to achieve this?


texts: I'm using seep sleep mode with UNO with a simple sketch that turning on an LED and then goes to sleep. as far as the ATmega328p datasheet in sleep mode part showing the wake up sources and deactivated clock sources in deep sleep mode and the I/O clock becomes deactivate so we expect when the board goes to sleep the LED should become off because of no clock. but it doesn't happen and LED keeps ON in sleep mode. what is the problem?7 and how can we even find out that the board is on sleep mode or not?


texts: Feed values to an array using keypad interfaced with Arduino Uno

texts:
I am trying to input keypad values to an array. The code compiles without any error. When running the code, the code proceeds into the for loop and prints 'm' on the lcd, but doesn't execute "customKey = customKeypad.getKey();" and the below steps and keeps printing 'm' 5 times. I am not able to enter keypad values. Please help.

#include <LiquidCrystal.h>
#include <Keypad.h>

const int rs = A1, en = A0, d4 = A2, d5 = A3, d6 = A4, d7 = A5;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

const byte ROWS = 4;
const byte COLS = 4;

char hexaKeys[ROWS][COLS] = { { '1', '2', '3', 'A' }, { '4', '5', '6', 'B' }, {
    '7', '8', '9', 'C' }, { '*', '0', '#', 'D' } };

byte rowPins[ROWS] = { 13, 12, 11, 10 };
byte colPins[COLS] = { 9, 8, 7, 6 };

Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS,
    COLS);

//String inputString = "";
char customKey;
char a[5];

void setup() {
  Serial.begin(9600);
  //inputString.reserve(200);
  lcd.begin(16, 2);
}

void loop() {
  lcd.clear();
  if (Serial.read() == '1') {
    lcd.setCursor(0, 0);
    lcd.print("WELCOME !");
    delay(1000);
    lcd.clear();
    lcd.print("Enter UserID :");
    lcd.setCursor(0, 1);
    for (int i = 0; i < 5; i++) {
      lcd.print('m');
      customKey = customKeypad.getKey();
      delay(30);

      if (customKey) {
        lcd.print('*');
        a[i] = customKey;
      }
      if (i == 5) {
        a[i] = '\0';
        break;
      }

      delay(1000);
    }
  }
}


texts: compilation terminated. exit status 1 error compiling for board arduino/genuino uno

texts:
hi i have done this code for my uno R3 and i cant upload it
any suggestions

#include"DHT.h"
#define DHTPIN 8
#define DHTTYPE DHT11
DHT dht( DHTPIN,DHTTYPE);
const int ledPin=13
int piesoPin=9
void setup(){
  serial.begin(9600);
  pinMode(ledPin,OUTPUT);
  pinMode(piezoPin,OUTPUT);
  delay(5000);
}
void loop(){
  int t=dht.readTemperature();
  int h=dht.readHumidity();
  Serial.print(t);
  if(t>26){
    digitalWrite(ledPin,HIGH);
    digitalWrite(piezopin,HIGH);
    {TONE(9,3047,400);
    delay(1000);
    noTone(8);
    delay(100);
    }
    delay(1000);
    Serial.print("ON T=");
  }
  else(digitalWrite(piezoPin,LOW);
  digitalWrite(LEDpIN,LOW);
  Serial.print("OFF,T=");
  }}


texts: Measure voltage changes with unknown baseline

texts:
I would like to monitor an audio stream and detect when it is "active" and music is playing or when it is "inactive" and is silent. What is a good way to measure when an audio stream changes state and continues to be "active?"

Each audio stream is amplified with this circuit.

Each audio stream has a different baseline voltage when it is not playing and "silent", but that voltage tends to drift slightly and change. This may be an artifact of my amp. I don't have an OScope and my multimeter is rubbish for low voltage so I can't quite pin down where the drift is coming from.

Currently, I'm using the method shown below, but that isn't as effectivewhen the audio stream is loud (e.g. has a compressed dynamic range).

Also, low volume tracks (e.g. classical music) tends have too low of a dynamic range to measure accurately and I get a lot of false "off" states.

#include <elapsedMillis.h>    //measure elapsed time

const int analogInPin = A0;   //Analog input pin - reads from amplifyer circuit
const int statusLight = 10;   //Digital output pin for indicator light
int sensorValueA = 0;         //Sensor reading now
int sensorValueB = 0;         //Previous sensor reading
int sensorDeltaA = 0;          //Change in sensor reading
int sensorDeltaB = 0;          //Record the last delta - useful for prefenting accidental triggering on start
int sensorThreshold = 50;      //Threshold in delta to trigger action
elapsedMillis turnOverTime;   //Timer for measuring the turnover between changes in sensor reading

void loop() {
  //measure the analog input
  sensorValueA = analogRead(analogInPin);
  sensorDeltaA = abs(sensorValueA - sensorValueB);

 //check if the data is over the threshold and switch on
  if ((sensorDeltaA >= sensorThreshold) and (sensorDeltaB != 0)) {
    turnOverTime = 0;
    powerStateA = true;
  }

  sensorValueB = sensorValueA;

  //check if no sensor data beyond the threshold has been returned within the delay window, switch off
  if (turnOverTime >= delayTime) {
    turnOverTime = 0;
    powerStateA = false;
  }

  //if the powerstate changes act acordingly
  if (powerStateA != powerStateB) {
    digitalWrite(statusLight, powerStateA);
  }
}


texts:
I am looking for a relay that stays on (NC=Normally Closed), and when I send a new signal switches to off (NO=Normally Open).

So the relay doesn't consume any power while being in a specific position.

Do you guys know any type?

Thanks :)


texts:
I'm looking for a complete list of the arithmetic types in the Arduino framework.
On the Internet I found various incomplete lists: sometimes there is short, sometimes word, but other types are missing.

Could someone please provide an exhaustive list of the arithmetic data types in Arduino, including the C/C++ types and the Arduino-defined types (or aliases, e.g. the one created among others in Arduino.h with typedef uint8_t byte;) with a short description? If two types are identical please include both names in the list but making clear that they are the same.


texts: How to change the default name of ESP8266-12E module

texts: Is there any way to change the default name (ESP_xxxxx) that the module generates?


texts: Multiple Servo motors with an ultrasonic sensor

texts:
I am building a robot arm with 6 servo motors that works with an ultrasonic sensor. The purpose of the program is when an object is detected at 20 cm (fixed position) from the sensor, the buzzer and led turn on. After the buzzer turns on, the arm moves to that fixed position, picks up the object and places it at another fixed point.

How can I make multiple loops so that the sensor first detects an object then the arm moves to the fixed position, places the object and then returns to the original position.

I would really appreciate all the help I can get !!!

This is what I have so far in the program:

// include servo library

#include <Servo.h>

// define pin numbers for the utltrasonic sensor

const int trigPin = 25; // pin number for trig pin
const int echoPin = 24; // pin number for echo pin
const int buzzer = 32; // pin number for buzzer
const int ledPin = 30; // pin number for led
long duration; // duration storage
int distance; // distance storage
int safetyDistance; // safety distance storage

int servo1Pos, servo2Pos, servo3Pos, servo4Pos, servo5Pos, servo6Pos; // servo positions storage

// define variable for servo positions

Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;
Servo servo6;

void setup() {
  pinMode (trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(buzzer, OUTPUT);
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);

  servo1.attach(6);
  //servo2.attach(7);
  //servo3.attach(8);
  //servo4.attach(9);
  //servo5.attach(10);
  //servo6.attach(11);
  delay(3000);

  // Robot initial position

  servo1Pos = 20;
  servo2Pos = 100;
  servo3Pos = 35;
  servo4Pos = 110;
  servo5Pos = 85;
  servo6Pos = 80;

}

void loop() {

  // clears the trig pin

  digitalWrite (trigPin, LOW);
  delayMicroseconds (2);

  // sets trig pin on HIGH state for 10 microseconds

  digitalWrite (trigPin, HIGH);
  delayMicroseconds (10);
  digitalWrite (trigPin, LOW);

  // reads echo pin and stores the value in duration variable

  duration = pulseIn (echoPin, HIGH);

  // distance is calculated

  distance = duration*0.034/2;

  // distance is stored in safetyDistane variable

  safetyDistance = distance;

  if (safetyDistance <=20) {

    digitalWrite (buzzer, HIGH); // the buzzer turns on if the distance is less than 5 cm
    digitalWrite (ledPin, HIGH);
    delay (1000);
    digitalWrite (buzzer, LOW); // the buzzer turns off after 5 sec
    delay (1000);

    for (servo1Pos = 20; servo1Pos <= 90; servo1Pos +=1)
    {
      servo1.write (servo1Pos);
      delay (500);
    }
    for (servo2Pos = 100; servo2Pos <= 180; servo2Pos +=1)
    {
      servo2.write (servo2Pos);
      delay (500);
    }
    //for (servo3Pos = 35; servo3Pos <= 90; servo3Pos +=1)
    {
      //servo3.write (servo3Pos);
      //delay (500);
    }
    //for (servo4Pos = 120; servo4Pos <= 180; servo4Pos +=1)
    {
      //servo4.write (servo4Pos);
      //delay (500);
    }
    //for (servo5Pos = 85; servo5Pos <= 90; servo5Pos +=1)
    {
      //servo5.write (servo5Pos);
      //delay (500);
    }
    //for (servo6Pos = 80; servo6Pos <= 90; servo6Pos +=1)
    {
      //servo6.write (servo6Pos);
      //delay (500);
    }

    delay (1000);

    for (servo1Pos = 20; servo1Pos >= 90; servo1Pos -=1)
    {
      servo1.write (servo1Pos);
      delay (500);
    }
    for (servo2Pos = 100; servo2Pos >= 180; servo2Pos -=1)
    {
      servo2.write (servo2Pos);
      delay (500);
    }
    //for (servo3Pos = 35; servo3Pos >= 90; servo3Pos -=1)
    {
      //servo3.write (servo3Pos);
      //delay (500);
    }
    //for (servo4Pos = 120; servo4Pos >= 180; servo4Pos -=1)
    {
      //servo4.write (servo4Pos);
      //delay (500);
    }
    //for (servo5Pos = 85; servo5Pos >= 90; servo5Pos -=1)
    {
      //servo5.write (servo5Pos);
      //delay (500);
    }
    //for (servo6Pos = 80; servo6Pos >= 90; servo6Pos -=1)
    {
      //servo6.write (servo6Pos);
      //delay (500);
    }

    delay (1000);

  }

}


texts:
I am using Free RTOS on esp32 in my program.
However at some point of time when I execute xTaskCreate() it returns -1 , which error is  could_not_allocate_required_memory. In my program, each time i pring getFreeHeap() it is reduced by 2000 approximately and is never cleared or reset, when it is not sufficient or below 2000 xTaskCreate returns -1.
After reading a lot of forums I could not find a way to clear the memory to create a task, can anyone guide me achieving this ?
code snippet
void createTsk(){
  SerialDebug.print("available Heap size: ");
  SerialDebug.println(ESP.getFreeHeap());

  BaseType_t xBy = xTaskCreate(taskPriorityOne, "TaskOne", 20240, NULL, 1, &thOne);
  SerialDebug.println("Return Val : ");
  SerialDebug.println(xBy);
}

void taskPriorityOne(void *paramter)
{
   SerialDebug.println("Prio 1 task Initiated");
   threadTask(priorityOneQue, "task1", thOne);
}

void threadTask(QueueHandle_t priorityQue, String taskName, TaskHandle_t th)
{

  xQueueReceive(priorityQue, &taskdataholder, portMAX_DELAY);
  ongoingProcess = taskdataholder;
  furtherExecutionHttp(taskdataholder, fnm, taskName, th);

}

void furtherExecutionHttp(DataHolder *taskdataholder, String fnm, String
taskName, TaskHandle_t th)
{

   String response = httpRequest(taskdataholder->protocol, taskdataholder-
   >host, taskdataholder->port, taskdataholder->url, taskdataholder->body,
   fnm);

  delay(10);

  free(taskdataholder);
  SerialDebug.println("Releasing memory..\n");

  vTaskDelete(th);
}


texts:
I'm trying to use CHSV with FastLED library and as I understand hue, value and saturation in the CHSV type are of type uint8_t, or 1 byte.

My problem is with using variables:

CHSV led = (hue, sat, val);

with:

uint8_t hue;
uint8_t sat;
uint8_t val;

Is there a difference between uint8_t and byte data types? what is it and how does one use it with the context of arduino and FastLED library?
Am I getting the syntax wrong?
I get an error - convertion from 'uint8_t' to non scalar type 'CHSV' requasted.
I thought the library does that on its own, do I need to add more code? If yes, what code?

Thank you


texts:
So I am trying to make an audio visualizer from this tutorial listed here.

So I downloaded all the files needed, and downloaded the code. But when I try to verify it, I get this Error:

C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp: In constructor 'RobotControl::RobotControl()':
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:8: error: 'LCD_CS' was not declared in this scope
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:8: error: 'DC_LCD' was not declared in this scope
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:8: error: 'RST_LCD' was not declared in this scope
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp: In member function 'void RobotControl::begin()':
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXA' was not declared in this scope
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXB' was not declared in this scope
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXC' was not declared in this scope
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXD' was not declared in this scope
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:19: error: 'MUX_IN' was not declared in this scope
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:22: error: 'BUZZ' was not declared in this scope
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:25: error: 'Serial1' was not declared in this scope
core.a(main.cpp.o): In function `main':
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\hardware\arduino\cores\arduino/main.cpp:11: undefined reference to `setup'
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\hardware\arduino\cores\arduino/main.cpp:14: undefined reference to `loop'

I've looked this up before, and couldn't find anything on it. So I came here for a last resort.

Any ideas?

EDIT: So I reinstalled the folders, and renamed the LED folder but now I get a new error:

Piccolo:112: error: 'Adafruit_BicolorMatrix' does not name a type
Piccolo.pde: In function 'void setup()':
Piccolo:130: error: 'matrix' was not declared in this scope
Piccolo.pde: In function 'void loop()':
Piccolo:168: error: 'matrix' was not declared in this scope
Piccolo:168: error: 'LED_RED' was not declared in this scope
Piccolo:169: error: 'LED_YELLOW' was not declared in this scope
Piccolo:170: error: 'LED_GREEN' was not declared in this scope
Piccolo:207: error: 'LED_OFF' was not declared in this scope
Piccolo:210: error: 'LED_OFF' was not declared in this scope

EDIT 2: Deleted Robot_Control and got this error:

In file included from Piccolo.pde:34:
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Adafruit_LEDBackpack/Adafruit_LEDBackpack.h:94: error: expected class-name before '{' token
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Adafruit_LEDBackpack/Adafruit_LEDBackpack.h:103: error: expected class-name before '{' token
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Adafruit_LEDBackpack/Adafruit_LEDBackpack.h:112: error: expected class-name before '{' token
Piccolo.pde: In function 'void loop()':
Piccolo:168: error: 'class Adafruit_BicolorMatrix' has no member named 'fillRect'
Piccolo:169: error: 'class Adafruit_BicolorMatrix' has no member named 'fillRect'
Piccolo:170: error: 'class Adafruit_BicolorMatrix' has no member named 'fillRect'
Piccolo:207: error: 'class Adafruit_BicolorMatrix' has no member named 'drawLine'
Piccolo:210: error: 'class Adafruit_BicolorMatrix' has no member named 'drawLine'


texts: Confused as to how 2 of my interrupts are firing from just 1 pin input?

texts:
I have the following code which uses interrupts to set a flag for whether serial IO should happen to update my PC about a particular pin input. So I have interrupts on pins 2 and 3.

I am using the arduino's pin 13 as an output, and every 2 seconds send a pulse. On my arduino, I have 1 wire running from 13 to pin 3. Note: I have nothing at all inserted into pin 2.

Somehow, I get the following input every 2 seconds:

Pin 2
Pin 3

How is my interrupt for pin 2 firing??

boolean serialCommsQueue1 = false;
boolean serialCommsQueue2 = false;

void setup()
{
  pinMode(2, INPUT);
  pinMode(3, INPUT);
  attachInterrupt(digitalPinToInterrupt(2), pin2Fired, RISING);
  attachInterrupt(digitalPinToInterrupt(3), pin3Fired, RISING);
  Serial.begin(9600);
  pinMode(13, OUTPUT);
}

void loop()
{
  digitalWrite(13, HIGH); // sets the digital pin 13 on
  delay(1000);            // waits for a second
  digitalWrite(13, LOW);  // sets the digital pin 13 off
  delay(1000);            // waits for a second

  if (serialCommsQueue1)
  {
    serialCommsQueue1 = false;
    Serial.println("Pin 2");
  }

  if (serialCommsQueue2)
  {
    serialCommsQueue2 = false;
    Serial.println("Pin 3");
  }
}

void pin2Fired()
{
  serialCommsQueue1 = true;
}

void pin3Fired()
{
  serialCommsQueue2 = true;
}

EDIT:

If I take the wire out of 3, pin 2 constantly (every 2 seconds) writes to serial. If I put the wire back in pin 3 regularly writes every 2 seconds - which itself is a problem too, since it should only be detecting a 'change'?


texts: Sizes of the original ESP32-DevKitC-32U Wifi board

texts:
I know that this topic does not apply to Arduino, but for me it is important to find a solution to the problem. I know the consequences.

I'm creating a pcb board into which the original ESP32-DevKitC-32U module will be inserted. I can not find the original dimensions of the board, in particular the distance between the contact rails. The site espressif has a small description.

27.9mm is indicated here. It is not clear to me, is this the full width of the board or the distance between the contacts?

What I want to do:

It is very important for me to find out the correct dimensions of the original board. Maybe someone has such a board and can measure this size?


texts: Would rewriting my code in C help reduce RAM usage?

texts:
So my program fails to run because there is not enough room for my variables as well as the Arduino Core and Stack. I can't find any more ways to optimize my program so I'm thinking about just rewriting it in C.

However, I'm not sure if that will actually help me. For example I know that in C my program will run faster because things like digitalWrite() and analogRead() have a bunch of "extras" that make it go slower, but I don't know if this will affect RAM.

So can any of the experts on here tell me if writing my code will help before I waste time doing so?

Here is my code:

#include <SoftwareSerial.h>
#include <avr/pgmspace.h>

#define FASTADC 1

// defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

SoftwareSerial mySerial(0,1) PROGMEM;

byte i;

byte pixelsArray1[128];   //Array to hold the values of the individual pixles.
byte pixelsArray2[128];   //Array to hold the values of the individual pixles.
byte pixelsArray3[128];   //Array to hold the values of the individual pixles.

void setup()
{
  #if FASTADC
   // set prescale to 16
   sbi(ADCSRA,ADPS2);
   cbi(ADCSRA,ADPS1);
   cbi(ADCSRA,ADPS0);
  #endif

  pinMode(1,OUTPUT);        //Setting the 1 pin to be used for output
  pinMode(0,OUTPUT);        //Setting the 0 pin to be used for output
  pinMode(A3,INPUT);        //Input for Camera 3
  pinMode(A2,INPUT);        //Input for Camera 2
  pinMode(A1,INPUT);        //Input for Camera 1

  mySerial.begin(9600);     //Setting the data transfer rate
}

Notes:

I'm programming on the ATtiny85
I'm running Windows 10
I've never programmed in Arduino before


texts: Common wireless gadget with rotary encoder to connect with Arduino

texts:
I'm looking for a common "wireless gadget" with a rotary encoder that can be accessed by an Arduino. Background: I need a portable rotary encoder to create a simple way to control model railway locomotives. The only one I have found so far is a wireless mouse where the scroll wheel can be easily used as rotary encoder.

But they usually are using USB on the PC side which is not that easy to handle by Arduino. Does anybody knows about other common "wireless gadgets"?


texts: i wanted to make a remote controlled wall socket over wifi (and maybe internet in the future) with an Arduino, i'm relatively new to Arduino, i know only the basics of programming. My idea was to use a Arduino Pro Mini, a relay, a Esp8266 wifi module to connect to my home wifi and maybe a module to monitor consumption like the ACS712 current sensor but i don't know how to make all of this work, maybe i can get the Arduino working but i don't know how to control it on the client side like an app or web interface on my phone/computer.


texts: Writing elegant applications for Arduino

texts:
Coming from a C background, I was taught that tight loops that just burn CPU aren't desirable.

Is there any programming style guides on Arduino? Is it common practice to just let loop iterate as a tight loop forever?


texts:
I am using Arduino Duemilanove and a hall effect sensor to calculate the speed of a motor.  When I used sensor out directly to Interrupt0, the rising edges of noise were also detected. So the speed calculation went wrong.

So now  sensor is connected to A0.and a threshold is put. Pin No 13 is connected to Interrupt 0(Pin 2). I use the following code.

volatile byte count;
 const int analogPin = A0;
 const int digitalPin=13;
 const int threshold =20;
 unsigned int rpm;
 unsigned long starttime;

 void setup()
 {
   pinMode(digitalPin,OUTPUT);
   digitalWrite(analogPin,HIGH);
   digitalWrite(digitalPin,HIGH);
   Serial.begin(9600);
   attachInterrupt(0,sense,FALLING);
   rpm=0;
   starttime=0;
   count=0;
 }
 void loop()
 {
   int sensorValue = analogRead(analogPin);
   Serial.println(sensorValue);
   if (sensorValue < threshold)
   {
     digitalWrite(digitalPin,LOW);
     if (count>=20)
     {
       rpm=60*1000*count/(millis()-starttime);
       starttime=millis();
       count=0;
       Serial.println(rpm,DEC);
     }
   }
   else
   {
     digitalWrite(digitalPin,HIGH);
   }

 }
 void sense()
 {
  count++;
 }

But I get actual speed only in between. The speed changes back . I feel there is some problem with the sampling or rpm updation. Looking forward for help


texts:
I've been trying to get colours fade into each other for a project I'm working on.
I have achieved this with the rainbow effect that some from Adafruit's example code, however I want to be able to choose the colours (eg. dark blue into light blue).

I've got the colours changing and fading, however the fade turns off all the LEDs and starts to increase the brightness of the new colour. I need the colours to blend rather than fade out and increase in brightness.

Is anyone able to point me in the right direction?

#include "LPD8806.h"
#include "SPI.h"
#define stripSize 64

int nLEDs = 160;

int dataPin  = 2;
int clockPin = 3;

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

// You can optionally use hardware SPI for faster writes, just leave out
// the data and clock pin parameters.  But this does limit use to very
// specific pins on the Arduino.  For "classic" Arduinos (Uno, Duemilanove,
// etc.), data = pin 11, clock = pin 13.  For Arduino Mega, data = pin 51,
// clock = pin 52.  For 32u4 Breakout Board+ and Teensy, data = pin B2,
// clock = pin B1.  For Leonardo, this can ONLY be done on the ICSP pins.
//LPD8806 strip = LPD8806(nLEDs);

void setup() {
  // Start up the LED strip
  strip.begin();

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

void loop() {
  //turnAllOn(strip.Color(30,30,30),4000);
  fade(0, 127, 0, 100); //red, green, blue, delay - fade up all pixels one color
  //turnAllOn(strip.Color(30,100,30),4000);
  fade(50, 127, 02,100); //red, green, blue, delay - fade up all pixels one color
  //turnAllOn(strip.Color(100,30,100),4000);
  fade(50, 127, 50, 100); //red, green, blue, delay - fade up all pixels one color
}

void fade(uint32_t r, uint32_t g, uint32_t b, uint32_t wait) {
  int i, j;
  for (j=0; j < 384; j++) {
    for (i=0; i < strip.numPixels(); i++) {
      strip.setPixelColor(i, strip.Color((r*j)/1000,(g*j)/1000,(b*j)/1000));
    }
  strip.show();
  }
  delay(wait);
}

void turnAllOn(uint32_t c, uint32_t wait) {
  int i;
  for (i=0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, c);  // turn all pixels on
  }
  strip.show();   // write all the pixels out
  delay(wait);
}

uint32_t Wheel(uint16_t WheelPos)
{
  byte r, g, b;
  switch(WheelPos / 128)
  {
    case 0:
      r = 127 - WheelPos % 128;   //Red down
      g = WheelPos % 128;      // Green up
      b = 0;                  //blue off
      break;
    case 1:
      g = 127 - WheelPos % 128;  //green down
      b = WheelPos % 128;      //blue up
      r = 0;                  //red off
      break;
    case 2:
      b = 127 - WheelPos % 128;  //blue down
      r = WheelPos % 128;      //red up
      g = 0;                  //green off
      break;
  }
  return(strip.Color(r,g,b));
}


texts:
I bought a very old oscilloscope and although it works, I have my doubts about refreshing the screen (the electron beam fades away very slowly or is not showing up consistently across the screen).

I tested a bit with digitalWrite and anlogWrite, but this only sends either 0 or 5V out. Is there a way to make a preferably sine or triangle wave of 0 to 5V or -5 to +5V... I guess the Arduino should be capable of it, but so far I only get 0V or 5V out, nothing in between.

According to lesson 8 I should get a variable voltage of 0-5V on a pin with analogWrite, but all I get is 0 or 5V.

For what I see:

PWM gives with analogWrite a pulse signal of 0V or 5V with a duty cycle.
non PWM pins give either 0V or 5V (analogWrite of 0-127 appr: 0V, >127: 5V).


texts: Is there a manometer available to use with Arduino?

texts:
I used an analog manometer in a plumb system. I would like to actually track information about water pressure across an entire building on different points and record all this information to analyze changes on pressure. I was wondering if there is a manometer that can be used with arduino. Or if there is some other homemade solution?

If there is any electronic sensor with an analog output that would be enough.


texts: Taking voice input from raspberry pi and sending converted text to arduino to turn on relays

texts: I have one raspberry pi B+ and an Arduino uno. I know how to control a relay from an Arduino. I searched a tutorial about voice recognition on arduino but got to know that arduino cannot take in audio inputs. It can just sense if there is an audio. Now I think that I can use the raspberry pi to take inputs and convert it to text with software and then send it to arduino. Then Arduino can control the relay. Is there any way to do that?


texts:
I've been looking at water flow control with Arduino and I'm finding a huge difficulty in managing to do an 'analog' control on water flow. The mainstream solution seems to be the well known solenoid valve, however those seem to be binary (full flow, no flow), and I'm looking for a more variable answer.

Is it possible to get middlegrounds with solenoids? Maybe actuating them with less voltage or amperage will cause it to partially actuate? If not, does anyone know of embedded solutions using servos or steppers maybe?


texts:
I am making a project in which I am trying to communicate the LDR values collected by one arduino(slave) to another arduino(master) via bluetooth. The readings of the LDR is displayed on the serial monitor.
The slave part of the arduino code :

 #include <SoftwareSerial.h>
  SoftwareSerial BTSerial(10, 11); // RX | TX
  #define ldrPin A0
  int ldrValue = 0;
  void setup() {
     pinMode(9, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
     digitalWrite(9, HIGH);
     pinMode(ldrPin, INPUT);
     BTSerial.begin(9600);
     Serial.begin(9600);

   }
   void loop()
    {
     ldrValue = analogRead(ldrPin);
     BTSerial.println(ldrValue);
     Serial.println(ldrValue);
     delay(10);
    }

I tried getting the readings of LDR in serial monitor to check whether the readings are correct. The readings shown in Serial monitor were correct.

The code of master part of the project which receives the readings from slave :

#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX | TX
const byte numChars = 1024;
char receivedChars[numChars];   // an array to store the received data

boolean newData = false;

void setup() {
pinMode(9, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH  to switch module to AT mode
digitalWrite(9, HIGH);
BTSerial.begin(9600);
Serial.begin(9600);
Serial.println("<Arduino is ready>");
}

void loop() {
   recvWithEndMarker();
   showNewData();
 }

void recvWithEndMarker() {
   static byte ndx = 0;
   char endMarker = '\n';
   char rc;

   while (BTSerial.available() > 0 && newData == false) {
     rc = BTSerial.read();

     if (rc != endMarker) {
        receivedChars[ndx] = rc;
        ndx++;
        if (ndx >= numChars) {
            ndx = numChars - 1;
        }
    }
    else {
        receivedChars[ndx] = '\0'; // terminate the string
        ndx = 0;
        newData = true;
      }
    }
  }

   void showNewData() {
      if (newData == true) {
       Serial.print("This just in ... ");
       Serial.println(receivedChars);
       delay(1000);
       newData = false;
    }
   }

But The serial monitor did not show the correct readings of LDR . Instead it showed something like this

<Arduino is ready>
 This just in ... 8
 This just in ... 3
 This just in ... 4
 This just in ... 3
 This just in ... 3
 This just in ... 3
 This just in ... 3
 This just in ... 4
 This just in ... 3
 This just in ... 4
 This just in ... 3
 This just in ... 3

I have referred this link for the Arduino serial communication:
Serial Input

Kindly help me out since it has been days since I have stuck up in this issue.

Thank you!


texts: Arduino potentiometer example: what limits the current?

texts:
I have a question regarding potentiometer example:

https://www.arduino.cc/en/Tutorial/AnalogReadSerial

If I turn the potentiometer to the marginal position and have 5V at A0 (and almost zero resistance at the pot), what limits the current flowing through the circuit?


texts:
Can not initialize ESP module in Arduino SoftwareSerial's example sketch in configuring WiFi module.

In the sketch it tells:

#include "WiFiEsp.h"
// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(11,12); // RX, TX
#endif

I plugged jumper wires in from esp8266 RX to Digital 11 of mega which is RX and TX of esp8266 to Digital 12 of mega, and I compile the code and looked at the Serial Monitor, but it says:

[WiFiEsp] Initializing ESP module
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] Cannot initialize ESP module

Advise is greatly appreciated.


texts: How do I read data from Parallel port DB25 over my Arduino?


texts: Using an Arduino as a lithium ion charge controller

texts: I have a trinket that I'm going to be powering off of a small lithium ion battery. I was also considering adding a small solar panel to the mix, and using the solar panel to charge the battery. I'm wondering if I can use the trinket itself as a smart charge controller to charge and monitor the battery.


texts: Why is there no smooth value from ADXL335?

texts:
I have written this code to read x-acceleration from ADXL335.

Why is the value toggling between 342, 343, 344 even at rest? Is there anything I need to do to get a smooth curve?
How to increase resolution? (I'm using a Mega 2560)

int Xcurr,Ycurr,Zcurr;
int Xpre=0,Ypre=0,Zpre=0;
int res=0;
// these constants describe the pins. They won't change:
const int groundpin = A1;
// analog input pin 4 -- ground
const int powerpin = A0;
// analog input pin 5 -- voltage
const int xpin = A3;
// x-axis of the accelerometer
const int ypin = A2;
// y-axis
const int zpin = A4;
// z-axis (only on 3-axis models)
const int stpin = A5;

void setup() {
  Serial.begin(9600);
  pinMode(groundpin, OUTPUT);
  pinMode(powerpin, OUTPUT);
  digitalWrite(groundpin, LOW);
  digitalWrite(powerpin, HIGH);
  pinMode(stpin, OUTPUT);
  digitalWrite(stpin, LOW);
}

void loop() {
  Xcurr=analogRead(xpin);
  Serial.print(Xcurr);Serial.print("\n");
  delay(100);
}


texts: ADS1115 : measuring 5v voltages and powering with 3.3v

texts:
I have a project where I need to measure 0 - 5 V. I’m using a ADS1115 to have a better precision, connected to a ESP12. Since the ESP is only 3.3 V tolerant and the ADS powered by 5 V (because it needs to be powered a the same voltage as the measured voltage), I put the two pull-up resistor of the I2C bus on 3.3 V.

Is it safe to operate like this?


texts: creating object of another class when initializing an object of a class

texts:
Here's what I want to achieve:
I'm building a class for controlling step motors. In that class I want to have a method called "init". In that method I'd like to create an object of class Tone, which I'll need to control a motor.
BUT I want to have seperate Tone class object for every object of my class that I create. How can I do it?

So, for exmaple, if I have:

myClass newmotor1;
memotor1.init();

After executing these two lines, I'd like to have my object newmotor1 (which I have, because I just created it) AND an object of class Tone, which I'll use.


texts:
I am using 2 accelerometers connected to an arduino. The code below does not work.

> if((acc1 >= 20 && acc1 <= 40) && (acc2 >= 20 && acc2 <=40)) //If acc1 is between 20 and 40 AND if acc2 is between 20 and 40
>     {
>         digitalWrite(13, HIGH);
>     }

But, the following code does:

> if((acc1 >= 20 && acc1 <= 40)) //If acc1 is between 20 and 40
>     {
>         digitalWrite(13, HIGH);
>     }

Can anyone tell me why please?
Edit with full code:

const int acc1_xPin = 0; //X Pin on acc1
const int acc1_yPin = 1; //Y Pin on acc1
const int acc2_xPin = 2; //X Pin on acc2
const int acc2_yPin = 3; //Y Pin on acc2

int xAcc1_maxVal = 409; //Maximum value for X-axis Acc1
int xAcc1_minVal = 269; //Minimum value for X-axis Acc1
int yAcc1_maxVal = 410; //Maximum value for Y-axis Acc1
int yAcc1_minVal = 270; //Minimum value for Y-axis Acc1

int xAcc2_maxVal = 411; //Maximum value for X-axis Acc2
int xAcc2_minVal = 268; //Minimum value for X-axis Acc2
int yAcc2_maxVal = 402; //Maximum value for Y-axis Acc2
int yAcc2_minVal = 263; //Minimum value for Y-axis Acc2

//Hold Calculated Values
double acc1; //acc1 angle
double acc2; //acc2 angle

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

// the loop function runs over and over again forever
void loop() {

  int acc1_xRead = analogRead(acc1_xPin); //acc1 X-axis
  int acc1_yRead = analogRead(acc1_yPin); //acc1 Y-axis
  int acc2_xRead = analogRead(acc2_xPin); //acc2 X-axis
  int acc2_yRead = analogRead(acc2_yPin); //acc2 Y-axis

  //convert read values to degrees -90 to 90 - Needed for atan2
  int acc1_xAng = map(acc1_xRead, xAcc1_minVal, xAcc1_maxVal, -90, 90);
  int acc1_yAng = map(acc1_yRead, yAcc1_minVal, yAcc1_maxVal, -90, 90);
  int acc2_xAng = map(acc2_xRead, xAcc2_minVal, xAcc2_maxVal, -90, 90);
  int acc2_yAng = map(acc2_yRead, yAcc2_minVal, yAcc2_maxVal, -90, 90);

  //Caculate 360deg values like so: atan2(-yAng, -zAng)
  //atan2 outputs the value of -π to π (radians)
  //We are then converting the radians to degrees
  acc1 = RAD_TO_DEG * (atan2(-acc1_yAng, -acc1_xAng) + PI); //acc1 in degrees
  acc2 = RAD_TO_DEG * (atan2(-acc2_yAng, acc2_xAng) + PI); //acc2 in degrees

  if((acc1 >= 20 && acc1 <= 40) && (acc2 >= 20 && acc2 <= 40))
  {
    digitalWrite(13, HIGH);
    Serial.println("HIGH");
  }
  else if ((acc1 >= 41 && acc1 <= 60) && (acc2 >= 41 && acc2 <= 60))
  {
    digitalWrite(13, LOW);
    Serial.println("LOW");
  }

  Serial.print("Acc1: ");
  Serial.print(acc1);
  Serial.print(" Acc2: ");
  Serial.print(acc2);
  delay(1000);

}

I'd really appreciate any input as to way the if statements are not working when I have 2 conditions in them but will work when I have 1 condition.

Edit:
I have corrected the typos in the code. My laptop gave up on me last night so I had to retype the code on a friends laptop, hence the typos and why I didn't post the whole code initially.
The IF statements still don't work as stated above when the 2 conditions are in the IF statements together, but when I only put 1 condition in, it works fine.


texts:
I'm designing a shield for Arduino which drives two stepper motors. They are small and require 5V but their max combined current is around 1A, way too much for the USB supply. Therefore I will have external 5V power supply connected to my shield.

The entire device will usually operate being connected to a PC through USB, but still I'd like to have a possibility to run it separately.

The question is: how to power Arduino itself?

From my external PSU through the pins: Sounds as the simplest solution but I'm bit worried about the onboard regulator of Arduino while reverse powered.
Separate power circuits for electronics and motor: My L293D chips allow for separate power and even different voltage for the motors. It could even be an advantage for my shield, as I could use other motors and different power for them in the future. I will, however, lose the possibility of running the device without USB connection.
Same as above with additional barrel jack power connection to supply Arduino when USB is disconnected. This, however, could fail with 5V supply, because of the voltage drop of the regulator which handles power coming from barrel jack.


texts: Problem with arduino starter kit project 7

texts:
Can someone pls help me only the two buttons clossest to the big green wire work and i don^t know why i have already tried swapping buttons

EDIT 1:
my code

and i know the first two are working because they generate a tone with the piezo
the third one does nothing and the last one only makes static noises


texts: How to count the voltage pulses of a digital temperature sensor using Arduino Mega Atmega2560?

texts:
I have a digital temperature sensor which gives digital output in the form of current pulses. The number of pulses corresponds to a particular temperature.

I have converted the current pulses to voltage pulses using transistor as a level shifter. I want to count the number of pulses for a time interval of 50ms each time.

Please help me with the algo and the code.


texts:
I'm looking for a library which would allow me to read the MPU9250 data without having to deal with float. So far, I have found 3 libraries:

FaBo_202_9Axis_MPU9250
MPU9250_asukiaaa
SparkFun_MPU-9250_9_DOF

None of them seem to expose raw integer acceleration values, only floats.


texts:
I am using a sensor which delivers a 4 to 20 mA output.
Converting this with a 250 Ohm resistor to ground I convert this to a 1 - 5 V output.

My question how can I change the 0V reference, so I can use the full spectrum
I found a way to change the 5V reference (analogReference()).
Is it possible to change the 0V reference of a input to 1V?

Any other solution to my problem is welcome as well! (As long as it doesn't involve I2C or anything which lowers my looptime drastically)


texts: Read from Blynk terminal number to arduino

texts:
I have a problem in sending numbers from blynk terminal to arduino serial monitor. When I send any number from blynk terminal the arduino always getting 1. How can I get any number please help me. Thank you.
Here's my code
BLYNK_WRITE(V0){
  int pinValue = param.asInt(); // Int Value
  String i = param.asStr(); //String Value
  Serial.println(pinValue);

 if(i == "A"){
      Serial.println("Ready to enroll a fingerprint!");
      Serial.println("Please type in the ID # (from 1 to 127) you want to delete...");

      Blynk.virtualWrite(V0, "Ready to enroll a fingerprint!");
      Blynk.virtualWrite(V0, "Please type in the ID # (from 1 to 127) you want to save this finger
      as...");

      uint8_t num = 0;

        while (num == 0) {
          while (! Serial.available());
          num = Serial.parseInt();
        }
      Serial.print("Enrolling ID #");
      Serial.print(num);
 }
}

The value output of num is always 1 even I sent a different number.


texts: Errors reading fixed-length control strings over serial

texts:
I am sending a short 12-char control string over serial with Python and Debian Jessie.

It works, but sometimes chars are added or skipped randomly. Here it is an extract of the Arduino code:

void setup() {
  matrix.begin();
  matrix.setTextWrap(true);
  matrix.setFont(&TomThumb);
  matrix.fillScreen(matrix.Color333(0, 1, 1));
  matrix.swapBuffers(false);
  Serial.begin(115200);
}

void loop() {
  char c = 0; // serial char buffer
  byte i = 0; // string counter (reused multiple times)
  // read the equalizer control string
  delay(1);
  if (Serial.available() > 0) {
    turnmatrixoff();
    String control_str = Serial.readStringUntil('\n');
    Serial.println((control_str));
    draw_equalizer(control_str.c_str());
  }

Here is the log of the strings echoed back from the Arduino:

10563942332
00863931110
00773940100
0000974940100
00763940100
10693931211
00593950100
00544840100
00464950100
1050000
004549310744940100
00664961211
00694941111
10784951100
0
00593931100
00373931100
00483920100
00583720110
10473510000
000332710000
00252710000
00142510000
00122620000
002510000
003310100
00334520110
00343520100
00244720100
00355820110
00343611110
10144621210
00424921210
10343921210
00233811310

As you can see, some strings are truncated or padded (they all should be of the same size).

I've tried coding a char-by-char read function but the results were even worse:

char c = 0; // serial char buffer
byte i = 0;

while (Serial.available() > 0) {
  delay(1);  //small delay to allow input buffer to fill
  c = Serial.read();
  if (c == '\n' || i >= EQUALIZER_STR_SIZE - 1) {
    // finished reading the string
    equalizer_str[i] = 0; // terminate the string
    Serial.println(equalizer_str); // debug echo
    draw_equalizer(equalizer_str);
    break;
  } else {
    // append to the string
    equalizer_str[i] = c;
    i += 1;
  }
}

EDIT: here it is the full python script.

Decreasing the baud rate to 9600 seems to fix the issue, but the matrix updates too slowly this way.

Maybe I could use some other serial port initialization trick to prevent buffer overflows?

UPDATE:

I've found another way to reduce the serial traffic by increasing the audio capture chunk. For some reason this way the errors are gone completely.
Here it is a video of the code finally running fine.


texts: 3rd Libraries: fatal error: Something.h: File does not exist

texts:
I created this question because I find many questions with similar problems,
  so I wanted to provide a reference/ more generic question for these type of problems.

For my projects I have installed 3rd party libraries by cloning from the library's git repository into the folder that preferences.txt's sketchbook.path value exists into a folder named libraries. In other words if the sketchbook.path has the value /home/myuser/sketchbook I clone the repositories into the folder /home/myuser/sketchbook/libraries.

Then on the folder /home/myuser/sketchbook/myexample I store my code myexample.ino that needs a library with header files Something.h.

While I click on Arduino IDE the verify button I get the error:

/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions
    -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD
    -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__
    -I/usr/share/arduino/hardware/arduino/cores/arduino
    -I/usr/share/arduino/hardware/arduino/variants/standard
    -I/usr/share/arduino/libraries/SPI
    /tmp/build6596169359663087897.tmp/LoRaSerialGateway.cpp -o
    /tmp/build6596169359663087897.tmp/LoRaSerialGateway.cpp.o
LoRaSerialGateway.ino:15:18: fatal error: Something.h:
compilation terminated.

So my guess is that I cannot make avr-gcc to compile using the 3rd party library. Do you know how to pass into avr-gcc the correct paths for the appropriate libraries?


texts:
I've been browsing Aliexpress and eBay for decent Arduino enclusures, but I've found out they are even pricier then boards themselves.

Then I've realized that there are multiple firms that offer cheap laser cutting - I can buy 1 sq.m acrylic sheet and order cutting multiple parts of boxes at once.

Obviously I am not the first one who came up with this idea. Has anyone seen downloadable vector layouts I can use as something to start from? Thanks.


texts: How do software interfaces compare to hardware interfaces in therms of speed and reliability?

texts: The Arduino core includes numerous software interfaces mimicking the hardware interfaces provided by the chip and even extending beyond. My question is, if in a project I can either use software or hardware protocol, what would be the difference in stability, speed and versatility? Is there a reason why hardware interfaces are preferred? Because anyways the protocol is handled by the CPU or am I mistaking something?


texts: LCD stays blank when it is on and all wiring seems correct

texts:
So I have to do this project for school and it involves using a lcd display on tinkercad. I followed the wiring on this tutorial here: https://www.arduino.cc/en/Tutorial/HelloWorld. When I turn it on, the display is just blank even though I've tried to print.

Here is the code I have for this

#include <Servo.h>
#include <LiquidCrystal.h>

//TESTING
//ULTRASONIC WORKS
//SERVO WORKS
//BUZZER WORKS
//POTENTIOMETER WORKS

//Variables:

Servo pump;

LiquidCrystal lcd (12, 11, 5, 4, 3, 2);

bool blnPump = true;

long lngTimer = 0;
long lngDistance = 0;

int intPumpTime = 0;
int intLightLevel = 0;
int intCount = 0;

//soundDistance:to use the ultrasonic distance sensor and find the distance of an object above

//input
    //intSignalPin: to indicate which pin to use for the sensor
//output
    //lngDistance: the distance between the sensor and the object in cm

long soundDistance (int intSignalPin)
{
  long lngTime = 0;
  long lngDistance = 0;
  //gather the time is takes for the sound to travel back

  pinMode (intSignalPin, OUTPUT);
  digitalWrite (intSignalPin, LOW);
  delay (2);
  digitalWrite (intSignalPin, HIGH);
  delay (10);
  digitalWrite (intSignalPin, LOW);
  pinMode (intSignalPin, INPUT);
  lngTime = pulseIn (intSignalPin, HIGH);

  //Serial.println (lngTime);
  //calculating the distance

  lngDistance = lngTime * 0.01723;

  return lngDistance;
}

void setup()
{
  pinMode (A0,INPUT);
  pinMode (A1, INPUT);
  pinMode (9, OUTPUT);
  pinMode(13, INPUT);
  Serial.begin (9600);

  pump.attach (10);

  lcd.begin(16, 2);
  lcd.print ("hello");
}

void loop()
{
  //turning lcd off
  digitalWrite (8, LOW);

  lcd.print ("hello");
  //determining how many times the servo will pump
  intPumpTime = analogRead (A0);

  if (intPumpTime >= 0 && intPumpTime <= 341)
  {
    intPumpTime = 1;
  }

  else if (intPumpTime >= 342 && intPumpTime <= 683)
  {
    intPumpTime = 2;
  }

  else //if (intPumpTime >= 684 && intPumpTime <= 1023)
  {
    intPumpTime = 3;
  }

  //Pumping if theres a hand in range of 5cm to 25cm and pumping different amounts of sanitizer based on potentiometer, playing a tone if it does and turning the lcd on or off based on light level

  if (soundDistance (13) >= 5 && soundDistance (13) <= 25 && blnPump == true)
  {
    //turning lcd on or off
    intLightLevel = analogRead (A1);
    if (intLightLevel <= 300)
    {
      lcd.noDisplay();
    }

    else
    {
      lcd.display();
    }

    //playing tone to indicate its pumping
    tone (8, 500);
    delay (100);
    noTone (8);

    //lighting up led to indicate its pumping
    digitalWrite (9, HIGH);

    //pumping
    for (intCount = 0; intCount < intPumpTime; intCount++)
    {
        pump.write (90);
        delay (1000);
        pump.write (0);
        delay (1000);
    }

    //shutting off the led and turning the servo off
    digitalWrite (9, LOW);
    blnPump = false;

    lngTimer = millis();

    //waiting here to display hand scrubing time, no more sanitizer will be dispensed in this 20 seconds
    while (millis() - lngTimer < 20000)
    {

      if (millis() - lngTimer <= 1000)// && intLightLevel > 300)
      {
        lcd.clear();
        lcd.print ("19 seconds left");
      }

      else if (millis() - lngTimer > 4000 && millis() - lngTimer <= 5000)// && intLightLevel > 300)
      {
        //blnPump = true;
      }
    }

    //decide if to use LCD or not here
  }

  else
  {
    pump.write (0);
  }

  //Serial.println (soundDistance (13));
  //long lngTest = soundDistance (13);
}

Sorry for all the extra code, they're for the other parts. I think I have followed what needs to be followed with inputting the pin into the LiquidCrystal class, the begin method but it just doesn't print.


texts: Is there a thermal sensor with a distance of 10 meters for Arduino

texts: I am looking for a thermal sensor with a distance of 10 meters . In my plan , I would like to recognize objects based on the heat. for example car.


texts:
I've been struggling with writing a code for Arduino UNO so that I could use my phone and change the colour of the LED strip via terminal.

#include <FastLED.h>
#include <SoftwareSerial.h>

SoftwareSerial btSerial(2, 4); // RX, TX

#define NUM_LEDS 22
#define DATA_PIN 6
CRGB leds[NUM_LEDS];

void setup() {

  btSerial.begin(9600);
  btSerial.println("Connected to Arduino");
  FastLED.addLeds<WS2812, DATA_PIN>(leds, NUM_LEDS);
}

char a;

void loop()
{
    if (btSerial.available())
    {
      a= (char)btSerial.read();

      if(a=="b")
      {
        btSerial.println("Turning LED blue");
        leds[0] = CRGB::Blue; // Turns 1 LED to blue
        FastLED.show();
      }
    }
}

So basically I'd like to be able to change LED colours with my phone. If you enter "r", the LEDS turn red, if you enter "b", leds turn blue etc. Maybe even add some patterns. Brightness controller would be nice too to save some battery.

EDITED. Serial works.

#include <FastLED.h>
#include <SoftwareSerial.h>

SoftwareSerial btSerial(2, 4); // RX, TX

#define NUM_LEDS 22
#define DATA_PIN 6
CRGB leds[NUM_LEDS];

void setup() {
  Serial.begin(9600);
  btSerial.begin(9600);
  btSerial.println("Connected to Arduino");
  FastLED.addLeds<WS2812, DATA_PIN>(leds, NUM_LEDS);}

char a;

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

3.

#include <FastLED.h>
#include <SoftwareSerial.h>

SoftwareSerial btSerial(2, 4); // RX, TX

#define NUM_LEDS 22
#define DATA_PIN 6
CRGB leds[NUM_LEDS];

void setup() {
  Serial.begin(9600);
  btSerial.begin(9600);
  btSerial.println("Connected to Arduino");
  FastLED.addLeds<WS2812, DATA_PIN>(leds, NUM_LEDS);}

char a;

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

    if (a=='b'){
      btSerial.println("Turning LED blue");
      leds[0] = CRGB::Blue;
      FastLED.show();}

RECENT:

#include <FastLED.h>
#include <SoftwareSerial.h>

SoftwareSerial btSerial(2, 4); // RX, TX

#define NUM_LEDS 28
#define DATA_PIN 6
CRGB leds[NUM_LEDS];

void setup()
{
  Serial.begin(9600);
  btSerial.begin(9600);
  btSerial.println("Connected to Arduino");
  FastLED.addLeds<WS2812, DATA_PIN>(leds, NUM_LEDS);
}

char a;

void loop()
{
  if (btSerial.available())
  {
    a= (char)btSerial.read();

    if( a == 'b' )
    {
      btSerial.println("Sinine"); //All LEDs are blue
      fill_solid( leds, NUM_LEDS, CRGB::Blue);
      FastLED.show();
    }

    if( a == 'r' )
    {
      btSerial.println("Punane"); //All LEDs are red
      fill_solid( leds, NUM_LEDS, CRGB::Green);
      FastLED.show();
    }

    if( a == 'g' )
    {
      btSerial.println("Roheline"); //All LEDs are green
      fill_solid( leds, NUM_LEDS, CRGB::Red);
      FastLED.show();
    }

    if( a == 'y' )
    {
      btSerial.println("Sinine"); //All LEDs are yellow
      fill_solid( leds, NUM_LEDS, CRGB::Yellow);
      FastLED.show();
    }

    if( a == 'w' )
    {
      btSerial.println("Sinine"); //All LEDs are white
      fill_solid( leds, NUM_LEDS, CRGB::White);
      FastLED.show();
    }

    if( a == 'o' )
    {
      btSerial.println("Väljas"); //All LEDs are turned off
      fill_solid( leds, NUM_LEDS, CRGB::Black);
      FastLED.show();}

    if ( a == 'z' ) //1 blue LED from start to finish
    {
      int i= 2;
      while (i > 0)
      {
        for (int dot = 0; dot < NUM_LEDS; dot++)
        {
            leds[dot] = CRGB::Blue;
            FastLED.show();
            leds[dot] = CRGB::Black;
            delay(100);
        }
      }
    }

     if ( a == 'x' ) //1 red LED from start to finish
     {
      int i= 2;
      while (i > 0)
      {
        for (int dot = 0; dot < NUM_LEDS; dot++)
        {
            leds[dot] = CRGB::Green;
            FastLED.show();
            leds[dot] = CRGB::Black;
            delay(100);
        }
      }
     }
  }
}


texts: How to connect a thermal printer to an ESP32?

texts:
I want to attach my GOOJPRT Thermal Printer (I believe model QR701, communication RS232) to my ESP32 but I cannot seem to get them working.
I tried all the Adafruit Thermal Printer library examples but get the same error each and every time:
"Error compiling for board ESP32 Dev Module."

I guess the libraries are not meant for the ESP32.
I also tried the "Thermal Printer Library" by Larry Bank (which should be compatible with the ESP32 according to its github docs) but there I cannot figure out how to connect the wires of thermal printer to the ESP32 correctly.
Of course, I do not ask for a specific solution, I am just looking for someone to point me in the right direction!

This is an image of the exact thermal printer I have
Full error message from Adafruit Thermal Printer examples:
C:\Users\Thomas\Documents\Arduino\libraries\SoftwareSerial-master\SoftwareSerial.cpp:41:27: fatal error: avr/interrupt.h: No such file or directory
compilation terminated.
Multiple libraries were found for "Adafruit_Thermal.h"
 Used: C:\Users\Thomas\Documents\Arduino\libraries\Adafruit_Thermal_Printer_Library
 Not used: C:\Users\Thomas\Documents\Arduino\libraries\Adafruit-Thermal-Printer-Library-master
Multiple libraries were found for "SoftwareSerial.h"
 Used: C:\Users\Thomas\Documents\Arduino\libraries\SoftwareSerial-master
 Not used: C:\Users\Thomas\Documents\Arduino\libraries\EspSoftwareSerial
exit status 1
Error compiling for board ESP32 Dev Module

Second error message from Adafruit Thermal Printer example after removing the manually installed SoftwareSerial.h:
A_printertest:21:28: fatal error: SoftwareSerial.h: No such file or directory
Multiple libraries were found for "Adafruit_Thermal.h"
compilation terminated.
 Used: C:\Users\Thomas\Documents\Arduino\libraries\Adafruit_Thermal_Printer_Library
 Not used: C:\Users\Thomas\Documents\Arduino\libraries\Adafruit-Thermal-Printer-Library-master
exit status 1
SoftwareSerial.h: No such file or directory


texts: I have a diagram of my Arduino circuit. How do get it ready for PCB manufacture?

texts:
For my engineering class, I am building a digital scale. My team has assembled the prototype out of:

Arduino Uno
Hx711 amplifier module
1 kg load cell
2 push buttons
A 4 digit 7-segment display module we found online, but we don't know its specific name
HC-05 Bluetooth module, no specific manufacturer
Lilypad switch CR2032 battery module
DC-DC step up to 5V boost converter module

Our prototype works. Well, sort of (we're still trying to work out the boost converter and c2032 to work). We have diagrammed how each module connects to each other on a piece of paper. However, we want to properly diagram this in a way so we can create a PCB for it.

I have tried the Eagle and Fritzing programs. I am very inexperienced with them. I am not able to find the HC-05 and LED display .sch or .fzz files online for this, so I have came to a halt. I am not sure how each of these modules are actually wired together either.

What can I do next?


texts:
If I have an interrupt attached to two pins and the handler of the first is still executing when the second interrupt fires, does it:
a) queue the second interrupt,
b) ignore the second interrupt (missing it altogether), or
c) pause processing of the first interrupt to execute the second?
I am writing code that logs the exact time the interrupt occurs. Quite lightweight, but have three pins and am logging the rise and fall of each, so there is the potential for collisions. If a) then the second interrupt timestamp will be late, b) there is no timestamp for the later interrupt or c) the timing of the first and second interrupts will be ambiguous.
b) is the worst case, the other two are manageable.


texts: SRF04 Ultrasonic sensor - inaccurate readings

texts:
I have an Arduino Uno linked up to an SRF04 ultrasonic sensor. I'm using the library from here: https://code.google.com/p/srf04-library/

I'm then using the basic script "Centimeter" that comes in the examples. This gives me a reading, but it seems to be ~20-25% inaccurate. When it reads 100cm, the distance is actually nearer 80cm.

I've replaced the SRF04 with another, and the same issue occurs. Additionally, it seems when it reads out of range (or even on surfaces that give an uneven "bounce"), I get very random figures (e.g. -5cm).

Has anyone experienced something similar?


texts:
I am using 74hc595 in several projects where I need more I/O and always worked fine using arduino pro mini or arduino mega. Now I connected same 2 of 74hc595 to an esp32 and does not work.
Is there any special things to do for esp32?

Wiring is exactly the same like here https://www.arduino.cc/en/tutorial/ShiftOut on chapter 2 (Connect the 2 registers.). If I use this with an arduino mega on pins 10,9,8 (see commented in code) is working perfect.

Then I replace arduino mega with esp32 and using pins 23,18,5 and does nothing. I get in serial monitor on/off prints but nothing changes to the relays.

Code

int SER_Pin = 23;//10; //pin 14 on 75hc595 //data pin
int RCLK_Pin = 18;//9; //pin 12  //latch
int SRCLK_Pin = 5;//8; //pin 11  //clock

#define number_of_74hc595s 2

#define numOfRegisterPins number_of_74hc595s * 8

boolean registers[numOfRegisterPins];

void setup() {
  Serial.begin(9600);
  pinMode(SER_Pin, OUTPUT);
  pinMode(RCLK_Pin, OUTPUT);
  pinMode(SRCLK_Pin, OUTPUT);

  clearRegisters();
  writeRegisters();
}

void clearRegisters() {

  for (int i = numOfRegisterPins -1; i >= 0; i--) {
    registers[i] =HIGH;
  }
}

//Set and display registers
//Only call after all values are set how you would like
void writeRegisters() {
   digitalWrite(RCLK_Pin, LOW);

   for (int i = numOfRegisterPins -1; i >= 0; i--) {
      digitalWrite(SRCLK_Pin, LOW);
      int val = registers[i];

      digitalWrite(SER_Pin, val);
      digitalWrite(SRCLK_Pin, HIGH);
}
  digitalWrite(RCLK_Pin, HIGH);

}

//set an individual pin high or low
void setRegisterPin (int index, int value) {
  registers[index] = value;
}

void c_on() {
  Serial.println("on");
  setRegisterPin(13,LOW);
  writeRegisters();
  delay(50);
}

void c_off() {
  Serial.println("off");
  setRegisterPin(13,HIGH);
  writeRegisters();
  delay(50);
}

void loop() {

c_on();
delay(1000);
c_off();
delay(1000);

}

Is there any special thing to do for using esp32?

Thank you very much


texts: Why is my Serial port not printing the right output?

texts:
am working with and Arduino nano and according to this, I can append strings to numbers by doing: stringThree =  stringOne + 123; but
when I do:

sensorValue = analogRead(A0);
String x1 = "{\"Volt\":"+sensorValue;
Serial.print(x1);

I get this unwanted output!

  =gëÙrïË:_³ß»þ™¹Æ3+Ç#ÿ¼¿.Õ[Oû/g¯>ïÿ1þ†lú0

but doing this it works fine.

sensorValue = analogRead(A0);
String x1 = "{\"Volt\":";
x1 += sensorValue;
Serial.print(x1);

  "Volt":646

why?


texts: HD44780 display incorrectly black-on-blue instead of white-on-blue

texts:
I have a generic HD44780 compatible 16x2 LCD display, with an already soldered on PCF8574 module. Its backlight is blue, and the characters are supposed to be white (on blue).

It is connected to a generic "Lolin" ESP8266 module which is working fine and is not related to the problem, I hope.

Using the LiquidCrystal_I2C library available at https://github.com/lucasmaziero/LiquidCrystal_I2C, I uploaded the simple "Hello, World" sketch provided, and it works. Used the most current libraries and Arduino IDE as of 2019-03-20.

However, the text displayed is a very dim black-on-blue instead of a bright white-on-blue.

I do not have any clue on why it happens and how to fix it (and that's my question).

What I know is that if I somehow "glitch" the display (for example by disconnecting and reconnecting the power lead) it will sometimes display gibberish, but in a very clear white-on-blue, so I know the LCD hardware is not defective per se.

I also tried a few other libraries to the same effect: LiquidCrystal_PCF8574 and LiquidCrystal_I2C (the version available directly from the Arduino IDE, source at https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library)

Below, the example sketch used to generate the problem. Be aware it is for the first LiquidCrystal_I2C library I referred above, but with changes, works with the others I tried.

#include <LiquidCrystal_I2C.h>

// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
  // initialize the LCD
  lcd.begin(); // Init with pin default ESP8266 or ARDUINO
  // lcd.begin(0, 2); //ESP8266-01 I2C with pin 0-SDA 2-SCL
  // Turn on the blacklight and print a message.
  lcd.backlight();
  lcd.setCursor(0, 0);

#if defined(ESP8266)
  lcd.print("ESP8266");
#else
  lcd.print("ARDUINO");
#endif

  lcd.setCursor(0, 1);
  lcd.print("Hello, world!");
}

void loop()
{
  // Do nothing here...
}

And a photo of the anomalous display. Turning the constrast potentiometer does not help.


texts:
I have a question about capacitors in DC (digital) circuits. The picture below is an edited schematic of the Arduino Uno R3.

The DTR line is connected to the reset input of the Atmega328 by a 0.1uF capacitor.

The capacitor is needed to initiate a load to the atmega flash memory through the USB -> UART. Why is this the case, everything I have been taught says "Capacitors block DC and let AC through"

All I see is something that can let AC noise through to the Arduino reset? I know its needed, I tested it. But why its needed, how it fulfils that function I have no idea.

Please help


texts: Leonardo clone being recognized by Windows as a broken Linino One - wtf?

texts:
I'm running a Velleman VMA103, which is advertised as a clone of the Leonardo. Both use the 32u4 chip, and the pinout is exactly the same. However, when I plug it in, the drivers do something weird.

For about 5 seconds after pressing reset, the Arduino IDE will recognize the Leonardo on COM9, and the Windows device manager will show "Arduino Leonardo bootloader" then, the COM9 device will disappear and a device will be shown in the Other Devices tab as a LININO ONE, with no drivers installed. How is this possible?

I've reinstalled the IDE, no help there.


texts: Data Structures and Color Data Types in FastLED

texts:
So i'm doing something wrong but i don't exactly know what and hope somebody can give me a quick pointer:

I declared a starting color for my fastled animation:

CHSV startcolor(100, 255, 255);

and then a data structure

typedef struct {

int currentBrightness = 0;

int targetBrightness = 0;

int updown;

CHSV color = startcolor;

} blinkblink, *pblinkblink;

So basically my idea is to have every LED be represented with this data structure to control brightness within an anmation. However if i now set

CRGB leds[NUM_LEDS];

and do something like

for (int i = 0; i < sizeof(myLeds); i++) {

leds[i] = myLeds[i].color;

}

FastLED.show();

nothing happens. I'm pretty sure, that this is because i'm somehow not understanding the data type thing. What am i doing wrong?


texts: tty doesn't list ttyUSB0 so arduino doesn't list serial ports

texts:
Okay so lsusb gives
Bus 002 Device 019: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter

dmesg|grep 'ttyUSB' gives

[63723.589107] usb 2-1: ch341-uart converter now attached to ttyUSB0

but tty lists only /dev/pts/0 although in /dev there is a ttyUSB0 file (or whatever it is because vim says its not a file)

I can use cu -l /dev/ttyUSB0 -s 9600 and transmit to arduino nano as the rx LED blinks. On starting arduino I get the "java.lang.NullPointerException thrown while loading gnu.io.RXTXCommDriver" error.

System: Linux Mint 19.1 Tessa (64 bit)


texts: Make Sure Digital pin is high before Serial.write()

texts:
I have the following code for a TTL to RS-485 Adapter Module

[...code]
digitalWrite(DE_PIN, HIGH); //directional control for adapter
Serial2.write(Message, Size);
Serial2.flush();
digitalWrite(DE_PIN, LOW);  // Set To Recieve
Serial2_reading_foo();
[code...]

I've noticed that DE_PIN does not seem to go High fast enough before Serial2.write() executes I confirmed this by adding a small delay(ms) which made the code function perfectly.

digitalWrite(DE_PIN, HIGH);
delay(100);
Serial2.write(Message, Size);
Serial2.flush();
digitalWrite(DE_PIN, LOW);  // Set To Recieve
delay(100);
Serial2_reading_foo();

Unfortunately, there's pretty much universal agreement that you shouldn't ever use delay() in programming. Plus doing any kind of wait function here seems to be insensitive to the real problem. Is there a better way to make sure that DE_PIN==HIGH before the Serial2.write() Function begins?


texts: I have been thinking about wireless sensor networks and home automation for a long time. I need a single MCU with an RF resever. It is best if the pin8 is in a small package. Can anyone help me?


texts: Arduino Due - using built in ADC as a DSO causes issues at high frequencies (kHz)

texts:
I am trying to use the inbuilt ADC of the Arduino Due to measure voltage signals. The frequency range I'm interested in measuring is  up to about 30 kHz.But I'm observing a strong capacitor behaviour as I increase the frequency ( from 10kHz onwards this is quite visible).

This is most visible when measuring a square wave. When I get close to 30 kHz the signal looks exactly like the text book capacitor charge/discharge wave and nothing like a square wave. Even at around 15 kHz, the square wave looks more like a sine wave/ ramp signal than a square wave.

Based on the behaviour my guess is that a capacitor in the Arduino Due ADC is causing this (as  the frequency increases, the capacitor cannot charge/discharge fast enough). But I'm not sure whether I'm correct about this.
Even if I'm correct, how can I fix this?

Any help would be much appreciated.

Thanks.

I don't have screenshots for the behaviour for a range of frequencies, but I will attach a hand drawing of what it looks like.

Also NOTE that As the frequency increases, the amplitude of the observed wave decreases ( I couldn't show this in my drawing). Think this again links back to the capacitor charge/discharge speed behaviour.

My Vin circuit : I tested by adding a voltage follower at the right most end(not shown on the schematic), but that made no difference.


texts:
The example program is from here: https://www.arduino.cc/en/Reference/attachInterrupt

When I paste in the code and run it, the LED is on all the time (It's supposed to blink):

const byte ledPin = 13;
const byte interruptPin = 2;
volatile byte state = LOW;

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), blink, CHANGE);
}

void loop() {
  digitalWrite(ledPin, state);
}

void blink() {
  state = !state;
}

This is my setup:


texts:
I'm having issues with a DS3231 RTC connected to an ESP8266. I can write to it to set the time (Wire.write returns 1), but anytime I try to read from it, Wire.requestFrom always returns 0.
I've tested my circuit with another DS3231 and it works correctly. So I guess it's faulty hardware and I can throw it to the bin. Or is there something I can do with it?
Update:
In fact, endTransmission returns 2, which if I understand well means the address is not found, so this is not a read issue. I guess that means it's dead.


texts: Can't make my stepper motor run clockwise and counterclockwise with AccelStepper Library

texts:
I'm relatively new to arduino thus need your help to figure out why my stepper motor doesn't rotate clockwise and counterclockwise. All I could do was to make it rotate only in one direction.

Here is my code:

#include <AccelStepper.h>

int pos=16000;
AccelStepper stepper(1,4,5);

void setup() {
stepper.moveTo(pos);
stepper.setMaxSpeed(6400);
stepper.setSpeed(6400);
}

void loop() {
if (stepper.distanceToGo() == 0)
{
  stepper.setCurrentPosition(0);
  pos = -pos;
  stepper.moveTo(pos);
  stepper.setSpeed(6400);
}
   stepper.runSpeed();
}

Will appreciate any help you can give me :)


texts: Why does the following code not cause the led's to flash but rather stay on continuously

texts:
int timer = 1000;
int thispin = 5;

void setup() {
  for (int thispin = 5; thispin < 8; thispin++)
    pinMode(thispin, OUTPUT);
}

void loop() {
  for (int thispin = 5; thispin < 8; thispin++)
    digitalWrite(thispin, HIGH);

  delay(timer);
  digitalWrite(thispin, LOW);

  for (int thispin = 7; thispin = 5; thispin--)
    digitalWrite(thispin, HIGH);

  delay(timer);
  digitalWrite(thispin, LOW);
}

I have the above code. I thought that how it was written would cause the led's to flash but they all stay on continuously. Could anybody help to explain what it is i have done wrong?
I am very new to this and I'm just fiddling basically trying to learn.
Thank you!


texts: Uno WiFi Dev Ed - Example Sketch with UnoWiFiDevEdSerial1.h library by Juraj errors on compile

texts:
Example sketch does not compile, error message
'static void WiFiClass::init()' is private within this context
IDE 1.8.13
Board Uno WiFi Dev Ed.
I have been using this board for several years uploading to Thingspeak using UnoWiFiDevEd.h using Ciao.
Now I am trying to use the UnoWiFiDevEdSerial1.h library but I can't even compile the example code below. Any suggestions?
/*
WiFiLink example: WebClient
https://github.com/jandrassy/arduino-library-wifilink
*/
#include <UnoWiFiDevEdSerial1.h>
#include <WiFiLink.h>
char server[] = "arduino.cc";
boolean sendRequest = true;
WiFiClient client;
void setup() {
Serial.begin(115200);
Serial1.begin(115200);
Serial1.resetESP();
delay(3000); //wait while WiFiLink firmware connects to WiFi with Web Panel settings
WiFi.init(&Serial1);
while (WiFi.status() != WL_CONNECTED) {
delay(10);
}
Serial.println("You're connected to the network");
printWifiStatus();
Serial.println();
}
void loop() {
if (sendRequest) {
/Users/mack/Documents/Arduino/UnoWiFiLink_DevEd/UnoWiFiLink_DevEd.ino: In function 'void setup()':
UnoWiFiLink_DevEd:21:8: error: 'static void WiFiClass::init()' is private within this context
WiFi.init(&Serial1);
^~~~
In file included from /Users/mack/Documents/Arduino/UnoWiFiLink_DevEd/UnoWiFiLink_DevEd.ino:7:0:
/Users/mack/Documents/Arduino/libraries/WiFi_Link/src/WiFiLink.h:44:17: note: declared private here
static void init();
^~~~
UnoWiFiLink_DevEd:21:21: error: no matching function for call to 'WiFiClass::init(UnoWiFiDevEdSerial1*)'
WiFi.init(&Serial1);
^
In file included from /Users/mack/Documents/Arduino/UnoWiFiLink_DevEd/UnoWiFiLink_DevEd.ino:7:0:
/Users/mack/Documents/Arduino/libraries/WiFi_Link/src/WiFiLink.h:44:17: note: candidate: static void WiFiClass::init()
static void init();
^~~~
/Users/mack/Documents/Arduino/libraries/WiFi_Link/src/WiFiLink.h:44:17: note:   candidate expects 0 arguments, 1 provided
Using library Uno_WiFi_Developer_Edition_Serial1 at version 1.0.4 in folder: /Users/mack/Documents/Arduino/libraries/Uno_WiFi_Developer_Edition_Serial1
Using library WiFi_Link at version 1.0.1 in folder: /Users/mack/Documents/Arduino/libraries/WiFi_Link
Using library Wire at version 1.0 in folder: /private/var/folders/5v/dc3kh_4136g2j560dgjg3vww0000gn/T/AppTranslocation/E151A1AA-2F37-45B4-9B3C-A69070247D9C/d/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire
exit status 1
'static void WiFiClass::init()' is private within this context