texts: Which IDE should I use to write Pythonic-programs for Arduino

texts: I'm doing my first baby-steps to build tools using Arduino. I'd like to know if there is a way to write python scripts to build programs for Arduino. Most of IDEs I found are non-supported IDEs. Is there any "recommended" IDEs that I should use.


texts: Can MP3 be sent to SPI of Adafruit Music Maker Arduino shield instead of from its SD card?

texts:
Can uncompressed MP3 audio data be sent from Arduino board, by SPI, to Adafruit Music Maker shield instead of from the SD card on the Music Maker?

Instead of using SD card on Music Maker board, I want to send the compressed MP3 data from a Particle Photon board on the Particle shield shield, by SPI, to the VS1053B codec chip on Music Maker board, and then to amplifier for speakers.

Particle Shield Shield is attached to Particle Photon board, which has STM32F205RGY6 120Mhz ARM Cortex M3.

Particle Photon board uses its WiFi to receive uncompressed MP3.


texts:
Apologies for the simple question, I really couldn’t find any help online with this as when I kept searching, the results had lights that had way too much voltage compared to what I need.

So I have a simple light decoration that requires around 3v and comes with a battery pack to power it (2AA batteries) and I took it apart and was able to connect them via a breadboard to test if is all working.

How do incorporate the Arduino into it so that I can switch the lights on through the Arduino? A lot of the small voltage videos I saw were just simple connecting 1 LED through a digital pin but that’s not enough current for the lights I have and I’m not experienced enough to find myself a solution so help would be greatly appreciated.

For little more info, the 3.3v and 5v pins my Arduino (uno) are already taken up.

Also, I’ll be turning the lights on and off with an IR Remote which I’ve already programmed to a servo that’s powered through the USB supply (5v) and the IR Sensor is connected to the 3.3V.

Sorry if the question was badly worded.


texts:
I need to reduce the SPI clock speed of the Arduino Due down to about 100 kHz. Unfortunately my hardware doesn't support higher speeds.

With the current maximum divider of 255, I can only reach a speed of still 320 kHz (SPI.setClockDivider(10, 255);).

Of course I could use a software SPI, but I'm still interested in using the build-in hardware. A possible solution could be to lower the overall clock speed of 84 MHz. Any idea how to achieve this?


texts: Why doesn't the Micro OLED library compile on my DUE?

texts:
I have an Arduino DUE and just got a Micro OLED display from SparkFun.

Using their library, when I try to compile I get the error below.  Other example code works just fine and I've programmed this thing a million times with my code.  So it's clearly in the SparkFun code.

Here is the SparkFun tutorial page with a description of the product:

https://learn.sparkfun.com/tutorials/micro-oled-breakout-hookup-guide?_ga=1.19136059.2055231411.1404437767

Here is the library I am using:

https://github.com/sparkfun/Micro_OLED_Breakout/tree/master/Firmware/Arduino/libraries/SFE_MicroOLED

Here is the error I get:

Build options changed, rebuilding all

/Applications/Arduino.app/Contents/Resources/Java/libraries/SFE_MicroOLED/hardware.cpp: In member function 'void MicroOLED::spiSetup()':

/Applications/Arduino.app/Contents/Resources/Java/libraries/SFE_MicroOLED/hardware.cpp:46:10: error: cannot convert 'RwReg* {aka volatile long unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in assignment
    ssport  = portOutputRegister(digitalPinToPort(csPin));
            ^
  /Applications/Arduino.app/Contents/Resources/Java/libraries/SFE_MicroOLED/hardware.cpp:48:51: error: 'portModeRegister' was not declared in this scope
    ssreg  = portModeRegister(digitalPinToPort(csPin));
                                                     ^
  /Applications/Arduino.app/Contents/Resources/Java/libraries/SFE_MicroOLED/hardware.cpp: In member function 'void MicroOLED::i2cSetup()':
  /Applications/Arduino.app/Contents/Resources/Java/libraries/SFE_MicroOLED/hardware.cpp:84:2: error: 'TWBR' was not declared in this scope
    TWBR = ((F_CPU / I2C_FREQ) - 16) / 2;
    ^
  /Applications/Arduino.app/Contents/Resources/Java/libraries/SFE_MicroOLED/hardware.cpp: In member function 'void MicroOLED::parallelSetup()':
  /Applications/Arduino.app/Contents/Resources/Java/libraries/SFE_MicroOLED/hardware.cpp:109:10: error: cannot convert 'RwReg* {aka volatile long unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in assignment
    ssport  = portOutputRegister(digitalPinToPort(csPin));
            ^
  /Applications/Arduino.app/Contents/Resources/Java/libraries/SFE_MicroOLED/hardware.cpp:111:51: error: 'portModeRegister' was not declared in this scope
    ssreg  = portModeRegister(digitalPinToPort(csPin));
                                                     ^
  /Applications/Arduino.app/Contents/Resources/Java/libraries/SFE_MicroOLED/hardware.cpp:114:10: error: cannot convert 'RwReg* {aka volatile long unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in assignment
    wrport  = portOutputRegister(digitalPinToPort(wrPin));
            ^

/Applications/Arduino.app/Contents/Resources/Java/libraries/SFE_MicroOLED/hardware.cpp:119:10: error: cannot convert 'RwReg* {aka volatile long unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in assignment
    rdport  = portOutputRegister(digitalPinToPort(rdPin));
            ^
  Error compiling.


texts: Measure lipo voltage while powering arduino

texts:
I have a arduino pro micro 5V that I want to power with a 3.7V lipo. I also have a charging module to charge the lipo.
(https://www.banggood.com/nl/TP4056-1A-Lipo-Battery-Charging-Board-Charger-Module-Mini-USB-Interface-p-1027027.html?rmmds=myorder&cur_warehouse=CN).

I want to measure the battery level of the lipo.

Should I use a step up module to 5V?

How can I measure it? I read that you can't just use analogRead because the lipo itself is the reference.

Thanks in advance!


texts: Machine installed with arduino suddenly turns on when usb is unplugged

texts:
Why is my machine suddenly turns ON when I unplugged the USB on my computer? Does it have connection on the auto reset feature of my arduino board?

String input = "";

void setup(){

  Serial.begin(9600);   // Sets up communication with the serial port

  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  pinMode(8,OUTPUT);
  pinMode(9,OUTPUT);
  pinMode(10,OUTPUT);
  pinMode(11,OUTPUT);   // for start of program operation

  digitalWrite(6,HIGH);
  digitalWrite(7,HIGH);
  digitalWrite(8,HIGH);
  digitalWrite(9,HIGH);
  digitalWrite(10,HIGH);

  digitalWrite(11,LOW);

}

void loop(){

  int recipe;
  //Serial.print("Enter recipe number: ");

  while(Serial.available()==0){    // Waits for data from serial port
  }

  while(Serial.available() > 0){
    int data = Serial.read();
      // convert the incoming byte to a char
      // and add it to the string
    input += (char)data;

    recipe = input.toInt()+'0';    //recipe=0 if not a digit
    if(recipe == '0')
      recipe = data;

    if(data == '\n'){
      //Serial.print("Recipe: ");
      //Serial.println(recipe);
      //Serial.print("String: ");
      //Serial.println(input);
      input = "";
    }
  }

  if(recipe == 's'){
    digitalWrite(11,HIGH);
    delay(1000);
    digitalWrite(11,LOW);

    digitalWrite(6,LOW);
    digitalWrite(7,LOW);
    digitalWrite(8,LOW);
    digitalWrite(9,LOW);
    digitalWrite(10,LOW);
  }

  else if(recipe>'0' && recipe<'32'){

    recipe = recipe-'0';
    char binary[7] = {0};   // This is where the binary representation will be stored
    recipe += 32; // Adding 32 so that there will always be 6 digits in the string
    itoa(recipe,binary,2);  // Convert recipe to a string of base 2 and save it in array 'binary'
    char* signals = binary + 1; // Get rid of the most significant digit to get the 5 bits

  //Serial.print(signals);  // Print out the signals in binary

    int i;
    for(i=0; i<5; i++){
      if(signals[i] == '0')
        signals[i] = '1';
      else
        signals[i] = '0';
      digitalWrite(i+6, signals[i]-'0');    // write to pin; converts the bit of the string to HIGH or LOW
      //Serial.print(signals[i]);
    }

  }
  else
    loop();

}


texts:
I am newbie, I am afraid of doing harm and getting a burned-out Beagle Bone Black. I have soldered this SparkFun Logic Level Converter - Bi-Directional.

I have several questions:

How can I check if my converter works correctly without connecting it to any board or at least only to an Arduino?
How should I connect all my schematic from bbb to converter and then to an Arduino. I have a bi-directional converter, BTW. Can someone draw a simple picture of how to connect?

I would be grateful for any help.


texts: Receiving multiple bytes from an RPi using the i2c protocol

texts:
Trying to send bytes from an RPi as a master to an Arduino as a slave.

The send uses the write_byte(addr, value) function and seems to be working perfectly.

The Arduino however has issues with separating the received bytes into individual values.

I want to use the RPi to dictate when data is sent so I just need the Arduino to listen on wire.available.

Using the wire.onreceive event function I can have a separate function which has:

int var = wire.read()
Serial.print(var)   //for monitoring read byte

This code shows that the bytes being received are the right ones however, when I try something like

ledData[0] = wire.read();
ledData[1] = wire.read();
ledData[1] = wire.read();
etc
etc
...

This returns wildly different values as if the bytes are getting mixed up. Can anyone help me to specifically intake 16 bytes into array indexes for use in the main loop function.


texts:
I have 2 arduino Unos where each one works properly on its own.

I try to make them communicate with each other using serial communication (TX-RX ports).

When I try to upload my code to them I get this error :

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00
An error occurred while uploading the sketch

what should i do to fix it ? (MY os is windows 10) thanks


texts: Designing Class Based Code on ESP32-8266

texts:
I have some questions about modular embedded systems codes and its usage.
I am building an IoT Systems with esp32 now. To learn professional approaches for embedded systems, I have split codes to libraries. My aim at this architecture, create generic libraries for my colleagues and learn something about modular embedded systems programming.
I created .cpp files and .h files for Communication layers, sensor measurement layers, connections and database(EEPROM) layers etc.
I have some high level programming lang. experiences(C#,Python) so I want  use OOP on my codes.  So I created cpp classes on my codes. In C,  I wrote .c and .h files too.
My approach may be wrong for this situation. I have no professional embedded systems experiences . My main field is Automation Systems. I tried implement this kind of High level approaches on PLC's too.
In this situation  what are differences betweeb cpp classes and .c sources? What are pros and cons? If you have suggestions and documents-tutorials, can you share?
Thanks.


texts: How to pass non-static class member to callback?

texts:
I am using the arduinoWebSockets library in my own Arduino library. I'm having trouble with trying to assign a class member as the websocket library onEvent callback function.

MyClass.cpp:

#include <WebSocketsClient.h>
#include "Arduino.h"
#include "MyClass.h"

void MyClass::connect(String host, int port) {
  webSocket.begin(host, port, "/");
  webSocket.setReconnectInterval(5000);

  // tried all these variations
  // webSocket.onEvent(incomingEventHandler);
  // webSocket.onEvent(MyClass::incomingEventHandler);
  webSocket.onEvent(this->incomingEventHandler);
}

void MyClass::loop() {
  webSocket.loop();
}

void MyClass::incomingEventHandler(WStype_t type, uint8_t *payload, size_t length) {
  // do stuff with incoming data
  // need to access other member functions and class variables
}

MyClass.h:

#ifndef MyClass_h
#define MyClass_h

#include <WebSocketsClient.h>
#include "Arduino.h"

class MyClass {
  public:
    void connect(String host, int port);
    void loop();
    void incomingEventHandler(WStype_t type, uint8_t *payload, size_t length);
  private:
    WebSocketsClient webSocket;
};

#endif

The error returned is:

  sketch/MyClass.cpp: In member function 'void MyClass::connect(String,
  int)': MyClass.cpp:14:47: error: no matching function for call to
  'WebSocketsClient::onEvent()'
  webSocket.onEvent(this->incomingEventHandler);

From what I understand it seems like I need to create a pointer to the class member, I have tried a few different ways, this one seemed the most promising, but still failed:

typedef void (MyClass::*MyClassMemFn)(WStype_t type, uint8_t *payload, size_t length);

void MyClass::connect(String host, int port) {
  webSocket.begin(host, port, "/");
  webSocket.setReconnectInterval(5000);

  MyClassMemFn onEventCallback = &MyClass::incomingEventHandler;
  webSocket.onEvent(MyClassMemFn onEventCallback);
}

The above returns this error:

  sketch/MyClass.cpp: In member function 'void MyClass::connect(String,
  int)': MyClass.cpp:15:34: error: expected primary-expression before
  'onEventCallback'    webSocket.onEvent(MyClassMemFn onEventCallback);

I have also tried to use std::bind:

void MyClass::connect(String host, int port) {
  webSocket.begin(host, port, "/");
  webSocket.setReconnectInterval(5000);

  webSocket.onEvent(std::bind(&MyClass::incomingEventHandler, this));
}

Error:

  sketch/MyClass.cpp: In member function 'void MyClass::connect(String,
  int)': MyClass.cpp:12:47: error: no matching function for call to
  'WebSocketsClient::onEvent()'
  webSocket.onEvent(this->incomingEventHandler);

If I move the incomingEventHandler function outside the class definition, it works as expected, however then I can't call other class members or access class properties in the same scope.

In arduino c++ how can I pass non-static class member properties as a callback? Is there a better way to approach this?


texts: Arduino Uno not working as usb HID interface

texts:
I have an arduino uno rev 3 and it works perfectly fine. I the OS I am using is Kali Linux 2.0 and you can upload everything as normal to the arduino.
I am following this tutorial:Arduino Uno as usb HID interface device
to use my arduino uno r3 as a hid device. After I upload the

Arduino-keyboard-0.3.hex

file, I plug cycle the board and I try uploading the example blink program. It always says:

Serial Port /dev/ttyACM0 not found.
Retry the upload with another serial port?
/dev/ttyS0

the /dev/ttyACM0 is my default arduino port and /dev/ttyS0 is one of my usb devices that is plugged in. Neverless, I tried uploading but it says board isnt responding. Can someone help me with this please?


texts: How to remember variable values after rebooting an Arduino Uno R3 board?

texts:
Is there any way to store the values of necessary variables somewhere (may be in a file that gets updated by the program at various events), which can be read back when program starts after rebooting the Arduino board?

I am trying to control my AC appliances using IR remote control. Where I want Arduino to remember what was on and what was off in my room after a power failure.

Using EEPROM looks like a fairly good solution, though it has a limitation of 100,000 writes which is making me try to find another way out.

Using an external EEPROM which doesn't have that limitation or its fairly big, is a really good idea I got from fuenfundachtzig, thanks for this great idea. But I don't know how to implement this in my project. Any resource to gather knowledge on using external EEPROM, will be much appreciated.

Thank you all...


texts: WifiClient and aREST on esp32 - loop until new instructions recieved?

texts:
I've created a simple sketch for an esp32 that hosts a REST API that can be accessed via HTTP. Based on the instructions received from the client, the esp32 controls some neopixels with some various animations I've written.

Everything worked as expected until I got to an animation that runs in a while loop. The loop breaks when a new client is detected so that the light can switch functions. However, when the new client is detected, the client seems to be discarded or consumed, and i just end up back in the loop() function until I make a second HTTP request, then the changes to show up.

I'm sure it's something obvious, but what have I done wrong?

Code:

#include "WiFi.h"
#include "FastLED.h"
#include "aREST.h"
#include "ArduinoJson.h"

#define NUM_LEDS 64
#define DATA_PIN 18

CRGB leds[NUM_LEDS];
int LED_COUNT = 64;
int MAX_BRIGHTNESS = 200;

const char* ssid = "wifi";
const char* password = "password";
aREST rest = aREST();
WiFiServer server(80);
WiFiClient client;

void setup() {
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, LED_COUNT);
  flashAll(CRGB::Black);
  // Bind urls to the handling functions
  rest.function("random-strobe", randomStrobe);
  rest.function("solid-color", solidColor);
  rest.function("reset", reset);

  // Connect to WiFi and wait until we're connected to continue
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    flashAll(CRGB::Cyan);
    delay(500);
    flashAll(CRGB::Black);
    delay(500);
  }
  server.begin();
  flashAll(CRGB::Green);
  delay(2000);
  flashAll(CRGB::Black);
}

void loop() {
  if (checkForTask()) {
    rest.handle(client);
  }
}

boolean checkForTask() {
  // I have tried making this reassignment conditional
  // when the global 'client' is false, but it did not help
  //if (!client) { client = server.available(); }
  client = server.available();
  if (client) {
    return true;
  }
  return false;
}

int randomStrobe(String params){
  client.println("HTTP/1.1 200 OK");
  client.println("Content-type:application/json");
  client.println();
  client.stop();
  StaticJsonDocument<200> jsonDoc;
  Serial.println(params);
  Serial.println("params recieved. parsing...");
  auto error = deserializeJson(jsonDoc, params);
  if (!error) {
    // some setup stuff
    while(!checkForTask()){
      // do stuff in here
    }
    return 0;
  }
}


texts: I want to control a single DC motor with an Arduino. Why would I use an Arduino motor shield as opposed to an H-circuit and a MOSFET?

texts: I'm new to electronics. I'm trying to build something that will involve controlling the direction of rotation of a DC motor. A lot of online resources seem to recommend using an Arduino motor shield. But why shouldn't I just use some combination of an H-circuit (to control the direction of rotation) and a MOSFET (to switch power to the motor on and off)?


texts:
I am building a small electronic project, and I am incorporating module nodeMcU 8266 in a box.
I would like to know which pins are for "flash" and for "reset"
I know there are 2 buttons on the module for those 2 actions, but I would like to add 2 external buttons for those function on the case of the project, like that I will not need to open the box everytime. I looked on the net, and I guess that for "reset", I must connect to pin "Rst" and pin "Grd", I mean those 2 pin must be shorted, but I prefere to get confirmation before to go further.
And also for the "flash", what are both pins that I must connect the external push button to, to replicate the button present on the module itself.

Also I would like to connect an external LED to the module, following the state of the blue SMD led.
The thing is that there is an SMD blue led on the module, I want to know what are the 2 pins that are similar to the contacts of the blue SMD led.
I want the External LED that I plan to incorporate to the case of the project, to light up when the SMD blue led on the module is on, and when the led to be off when the blue SMD led is off. I want that both follow the same state.
Blue SMD led "On" >>> external led "On"
and
Blue SMD led "Off" >>> external led "Off"

Sorry for the little confused explanation, and thanx in advance for any help and support.


texts: Brushless motor + ESC with Arduino question

texts:
Sorry in advance as I'm still a rookie with Arduino projects. My goal is to use an Arduino Uno 3 to create an inexpensive drone/plane project.

Here are my materials and my set up:

A2212 1000kv Brushless Motor
HW30A Brushless Motor Speed Controller (ESC)
Arduino Uno R3
bunch of cables
9 V battery

Upon compiling the code I found here and connecting the 9 V battery to the ESC, all I hear is constant beep sounds from the motor (about once every 1.5 seconds). Can anyone help me figure out what's going on? Is it the 9 V battery that's not giving the motor enough juice? Or am I just too silly hoping to create something that works under $10?

#include <Servo.h>
Servo ESC1;

int pos = 0; //Sets position variable

void arm() {
  setSpeed(0); //Sets speed variable delay(1000);
}

void setSpeed(int speed){
  int angle = map(speed, 0, 100, 0, 180);
  //Sets servo positions to different speeds ESC1.write(angle);
}

void setup() {
  ESC1.attach(9); //Adds ESC to certain pin. arm();
}

void loop() {
  int speed; //Implements speed variable
  for(speed = 0; speed <= 70; speed += 5) {
    //Cycles speed up to 70% power for 1 second
    setSpeed(speed);
    //Creates variable for speed to be used in in for loop
    delay(1000);
  }
  delay(4000); //Stays on for 4 seconds
  for(speed = 70; speed > 0; speed -= 5) {
    // Cycles speed down to 0% power for 1 second
    setSpeed(speed); delay(1000);
  }
  setSpeed(0);
  //Sets speed variable to zero no matter what
  delay(1000);
  //Turns off for 1 second
}


texts: Why can't my bluetooth receive serial data from my android phone, but can send serial data from my bluetooth to my android phone?

texts:
I can receive serial data from my phone but I can't send serial data to the arduino using bluetooth. I can see my input from serial monitor to my Android but not the other way. I'm using ARF7044A bluetooth module if that matters. Any help would be appreciated please.

Arduino to Android: Working
Android to Arduino: Not working.

Here is the wiring:

Here is the code:

char state;
void setup()
{
pinMode(8, OUTPUT);
Serial.begin(9600);
}

void loop()
{

  if(Serial.available())
  {
    state = Serial.read();
    Serial.println(state);
  }
  if (state == 'a')
  {
    digitalWrite(8, HIGH);
  }
  else if(state == 'b')
  {
    digitalWrite(8,LOW);
  }
}


texts: Is there a way to disable modules like ADC without a sleep mode?

texts:
I'm working on a binary watch project. I want my circuit to live off of batteries for as long as possible, so I want to decrease the power consumption of my chip.

I'm using a barebones ATmega328P-PU with two 74HC595 shift registers. The ideal situation would be to keep the CPU, clock, flash, and I/O going so my program can continuously count the time on its own, but disable everything else that I'm not using, such as the ADC, BOD, TWI, timer1 and timer2, USART0, etc.

I took a look at the ATmega328P datasheet for the sleep modes, and it seems as though they all disable the CPU/Clock. Is this true? And if so, are there ways to disable the modules without enacting a sleep mode?


texts: Current difference between pinMode(pin, INPUT_PULLUP) and digitalWrite(pin, HIGH)?

texts:
Does pin 5 or pin 6 use more power if they're just being used as a signal to an external device?
pinMode(5, INPUT_PULLUP);

pinMode(6, OUTPUT);
digitalWrite(6, HIGH);

.
EDIT:  Thanks to some links below, I hopped thru a series of threads until I found the website www.gammon.com.au/power which did tests with a 328 and found the following results with the pins disconnected (which is different than my question but seems relevant nonetheless):
In SLEEP_MODE_PWR_DOWN:

All pins as outputs, and LOW: 0.35 µA.
All pins as outputs, and HIGH: 1.86 µA.
All pins as inputs, and LOW (in other words, internal pull-ups disabled): 0.35 µA (same as before).
All pins as inputs, and HIGH (in other words, internal pull-ups enabled): 1.25 µA.


texts: Determining which raw IR code to use for AC


texts: Can I control two coreless DC motors using L293DD SMD IC?

texts:
I wish to control two 3.7V 6x12mm Coreless DC motors (both direction and speed individually). The only constraint is that the motor driver (circuit) has to be as small as possible.

I've seen couple of driver circuits used in quadcopters where a single FET (such as IRLML2502) is used to control the speed of coreless motors. However, the direction control is not possible with such a circuit.

It requires at least 6 MOSFETs and maybe Schottky diodes to prevent back EMF (similar to half H-bridge like here). Even after this, opposite direction control for two motors at once cannot be achieved. Then I figured all of this will increase the area required and decided to replace it with L293DD IC. Now my question is:

Can the L293DD SMD IC be used to control these motors?
Is there an alternate solution/circuit/IC which can minimize the size and area?
Are ESCs required for these small coreless motors? Can they be controlled directly via the L293DD (like normal motors)?

PS: The controller will be ESP8266 and the entire system will powered by a 3.7V 300mAh LiPo battery.


texts:
Someone could help me?
I want to use dht11 with arduino and esp. Both will read data from dht11
the problem is that simultaneously cannot be done. So the solution will be to set one as a master and the other one as a slave.
the control will be done like so...
another wire from arduino pin->set as output ->esp pin->set as input.
if wire == 1 then dht11 will be read by arduino
if wire == 0 then esp will read dht.
with some delay ofcourse. but the problem is that i dk how to stop the communication between one board and the sensor when the other board will read it. so does it not exist any conflict


texts: Arduino join multiple strings and numbers and then seperate them

texts:
OK, I'm working on a remote controlled robot. Both the robot and the remote use Arduino with a Bluetooth shield. The Bluetooth is working and I need to send something similar to this over Bluetooth:

X:1026,Y:1026,Button:1

There may be more buttons added and X,Y can be between 1026 and 0. How can I build that string from:

xPosition = 1026;
 yPosition = 1026;
 buttonState = 0;

I also need to be able to separate that string back into variables on the 2nd Arduino.

EDIT: I have seen other questions similar to this but they involved Serial. I am using Bluetooth.

EDIT AGAIN: I am sending the data over Bluetooth with the BlueToothSerial.print command from the SoftwareSerial.h library. (BlueToothSerial is SoftwareSerial BlueToothSerial(RxD,TxD);)


texts:
I bought a Gsm module recently(not official arduino shield) and i connect it to Arduino uno. The problem (I guess) is , i can't set delay properly, the terminal send it too fast that i missed it or too slow even i set its baud rate to 4800 (I have tried it with many baud from 4800-to-115200).

I uploaded the code to Git ,with this address.

More details: For example when i enter d in terminal it act like this message came up : +CMTI: "SM",3 and it want to save it but it miss plus at first of it and it save CMTI: "SM",3,

After that it perform this : AT+CMGR=3 the terminal show the message in half size : +CMGR: "REC UNREAD","+9*********2","H/E.3D/1","16/02/28,00:27:02+14" which totally missed body part.

The weird thing is when i put some println on the program it miss more characters , and second weird thing is it missed more character in second run or i push d again.

I have tried to change the delays but no success.How can i fix it ? any help would be appreciated.

Edit:

If i make it simpler, when i use these code i get half message :

#include <SoftwareSerial.h>
SoftwareSerial serialGPRS(7, 8);
void setup()
{
  Serial.begin(19200);
  serialGPRS.begin(19200);
}
void loop()
{
  serialGPRS.println("AT+CMGR=1");
  delay(1000);
  while(serialGPRS.available()!=0)
    Serial.write(serialGPRS.read());
}

like: +CMGR: "REC READ","+9*******",".H/E.3D/1


texts: Proximity sensor without proximity sensor; is my hand magic, my competency crap, or my arduino fried?

texts:
here is a very simple circuit, with a LED between pin 2 and ground, and a loose wire in pin 8.

Here is the sketch that was intended for use with a small 4-contact switch like these in every arduino starter kit :

int yellowCIn = 8;
int yellowCOut = 2;

void setup() {
  pinMode(yellowCIn, INPUT);
  pinMode(yellowCOut, OUTPUT);
}

void loop() {
  if (digitalRead(yellowCIn) == HIGH) {
  digitalWrite(yellowCOut, HIGH);
  }
  else {
    digitalWrite(yellowCOut, LOW);
  }
}

However, simply moving my hand near the loose white wire is enough to light the LED, moving it away to put it off. As I am writing this, with the arduino connected by usb, rather than on the blue battery visible in the picture, I notice moving my hands away from the keyboard lights the led, moving them close to the keyboard powers it off...

So back to my title : are my hands magic, my electronics competency crap (well, it is, for sure) enough that I never heard of such a tremendous static electricity effect (and never fried one of the many computers I built from parts), or does this board have dire problems?

Thanks for your attention :)


texts: Does ESP8266 module is necessary to connected or just Separated

texts:
I using FPGA design have two thing sent text or image from FPGA to ESP8266 to website or app the my propose only shown the data,
My question i wanna connected (FPGA) TX to RX () is That can? kindly, any suggestion?


texts:
Just read a post about timers and there was a timers cheat sheet posted there. It has been very helpful and I wonder if there is one for interrupts as well?

The post with the nice timer cheatsheet was this one Arduino constant clock output


texts:
Guys please help me out in verifying my program for my project -- led fading effect using a push button.
My project is simple, I want to start the LED fading effect (i.e., glowing and dimming one after another) at one click on the push button that is pushing and then leaving the push button and on my another click I want the effect to get off.
The main problem is coming in the programming part and rest all the circuit and components are fine.
THIS IS MY SKETCH :-
int ledpin = 9;
int buttonpin = 8;
boolean buttonpressed = false;   // to check whether the button was pressed //
int brightness = 0;
int fadeamount = 5;

void setup ()
{
pinMode (ledpin, OUTPUT);
pinMode (buttonpin,INPUT);
digitalWrite (ledpin,LOW);
}

void loop ()
{
if ( digitalRead (buttonpin) == HIGH)
 {
  buttonpressed = true;
 }

 else {
     if ( buttonpressed = true && digitalRead(ledpin) == LOW)
       {
           brightness = brightness + fadeamount;
           if ( brightness == 0 || brightness == 255)
            {
             fadeamount = -fadeamount;}
             analogWrite(ledpin, brightness);
             delay (30);
             buttonpressed = false;
        }
      if (buttonpressed == true && analogRead(ledpin) == brightness)
        {
          digitalWrite(ledpin,LOW);
          buttonpressed = false;
        }
   }
 }

THIS IS THE CIRCUIT DIAGRAM


texts: Failed to initialise SD card on Leonardo

texts:
I'm trying to connect SD card reader to my Arduino. For testing i'm running CardInfo example.

It seems like it runs ok when I'm running it on my Arduino UNO, but it fails to initialise SD Card while i'm running it on any Arduino with Atmega32U4 chip. I tried on two Leonardo's and Micro Pro.

This is my pinout:

CardReader       Arduino

CS          <->     4
SCK         <->    13
MISO        <->    12
MOSI        <->    11
VCC         <->    5V
GND         <->    GND

I'm using Library in version 1.2.1 if that's make difference.

Does anyone have any suggestions?


texts: Leonardo Board stops reading analog input

texts:
I'm currently writing software that reads in analog data, writes it into an instance variable array, then returns the address of the array. However, after a few iterations of loop, the program stops completely. I'm tagging memory and memory-usage because I suspect that has to do with this, however I'm not experienced enough do deal with it. Any insight will be really appreciated, because this has been plaguing me for a while.
NeuroBoard.ino main loop
void loop() {
    int* samples = board.getNewSamples(10);

    for (int i = 0; i < 10; i++)
        Serial.println(samples[i]);
}

NeuroBoard.cpp (most removed for brevity)
int* NeuroBoard::getNewSamples(const size_t& size) {

    // TODO: Return buffer of n samples.

    this->samples = new int[size];

    for (int i = 0; i < size; i++) {
        int newSample = this->getLastSample(); // returns an integer
        this->calculateEnvelopeValue(newSample); // does not modify newSample value
        this->samples[i] = newSample;
        delay(1);
    }

    return this->samples;

}

NeuroBoard.hpp (declaration of samples)
/**
* Samples generated by the 'getNewSamples(n)' function.
**/
PROGMEM int* samples;


texts: I have the error: expected unqualified-id before 'if'

texts:
This is my Sketch or code:

const int EchoPin = 5;
const int TriggerPin = 6;
const int LedPin = 13;

void setup() {
 Serial.begin(9600);
 pinMode(LedPin, OUTPUT);
 pinMode(TriggerPin, OUTPUT);
 pinMode(EchoPin, INPUT);
 pinMode(13, OUTPUT);
}

void loop() {
 int cm = ping(TriggerPin, EchoPin);
 Serial.print("Distancia: ");
 Serial.println(cm);
 delay(1000);
}

int ping(int TriggerPin, int EchoPin) {
 long duration, distanceCm;
 digitalWrite(TriggerPin, LOW);
 delayMicroseconds(4);
 digitalWrite(TriggerPin, HIGH);
 delayMicroseconds(10);
 digitalWrite(TriggerPin, LOW);
 duration = pulseIn(EchoPin, HIGH);
 distanceCm = duration * 10 / 292/ 2;
 return distanceCm;
}

if (distanceCm <= 20) {
 digitalWrite(13, HIGH);
}

if (distanceCm >= 20) {
 digitalWrite(13, LOW);
}

The error appears in the second if.


texts: NEO GPS 6M connecting to Lilypad Arduino

texts:
I'm working on a project that has something to do with receiving gps data from the satellites. With this, I've used GPS NEO 6M with an arduino Lilypad for wearable purposes.

I've already tried using the Arduino Mega ADK and it's working with my codes before I used Lilypad.

With pin connections:

Lilypad         GPS
Vcc ----------> Vcc
GND ----------> GND
D4  ----------> TX
D3  ----------> RX

And here is the code I used for it:

  #include "TinyGPS++.h"
  #include "SoftwareSerial.h"

  SoftwareSerial serial_connection(4, 3);
  TinyGPSPlus gps;//This is the GPS object that will pretty much do all the grunt work with the NMEA data
  void setup()
  {
  Serial.begin(9600);//This opens up communications to the Serial monitor in the Arduino IDE
  serial_connection.begin(9600);//This opens up communications to the GPS
  Serial.println("GPS Start");//Just show to the monitor that the sketch has started
  }

  void loop()
  {
  while(serial_connection.available())//While there are characters to come from the GPS
  {
  gps.encode(serial_connection.read());//This feeds the serial NMEA data into the library one char at a time
  }
  if(gps.location.isUpdated())//This will pretty much be fired all the time anyway but will at least reduce it to only after a package of NMEA data comes in
  {
//Get the latest info from the gps object which it derived from the data sent by the GPS unit
  Serial.println("Satellite Count:");
  Serial.println(gps.satellites.value());
  Serial.println("Latitude:");
  Serial.println(gps.location.lat(), 6);
  Serial.println("Longitude:");
  Serial.println(gps.location.lng(), 6);
  Serial.println("Speed MPH:");
  Serial.println(gps.speed.mph());
  Serial.println("Altitude Feet:");
  Serial.println(gps.altitude.feet());
  Serial.println("");
  }
  }

 /*
* $GPRMC,183729,A,3907.356,N,12102.482,W,000.0,360.0,080301,015.5,E*6F
$GPRMB,A,,,,,,,,,,,,V*71
$GPGGA,183730,3907.356,N,12102.482,W,1,05,1.6,646.4,M,-24.1,M,,*75
$GPGSA,A,3,02,,,07,,09,24,26,,,,,1.6,1.6,1.0*3D
$GPGSV,2,1,08,02,43,088,38,04,42,145,00,05,11,291,00,07,60,043,35*71
$GPGSV,2,2,08,08,02,145,00,09,46,303,47,24,16,178,32,26,18,231,43*77
$PGRME,22.0,M,52.9,M,51.0,M*14
$GPGLL,3907.360,N,12102.481,W,183730,A*33
$PGRMZ,2062,f,3*2D
$PGRMM,WGS 84*06
$GPBOD,,T,,M,,*47
$GPRTE,1,1,c,0*07
$GPRMC,183731,A,3907.482,N,12102.436,W,000.0,360.0,080301,015.5,E*67
$GPRMB,A,,,,,,,,,,,,V*71
*/

This code was working when I used the mega ADK. And I concluded now that the program is not the issue why it's not working and receiving any gps data from the satellites above.
Does anybody here have tried working similarly with this project using Lilypad arduino? I kept banging my head figuring out the possible reason why my GPS is not working with the Lilypad.

I hope you can help me with this.

Cheers!


texts: NodeMCU does not boot up when GPIO pin is high

texts:
I have a NodeMCU board connected to a door and there is a micro switch that makes one GPIO pin (GPIO15 - D8 in this specific case) go high when the door opens.

My problem is if I lose power while the door is opened, the GPIO15 is fed high at the next boot when power is restored. And it makes the board go to a not responding state. I have to boot it again while the door is closed (pin is low) to bring it back to work. I experienced this while flashing too. I cannot flash while this pin is high (while the door is open).

How can I fix this?


texts:
I am new with Arduino. Im working in a school project, and I decided to create a glove with shock sensor for goalkeepers and need a ultrasonic sensor next to the ball, so i can know when the ball was kicked.

I need the data from both sensor.

Is this possible with only 1 arduino?, where the arduino is with the ultrasonic sensor and the shock sensor is connected with a bluetooth module to send it to the arduino.

Or, I have to use 2 arduinos?, one with with the glove and the other with the ultrasonic sensor and connect both with bluetooth?

If this is not the best way, can you help me with some ideas to do it? Thank you.


texts: Arduino Uno unable to detect serial port on MAC os Mojave 10.14.2

texts:
Ive upgraded to Mojave.  I've never used Arduino before.  I was given Arduino Uno.
Arduino Uno does not find any serial ports... can't load Blink example (the first step)

In blind frustration, I tried the three ports available... None of work.

I've loaded the
CH34x_Install_V1.4.pkg
to no avail.

How do I get a serial port package that will enable serial ports in general (and more importantly for arduino)

thx,
Bruce
On a related Note: the list of things that Mojave broke is long!  To solve many problems, re-install xcode FIRST!!! and read articles on apache, there is a "new and improve" apache server embedded in mojave.


texts: Do I need a relay to control a monitor's power with an Arduino?

texts: I'm trying to use an Arduino to switch a monitor's power on and off. I'm going to wire the Arduino to the monitor's power switch. I've tested the power switch with a multimeter, and when pressed, there is a 3.3V current running through it that triggers the power on and off. The monitor itself is takes 12VDC to power. I know that a relay is used when switching larger power sources from a low voltage source so as not to damage the lower voltage source, but since the switch in question only runs at 3.3V would it be safe to use the Arduino without a relay?


texts: Fetching txt file's contents from a webhost using esp8266

texts:
I am trying to access a txt file in my website and fetch its contents that is hosted by 000webhost. I used this code:

void sendGET() //client function to send/receive GET request data.
{
 WiFiClient client;
 if (client.connect(host, httpPort)) {  //starts client connection, checks for connection
 Serial.println("connected");
 client.println("GET /status.txt HTTP/1.1"); //download text
 client.println("Host: *****.000webhostapp.com");
 client.println("Connection: close");  //close 1.1 persistent connection
 client.println(); //end of get request
}
else {
 Serial.println("connection failed"); //error message if no client connect
 Serial.println();
}
bool rn = false;
while (client.connected() && !client.available()) delay(1); //waits for data
while (client.connected() || client.available()) { //connected or data available
char c = client.read(); //gets byte from ethernet buffer
Serial.print(c); //prints byte to serial monitor
//    responsed = c;
if (rn == true) {
  if (c == '1') {
    Open();
  }
  else if (c == '0') {

  }
}
if (c == '!') {
  rn = true;
 }
}

Serial.println();
Serial.println("disconnecting.");
Serial.println();
client.stop(); //stop client
rn = false;
}

but in my serial monitor, it echoed

connected
HTTP/1.1 200 OK
Date: Tue, 20 Nov 2018 06:26:41 GMT
Content-Type: text/plain; charset=UTF-8
Content-Length: 1
Last-Modified: Mon, 19 Nov 2018 10:01:12 GMT
Accept-Ranges: bytes
Server: awex
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Request-ID: 4575720f977969af975e822bc1e15eea
Age: 10203
X-Cache: HIT from localhost
X-Cache-Lookup: HIT from localhost:3128
Via: 1.1 localhost (squid/3.5.27)
Connection: close

1
disconnecting.

why isn't it reading the content? i am new to this platform, thank you.

edit, the file contains only two characters. i used ! to indicate that the next number will be the one to store, and the next is either 0 or 1 based on the api i made. in short it is used to transfer my api's response to be read by arduino using esp8266


texts: Initialize a "Matrix" object in my own library?

texts:
So, I'm trying to make a custom library to drive a 8x8 Bi-Color LED Matrix from 2 MAX7219's that incorporates two "Matrix" objects from the "Matrix" library and I cannot, for the life of me, figure out how to initialize them in my class. Can someone help me? By the way, I have been programming for 8 years, and consequently have a decent knowledge of the topic! Here is my current code:

header file

#include "Arduino.h"
#include "Matrix.h"
#include "Sprite.h"

class ZackBiColorMatrix{

    public:

        ZackBiColorMatrix(byte dataR, byte loadR, byte clockR, byte dataG, byte loadG, byte clockG);

        Matrix r;
        Matrix g;

        void setLED(byte col, byte row, byte val, char color);
        void writeSprite(byte x, byte y, Sprite sp, char color);

    private:

        byte redData;
        byte redLoad;
        byte redClock;

        byte greenData;
        byte greenLoad;
        byte greenClock;

};

and the .cpp file:

#include "Arduino.h"
#include "Sprite.h"
#include "Matrix.h"
#include "ZackBiColorMatrix.h"

ZackBiColorMatrix::ZackBiColorMatrix (byte dataR, byte loadR, byte clockR, byte dataG, byte loadG, byte clockG) {

    redData = dataR;
    redLoad = loadR;
    redClock = clockR;

    greenData = dataG;
    greenLoad = loadG;
    greenClock = clockG;

    r = Matrix (redData, redClock, redLoad);
    g = Matrix (greenData, greenClock, greenLoad);

}

void ZackBiColorMatrix::setLED (byte col, byte row, byte val, char color) {

    if (color == 'g') {

        g.write (col, row, val);

    }
    else if (color == 'r') {

        r.write (col, row, val);

    }

}
void ZackBiColorMatrix::writeSprite (byte x, byte y, Sprite sp, char color) {

    if (color == 'g') {

        g.write (x, y, sp);

    }
    else if (color == 'r') {

        r.write (x, y, sp);

    }

}

Also, I use the Eclipse Arduino IDE if that matters.


texts: Push to 2D array (log) but last value pushed is everywhere

texts:
I have this simple that is supposed to keep a log for me with a fixed number of entries. When I add to the log the oldest replaced is by the second oldest etc and the new entry added. Except when I add another entry both that and the one before have the same value (My C isn't any good, I'm more a ruby and lua guy).

What am I doing wrong here?

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

#define log_size 5
#define line_height 12
char *log_lines[log_size] = {"Hello", "World"};

void addToLog(char *text) {
  for(int i = log_size - 1; i > 0; i--) {
    log_lines[i] = log_lines[i-1];
  }
  log_lines[0] = text;
}

void printLog() {
  for(int i = 0; i < log_size; i++) {
    Serial.print(i);
    Serial.print(" ");
    Serial.println(log_lines[i]);
  }
}

void loop(void)
{
  char msg[20];
  sprintf(msg, "%d", millis());
  addToLog(msg);
  printLog();
  delay(1000);
}

The output after the first addToLog is

0 1000
1 Hello
2 World

second addToLog is

0 2001
1 2001
2 Hello
3 World


texts: Keyboard.h: No such file or directory - Arduino pro micro (leonardo)

texts:
I've just bought a new pro-micro and I want to simulate some keyboard inputs with it, the thing is the Arduino IDE (version 2:1.0.5) can't seem to find neither HID.h or Keyboard.h libraries. The steps to reproduce the problem are:

plug the device using usb cable on the pc
Open arduino ide
try to compile my code
it fails with the error

  test_keyboard.ino:27:22: fatal error: Keyboard.h: No such file or directory
  compilation terminated.

The code is:

#include <Keyboard.h>

void typeKey(int key)
{
  Keyboard.press(key);
  delay(50);
  Keyboard.release(key);
}

/* Init function */
void setup()
{
  // Begining the Keyboard stream
  Keyboard.begin();

  delay(400);

  //Keyboard.press(KEY_LEFT_GUI);

  Keyboard.press(KEY_CTRL);
  Keyboard.press(KEY_ALT);
  Keyboard.press(KEY_T);

  Keyboard.releaseAll();

  delay(100);

  Keyboard.print("echo 'hello world'");

  typeKey(KEY_RETURN);

  delay(100);

  // Ending stream
  Keyboard.end();
}

/* Unused endless loop */
void loop() {}

By the way, I'm running this on linux, after pluging it and running lsusb on terminal I got:
  Bus 002 Device 071: ID 2341:8036 Arduino SA Leonardo (CDC ACM, HID)


texts: Minimal example of Task Scheduler Blink?

texts:
Scheduler_example00_Blink is ~300 lines. For just an Arduino Uno, what is a minimal example?
It's hard to know what belongs and what doesn't. This example has six different approaches, and I'm just trying to extract one of them.


texts: Why is timer0 the fastest timer in the arduino?

texts:
In the documentation, it shows that the higher  frequency that can be reached with an Arduino UNO for and 8bits PWM is using timer0  with the pre-scaler  set at 1. That  gives a Fs of 62500 Hz, but why is that so?

I understand the Prescaler is dividing the frequency, but why it does start at 62500 Hz and  timer1 and timer2 have as maximum 31372 Hz.


texts:
I'm driving a large stepper motor via a GeckoBoard G213V and arduino UNO and I have that mostly working fine. However, I'd like to 'release' the stepper so it can swing freely.

There's two reasons I want to do this:

1) (Most important) I want the rotated object to naturally swing back to the 0 position thanks to gravity.
2) The motor gets hot - I'd rather not juice it when it should just be sat at 0.

Anybody know how I can do this? I'm using the AccelStepper library so a solution compatible with that would be ideal.


texts: How to Sort a String with Number by Ascending

texts:
I have trouble figuring out how to sort a String that has a Number in it.

The String im sending looks like 112:AAAA and 111:EEEE, how would I sort it so that the 111 will be the first in an array but (and here is what I cant figure out) the sorted array should contain the letters again so it would be a String Array that is sorted by the numbers and look like 111:EEEE, 112:AAAA.

I wanted to use what I have seen on C#, having a key and value, but that does not seem to exist in arduino code. So I improvised by writing everything in 1 char array.

edit: I see I'm mixing up char array and string, im very flexible and its no trouble to change to 1 or the other, currently I use char arrays.

I guess it would also be enough to just sort the strings, but i cant find a function for that also.


texts: Why this program works on an old Nano and doesn't work on Nano Every

texts:
Can someone tell me why "XTronical graphical Pulse and Oxygen monitor Displays"
https://www.xtronical.com/colour-ecg-monitor/
works perfectly on an old Nano or an Uno and doesn't work on the new Nano Every
even with Registers emulation: "ATMEGA328" ?

Is the Nano Every a "BAD BUY" ?

I very much welcome an explanation.
JFT


texts: Keeping track of the number of rotations of a stepper motor

texts: Using the stepper.h library in Arduino IDE, how can we control the number of rotations the motor has to move?


texts: What is the meaning of [type]* for arrays?

texts:
I've seen * used with arrays in some programs but not in others. The page on arrays doesn't mention it at all, but I often see it near functions when values are being passed.

Where would I find more information on this?


texts:
Can we upload the sketches to arduino UNO board via android bluetooth using any app?
If possible how can we achieve it?


texts: Different ways (and the fastest) to compute sines (and cosines) in Arduino

texts:
I am using an Arduino Uno board to compute the angles of my system (robotic arm). The angles are actually 10 bit values (0 to 1023) from the ADC, using the full range of the ADC. I am only going to be operating in the 1st quadrant (0 to 90 deg), where both sines and cosines are positive, so there is no problem with negative numbers. My doubts can be expressed in 3 questions:

What are the different ways to compute these trigonometric functions on Arduino?
What is the fastest way to do the same?
There are the sin() and cos() functions in the Arduino IDE, but how does the Arduino actually calculate them (as in do they use look-up tables, or approximations etc.)? They seem like an obvious solution, but I would like to know their actual implementation before I try them out.

PS: I am open to both standard coding on the Arduino IDE and assembly coding, as well as any other options not mentioned. Also I have no problems with errors and approximations, which are inevitable for a digital system; however if possible it would be good to mention the extent of possible errors


texts: How to detect the direction of rotation with a sensor encoder timing disk (photoelectric speed sensor)?

texts:
I am making a DIY gaming steering wheel and am stuck.
For measuring the rotation of the wheel, I'm using a sensor encoder timing disk, which is usually found in printers. - https://robu.in/product/photoelectric-speed-sensor-encoder-coded-disc-code-wheel.

A lot of tutorials on youtube use this.
But I just cannot seem to understand how to use this sensor.

Please help me in figuring this out: using this sensor, how to -

Measure how much the wheel rotated?
Know which direction did the wheel rotates in (clockwise, anti-clockwise).

PS: I tried using a rotatory encoder, but it is unable to sense rotation when rotated by a 1000 RPM motor. Would love to understand why.

Thanks!


texts: How to create a wired ESP8266 range extender?

texts:
Context: I have a NETGEAR router on the first story of my home, the range doesn't extend to the ground floor. I do have a cable duct from my router(on the first story) to the ground floor.

Question:

Is it possible to wire a Keyes ESP8266 to my router to act as a WiFi range extender?

Note: The length of the cable would be 10 meters.


texts:
I'm using my Arduino Uno to control a 5V 1A solenoid.

I'm using an N-Channel MOSFET linked to the Uno's 0 pin to switch the solenoid on and off. It is protected by a Schottky diode. Initially, I tested the circuit with the blink example sketch (just set to blink Pin 0 instead of Pin 13). I used the Uno's built in 5V 500mA output and the solenoid "blinked" on/off perfectly at whatever interval I wanted:

I plan on controlling multiple solenoids in a future version, which will draw more current than the Arduino output can supply, so I bought a 5V 12A power supply. I proceeded to test it with my single-solenoid set up using the same blink example sketch:

When I power the solenoid with my 5V 10A my power supply, the solenoid doesn't push on command. It merely "vibrates," travelling only about .5mm at several hundred Hz. The solenoid vibrates constantly the moment I plug in the power supply, and does so completely independently of whatever interval I have set it to "blink."

Any ideas as to what may be causing this to work with the Arduino's built in power supply, but not with an external power supply? I've tested the voltage on my power supply, and it reads 5V as advertised. I'm somewhat new this, and feel like I may be missing something obvious.

Thanks,

Max


texts: How to store a string in an object and retrieve it safely later?

texts:
I'm writing a program where I will be able to toggle between multiple banks, and each bank has 4 presets on it. Right now, I'm trying to give each preset a name that is assigned on creation.

I have an object I called StoredDataManager, which will handle all the banks. In its constructor, I do this:

for (byte i = 0; i < NUMBER_OF_BANKS; i++) {
  Bank bank;
  _banks[i] = &bank;
}

_banks is declared like this: Bank* _banks[NUMBER_OF_BANKS]; in the .hfile of StoredDataManager.

A bank has 4 presets, like this:

Preset* _A;
Preset* _B;
Preset* _C;
Preset* _D;

Which I initialize as this:

Preset preset(presetName, presetData);
...
_A = &preset; ...

Where presetName is "CHR", and presetData doesn't matter, because I'm just trying to get the name to work.

In the preset, the name is saved like this: char _presetName[4];.
It is returned like this:

char* Preset::getPresetName() {
  return _presetName;
}

I try to print a preset's name like this:

Serial.println(_banks[0]->getPreset('A')->getPresetName());

But, right now it simply returns C§.

Why is that? I suspect it has to do with the memory being erased or overwritten.

EDIT:
Here is the code of getPreset:

Preset* Bank::getPreset(char presetLocation) {
  switch (presetLocation) {
    case PRESET_LOCATION_1:
      return _A;
    case PRESET_LOCATION_2:
      return _B;
    case PRESET_LOCATION_3:
      return _C;
    case PRESET_LOCATION_4:
      return _D;
    default:
      return NULL;
  }
}

I think now that I'll turn this into 4 separate functions, like getA, getB and so on, but this what it is the moment. PRESET_LOCATION_1 is just a #define PRESET_LOCATION_1 'A'.

EDIT 2:
I start in the main arduino .ino file with this:

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

This triggers this constructor:

StoredDataManager::StoredDataManager() {
  for (byte i = 0; i < NUMBER_OF_BANKS; i++) {
    Bank bank;
    _banks[i] = &bank;
  }
  _currentBankIndex = 0;
  Serial.println(_banks[0]->getPreset('A')->getPresetName());
}

This is _banks: Bank* _banks[NUMBER_OF_BANKS];.
The initializing of the bank object runs this constructor: (PRESET_LOCATION_1, 2, 3, and 4 just being 'A', 'B', 'C', 'D')

Bank::Bank() {
  addPreset("CHR", "Some data", PRESET_LOCATION_1);
  addPreset("CHR", "Some data", PRESET_LOCATION_2);
  addPreset("CHR", "Some data", PRESET_LOCATION_3);
  addPreset("CHR", "Some data", PRESET_LOCATION_4);
}

Which calls this function:

void Bank::addPreset(const char* presetName, String presetData, char presetLocaton) {
  Preset preset(presetName, presetData);
  switch (presetLocaton) {
    case PRESET_LOCATION_1:
      _A = &preset; break;
    case PRESET_LOCATION_2:
      _B = &preset; break;
    case PRESET_LOCATION_3:
      _C = &preset; break;
    case PRESET_LOCATION_4:
      _D = &preset; break;
  }
}

Then, above in the StoredDataManages constructor, this line is hit:

Serial.println(_banks[0]->getPreset('A')->getPresetName());

And that's where I try to log out the preset name.


texts:
I'm pretty new to arduino and need some help.

My task is to connect my UNO R3 to wifi AND then send data (sketch for blinking led) to it.
I successfully connected my arduino with my wifi, but how do I send the sketch?

I didn't find a tutorial for this. Do you know a good one or can you help me, please?


texts: how to control switch (proteus) using bluetooth card (HC-05) and arduino?

texts:
This is the first time I use the Internet with the Arduino in the proteus ,
What are the stages that I must follow in order to be able to control the switch via Bluetooth?
If it was possible to clarify more, because I really do not know anything about the other applications, taht my first project in iot.


texts: How to tune up a servo and add protective clauses?

texts:
I am working with an Arduino Uno, and have recently been given an assignment to use the servo motor.
The requirements are that I tune the pulse widths while comparing the 0 and 180 degrees. Secondly I must put in a protective clause to prevent it from going past the values. Any help at all is greatly appreciated. Thank you.
(Using the servo.attach(pin, minpulse, maxpulse) method, and writeMicroseconds() command.)

You may want to put in protective clauses in your code to prevent accidental driving of the servo beyond its intended range.
Write a simple program to tune up your servo’s min and max pulsewidths corresponding to 0° and 180°. Start by using 900 and 2100 in the attach() command, and perhaps sending the motor to 0°, 90°, and 180° delaying a couple seconds between moves for you to assess the quality of alignment.

My only ideas have been to manually fine tune it by checking when it does not turn any more.


texts: Arduino with using Adafruit NeoPixel library set one color, fade random pixels in strip on and off

texts: So I am trying to get random pixels to fade on and off at one color. I want to create a power moving inside an item effect.  I have several examples of the whole strip fading in and out, but cant seem to nail down how to fade random pixels on and off at different intervals.  I want to have some on and some off, some fading out while others fading in, all on different LEDs at different times.  Can this be done?


texts: Stepper motor not working in Arduino 101

texts:
I am trying to connect a stepper motor ( this model exactly https://create.arduino.cc/projecthub/trduunze/grove-starter-kit-for-arduino-stepper-motor-driver-66471d ) in an arduino 101 but it does not work for some reason. I have tried connecting everything ast they tell in the website with no results:

And then I tried connecting directly to the board without using the shield, and still getting nothing.

The code I am using is this :

#include <Stepper.h>
int t =0;
const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution for your motor
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

int stepCount = 0;  // number of steps the motor has taken

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

void loop() {
  // set the motor speed:
  int motorSpeed = 15;
  if (motorSpeed > 0) {
    myStepper.setSpeed(motorSpeed);
    // step 1/100 of a revolution:
    myStepper.step(stepsPerRevolution / 25);
  Serial.println(motorSpeed);//print how fast the motor is going in the serial monitor
  }
}

Connecting the stepper motor and the driver, and launching the sketch in an arduino UNO board works perfectly, so I am really worried about that maybe the Stepper.h library might be different for the Arduino 101 but I couldn't find anything about that. I just have no idea why the project is not working in the 101 but working perfectly in the UNO. Any help or tips would be highly appreciated.

Cheers!

EDIT

After a lot of messing around, I have only been able to light up one led in the controller connecting one of the motor cables to GPIO5. None of the other GPIOS seem to work with the step motor controller.


texts: Max. external ADC speed with ESP32 (SPI or I2C)?

texts:
What is the maximum speed for external ADC I can expect to get with ESP32? I'm planning to have 16-bit ADC connected to I2C or SPI whichever gives more speed.
How that information is calculated from information in ESP data sheet?


texts:
I want to know when something is connected to USB port by blinking an LED.

I suppose have to check PB10 UOTGVBOF, but how to do this ?


texts:
I'm trying to convert the project here to an Arduino Nano.

I scaled the waveforms from 12 bit to 8 bit values. I replaced the analogReadResolution and analogWriteResolution calls with pinMode(10, OUTPUT) and pinMode(11, OUTPUT) and changed the two analogWrite calls to write to pins 10 and 11. Otherwise the program is unchanged.

My thinking (and this is where my poor electronics skills come into play) is that I just need a simple low pass filter to convert the PWM into the appropriate waveform (which, at startup, ought to be a sine wave on both pins). According to the article, the frequency generator tops out at 170Hz. I figure the PWM signal is going to be significantly higher than that, so I use R=3.3K and C = .1uF for my RC filter which ought to give me a -3dB at about 480Hz, but what I'm seeing on my scope is a mess. Not a stable signal at all.

This is the waveform I'm seeing on my scope:

Can someone educate me?

Update: BTW, this is the initial waveform which ought to be a sine wave.


texts: master slave control of 2wd robots using xbee

texts:
Hi there I just need to ask you how I can send command from master robot to slave to follow using XBee. I have configured both the XBee in AT mode, but I totally don't have the clue how the program.

I am using the following kit components (from DF ROBOT) to build this project,

Romeo V2-All in one Controller (Arduino based controller).
Differential drive chasis with caster ball.
Wheel Encoders.
XBee 2mW PCB Antenna - Series 2 (ZigBee Mesh)  Transceiver module for the communication between two robots.
IR sensors.

6.Micro DC Geared Motor w/ Back Shaft (180rpm 6V).

I have done the programming for obstacle detection, positioning of robot, but I have no idea how to do the master slave programming logic.

Please help me on this. Here attached the code I have done till now:

const int InfraredSensorPin1 = 6;//Connect the signal pin to the digital pin 6
int detected2;
int detected1;
const int InfraredSensorPin2 = 9 ;

int E1 = 5;     //M1 Speed Control
int E2 = 6;     //M2 Speed Control
int M1 = 4;    //M1 Direction Control
int M2 = 7;    //M1 Direction Control

#define LEFT 0
#define RIGHT 1
int value;
long coder[2] = {
  0, 0
};
int lastSpeed[2] = {
  0, 0
};

void stop(void)                    //Stop
{
  digitalWrite(E1, 0);
  digitalWrite(M1, LOW);
  digitalWrite(E2, 0);
  digitalWrite(M2, LOW);
}
void advance(char a, char b)         //Move forward
{
  analogWrite (E1, a);
  digitalWrite(M1, HIGH);
  analogWrite (E2, b);
  digitalWrite(M2, HIGH);
}
void back_off (char a, char b)         //Move backward
{
  analogWrite (E1, a);
  digitalWrite(M1, LOW);
  analogWrite (E2, b);
  digitalWrite(M2, LOW);
}
void turn_L (char a, char b)            //Turn Left
{
  analogWrite (E1, a);
  digitalWrite(M1, LOW);
  analogWrite (E2, b);
  digitalWrite(M2, HIGH);
}
void turn_R (char a, char b)            //Turn Right
{
  analogWrite (E1, a);
  digitalWrite(M1, HIGH);
  analogWrite (E2, b);
  digitalWrite(M2, LOW);
}

void setup(void)
{ Serial.println("Start!");

 pinMode(InfraredSensorPin1, INPUT);
 pinMode(InfraredSensorPin2, INPUT);

advance(200,200);
  Serial.begin(19200);      //Set Baud Rate//
  attachInterrupt(LEFT, LwheelSpeed, CHANGE);    //init the interrupt mode for the digital pin 2
  attachInterrupt(RIGHT, RwheelSpeed, CHANGE);   //init the interrupt mode for the digital pin 3
}
void loop(void)
{
  if((InfraredSensorPin1==LOW&&!InfraredSensorPin2==LOW)||(InfraredSensorPin1==LOW&&InfraredSensorPin2==LOW))
  turn_L (100,100);

  else if ((InfraredSensorPin2==LOW&&!InfraredSensorPin1==LOW)||(InfraredSensorPin2==LOW&&InfraredSensorPin1==LOW))
  turn_R (100,100);

  else
  advance (80,80);
  static unsigned long timer = 0;                //print manager timer
  if (millis() - timer > 5) {
    Serial.print("Coder value: ");
    Serial.print(coder[LEFT]);
    Serial.print("[Left Wheel] ");
    Serial.print(coder[RIGHT]);
    Serial.println("[Right Wheel]");

    lastSpeed[LEFT] = coder[LEFT];   //record the latest speed value
    lastSpeed[RIGHT] = coder[RIGHT];
    coder[LEFT] = 0;                 //clear the data buffer
    coder[RIGHT] = 0;
    timer = millis();
  }
}
void LwheelSpeed()
{
  coder[LEFT] ++;  //count the left wheel encoder interrupts
}
void RwheelSpeed()
{
  coder[RIGHT] ++; //count the right wheel encoder interrupts
}


texts: Is it possible to extract a hex file via UART from an Arduino?

texts: Right now I am tinkering on my 3D printer that has an Arduino mega as a brain. I need to update the Marlin firmware but in case of an error I want to create an backup of the firmware. And because it is assembled using a shield on top have no access to the ICSP interface. And I was curious if you can extract all the flash and EEPROM via USB (UART). If yes than what software should I use to do that.


texts: How can I put this display SSD1306 to sleep?

texts:
I have built a kitchen timer and it is supposed to spend most of its life in sleep mode in order to save power. I am using the SSD1306Ascii library (SPI) by William Greiman.

In this library I have found hints to power on and off commands but I don't know how to use them:

/** Set Display off. */
#define SSD1306_DISPLAYOFF 0xAE
/** Set Display on. */
#define SSD1306_DISPLAYON 0xAF

From what I could gather from the web, I need to re-initialize the display after turning it off and on again. But before I take care of that (which should be simple as it is done in setup anyway) I need to find out how to use these commands.

Would you help out a rookie?


texts:
I saw this question about powering Arduino and LED strip. So, I searched for a 5v 4a power supply and foud this one.
How does that adapter provide power for both Arduino and LED strip? I thought I might need DC barrel Plug to alligator clips but I'm not sure as this is the first time I use an external power supply to power multiple components.
So what do I need to make that wall adapter able to power both Arduino and LED strip?


texts:
Can anyone explain to me why my output ip is: 15.16.17.18?

I configured my addresses as follows:

Arduino :
gateway 192.168.1.1
ipaddress 192.168.1.8
subnet 255.255.255.0

My local network:
gateway 192.168.1.1

ipaddress 192.168.1.3

subnet 255.255.255.0

Then when I print it, it shows
15.16.17.18

Arduino code:

#include <SPI.h>
#include <Ethernet.h>

// network configuration. dns server, gateway and subnet are optional.

// the media access control (ethernet hardware) address for the shield:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// the dns server ip
IPAddress dnServer(192, 168, 1, 1);
// the router's gateway address:
IPAddress gateway(192, 168, 1, 1);
// the subnet:
IPAddress subnet(255, 255, 255, 0);

//the IP address is dependent on your network
IPAddress ip(192, 168, 1, 8);

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

  // initialize the ethernet device
  Ethernet.begin(mac, ip, dnServer, gateway, subnet);
  //print out the IP address
  Serial.print("IP = ");
  Serial.println(Ethernet.localIP());
}

void loop() {
}

My output is:

IP = 15.16.17.18

Please help, thank you.


texts:
I have a loop command reading temperature sensor data from 8 thermistors and are storing them as floats into an array. Instead of printing to Serial on each iteration, I would like to create a comma separated string of these values and send to serial (in one instance, versus 8). What would be the best way to do this? I have tried sprintf commands to no avail.
Thanks in advance!
Edit: I would like to also write this string of comma separated values to a MicroSD card slot so I am under the assumption that creating the string once and printing to Serial AND saving to MicroSD card is more efficient than 8 separate iterations


texts: Duemilanove serial TX/RX: which is what?

texts:
I want to use the GSM shield. For my project, I will hook it up directly to pins 0 and 1 (TX/RX). Will it work right away? Do I have to know which is TX and which RX and declare it?

I will not be using SoftwareSerial.


texts: How to output a true analog voltage at output pin

texts:
Regarding my program, it is a program that does some calculations and then outputs a voltage based on the result using analogWrite function. However my problem is that I had done my programming based on a misconception that analogWrite function via PWM does output an analog voltage, where in fact it only "simulates" the analog voltage instead.

Here are the relevant parts of my code :

int pwmOutput = 11;
int pwm = 0;

void compareNewOldVoltageYes(void)
{
  if(pv_Vnew > pv_Vold && pwm != 255)
  {
    ++pwm;           //increasing value
  }
  else if(pwm != 0)
  {
    --pwm;           //decreasing
  }
}

void compareNewOldVoltageNo(void)
{
  if(pv_Vnew > pv_Vold && pwm != 0)
  {
    --pwm;
  }
  else if(pwm != 255)
  {
    ++pwm;
  }
}

void loop()
{
   reading();
   PowerCalculation();

   if(pv_NewP > pv_OldP)
   {
      compareNewOldVoltageYes();
   }
   else
   {
      compareNewOldVoltageNo();
   }

   analogWrite(pwmOutput, pwm);           //analogWrite

   float displayPWMvolt = pwm * 0.0196;

   Serial.print("Output Voltage: ");
   Serial.print(displayPWMvolt);
   Serial.println(" V");

   pv_OldP = pv_NewP;

   Serial.print("Previous Power: ");
   Serial.print(pv_OldP);
   Serial.println(" W");

}

As for the circuitry, output pin 11 is being connected to a 1 ohm resistor and then to GND. (Where I measured the voltage) I am using Arduino Uno board.

UPDATE:

As said in the comments by @DatHa, pwm does not output voltage. Is there a way to output voltage as said, without changing the board?


texts: Arduino IDE loses programmer after installing Visual Micro

texts:
I had this added to programmers.txt

mysmartusb.name=mySmartUSB light
mysmartusb.communication=serial
mysmartusb.protocol=stk500v2
mysmartusb.program.protocol=stk500v2
mysmartusb.program.tool=avrdude
mysmartusb.program.extra_params=-P{serial.port}

And was getting so annoyed with the loading time of Arduino IDE 1.8.5 so I tried Visual Micro but that didn't go well either. Now, Arduino IDE can no longer see my programmer. Tried rebooting, did a search for all programmer.txt files on the C: and deleted/updated as I thought appropriate. Has anyone else ever had that issue and if so, how did they solve it?


texts: Converting RGB from color sensor into the Munsell Color System

texts:
I am hoping I could get some help developing a an idea I have for archaeologists/soil scientists using an arduino and the TCS3200 colour sensor. The idea I have is a simple device which can determine munsell colours with more accuracy and speed. The current conventional method is to use colour chips/swatches found in the Munsell system booklet and match them as close to examples of sediment/soil found at archaeological sites. The problem with doing this method is that it is highly subjective, and time consuming.

My idea is to use the Adafruit TCS34725 to read and detect the RGB colour of the sediment (in the RBG colour space) and convert the data into the Munsell System. I have all the data of what RGB ratio corresponds to each Munsell colour -- which I have downloaded from this site: www.cis.rit.edu/research/mcsl2/online/real_sRGB.xls

My problem is that when I use the sketch provided, I can not figure out how to use the "if" statement to "Serial.print" what the munsell colour corresponds to the RGB colour detected by the sensor.

My ultimate goal is to modify the colour view sketch here see: colorview
I would like to keep the everything provided but change two things, I would like to convert RGB into Munsell using the data provided by the RIT link and also add a screen and button to start the read process and display the colour.

If some one would be willing to help me that would be great!,


texts: It looks like I broke my Arduino (Compatible) Pro Mini board using AtmelStudio to change the fuses. I was having trouble with speed and using some basic sketches. For example, the LED blink was on for 2 seconds and off for 2 seconds instead of 1 second. I tried to change the fuses to Ext Clock + 65 ms, and now I can't use the thing at all. Cannot enter programming mode. Any ideas?


texts: How do I activate emulation in the Coddeblocks Arduino IDE

texts:
I stumbled upon this question here, so I tried the Codeblocks alternative. After opening an Arduino Project, and leaving all options to default, I ran the Arduino version of the Hello World. A popup opened that requests a serial port to move on. What error did I do?

If more details are needed I'll answer the comments. Thanks in advance!


texts: updating firmware on arduino wifi shield

texts:
I'm trying to upgrade firmware on my wifi shield by following the upgrade instructions for Mac. I was wondering what this means?:

  Connect a jumper on the J3 connector, that put the shield in the programming mode. Then connect the USB cable to the shield USB mini socket

How can I do this?


texts:
I have an Arduino Nano which is Powered by an external Power supply. This is connected with VIN and GND. The voltmeter says, there are 12,12 V

I have some components connected on the 5V PIN, which altogether draw max. 100mA
Since some of the components are not working anymore, I started measuring...

I have disconnected everything, but the Arduino Nano Power supply. (12,12V)

When I now measure GND and the 5V PIN, the Voltmeter says 6,97V! I guess this is why my components are giving up.

But why are there 6,97 Volts all of the sudden?
Is my Arduino broken now?
Can I fix this?
How can this happen?


texts: What is the Mark and Space of Ir remote of Airtel?

texts:
Can you please tell me to find out Airtel IR Remote Mark and Space coding. I am making a project in which i have to Airtel IR Remote But I do not have decoding style of it. So please help me out. Any help will be appreciated.

Thank you


texts:
NewPing sonar(TRIG_PIN, ECHO_PIN, MAX_DISTANCE);

AF_DCMotor motor1(1, MOTOR12_1KHZ);
AF_DCMotor motor2(2, MOTOR12_1KHZ);
AF_DCMotor motor3(3, MOTOR34_1KHZ);
AF_DCMotor motor4(4, MOTOR34_1KHZ);
Servo myservo;

boolean goesForward=false;
int distance = 100;
int speedSet = 0;

void setup() {

  myservo.attach(10);
  myservo.write(115);
  delay(2000);
  distance = readPing();
  delay(100);
  distance = readPing();
  delay(100);
  distance = readPing();
  delay(100);
  distance = readPing();
  delay(100);
}

void loop() {
 int distanceR = 0;
 int distanceL =  0;
 delay(40);

 if(distance<=15)
 {
  moveStop();
  delay(100);
  moveBackward();
  delay(300);
  moveStop();
  delay(200);
  distanceR = lookRight();
  delay(200);
  distanceL = lookLeft();
  delay(200);

  if(distanceR>=distanceL)
  {
    turnRight();
    moveStop();
  }else
  {
    turnLeft();
    moveStop();
  }
 }else
 {
  moveForward();
 }
 distance = readPing();
}

int lookRight()
{
    myservo.write(50);
    delay(500);
    int distance = readPing();
    delay(100);
    myservo.write(115);
    return distance;
}

int lookLeft()
{
    myservo.write(170);
    delay(500);
    int distance = readPing();
    delay(100);
    myservo.write(115);
    return distance;
    delay(100);
}

int readPing() {
  delay(70);
  int cm = sonar.ping_cm();
  if(cm==0)
  {
    cm = 250;
  }
  return cm;
}

void moveStop() {
  motor1.run(RELEASE);
  motor2.run(RELEASE);
  motor3.run(RELEASE);
  motor4.run(RELEASE);
  }

void moveForward() {

 if(!goesForward)
  {
    goesForward=true;
    motor1.run(FORWARD);
    motor2.run(FORWARD);
    motor3.run(FORWARD);
    motor4.run(FORWARD);
   for (speedSet = 0; speedSet < MAX_SPEED; speedSet +=2) // slowly bring the speed up to avoid loading down the batteries too quickly
   {
    motor1.setSpeed(speedSet);
    motor2.setSpeed(speedSet);
    motor3.setSpeed(speedSet);
    motor4.setSpeed(speedSet);
    delay(5);
   }
  }
}

void moveBackward() {
    goesForward=false;
    motor1.run(BACKWARD);
    motor2.run(BACKWARD);
    motor3.run(BACKWARD);
    motor4.run(BACKWARD);
  for (speedSet = 0; speedSet < MAX_SPEED; speedSet +=2) // slowly bring the speed up to avoid loading down the batteries too quickly
  {
    motor1.setSpeed(speedSet);
    motor2.setSpeed(speedSet);
    motor3.setSpeed(speedSet);
    motor4.setSpeed(speedSet);
    delay(5);
  }
}

void turnRight() {
  motor1.run(FORWARD);
  motor2.run(FORWARD);
  motor3.run(BACKWARD);
  motor4.run(BACKWARD);
  delay(500);
  motor1.run(FORWARD);
  motor2.run(FORWARD);
  motor3.run(FORWARD);
  motor4.run(FORWARD);
}

void turnLeft() {
  motor1.run(BACKWARD);
  motor2.run(BACKWARD);
  motor3.run(FORWARD);
  motor4.run(FORWARD);
  delay(500);
  motor1.run(FORWARD);
  motor2.run(FORWARD);
  motor3.run(FORWARD);
  motor4.run(FORWARD);
}


texts: Serial.parseInt() reads from the serial buffer until it sees a non-numeric character or it's timeout is reached. When I use it, I put a space after the last number to make it return faster. Can I change the timeout so if I forget the number it doesn't take as long?


texts: How to choose between Lithium-ion vs NiMH batteries to power Arduino on the go.

texts:
For my next project I'd like to use a battery pack to power my Arduino.
I would also like to get a small solar panel and charging module to charge these batteries when possible (during the day).

What is the right type of battery for this kind of application?
What are the differences given this context?
What are the factors I need to consider when choosing a rechargeable battery for this application?


texts: How can I control my Arduino with my computer?

texts: I have an eye scanner python program on my computer and I want to make a motor, that is connected to an Arduino, move if it gets a certain signal. How can I make my python program in Pycharm/visual studio code send a signal to my Arduino and my Arduino read the signal?


texts: Scroll LCD display connected to an Arduino Uno

texts:
I want to make some characters scroll left without affecting the first positions in each row of my LCD 16x2 screen. I have this code inside the loop so far:

lcd .clear();
lcd.setCursor(17, 0);
for (int i = 15; i > 0; i--) {
  lcd.print("x");
  lcd.scrollDisplayLeft();
  if (digitalRead(switchPin) == HIGH) {
    lcd.setCursor(0, 0);
    lcd.write(5);
  } else {
    lcd.setCursor(0, 1);
    lcd.write(5);
  };
  lcd.setCursor(17, 0);
  delay(500);
}
lcd.noAutoscroll();

I think it should work, but the character x just moves left by one position, whereas the character in the first position, either in the first or second row doesn't appear at all.


texts: Cannot upload to Robotdyn Mega 2560 PRO MINI?

texts:
I get this error trying to upload avrdude: stk500v2_ReceiveMessage(): timeout

It is Robotdyn Mega 2560 PRO MINI and a Robotdyn CH340 which I have connected like this:

I installed the CH340 drivers from here https://sparks.gogo.co.nz/ch340.html and I can see it in the device manager.
Connecting the Mega 2560 Pro Mini lights up the L and On LED but when pressing upload (testing with simple examples as Blink) I get the error and neither RX or TX lights up.

I have tried everything I can think of. What am I doing wrong?

I have confirmed that it is connected to the correct COM-port and I use these settings:

Board: Arduino/Genuino Mega or Mega 2560
Processor: ATMega2560 (Mega 2560)

I have also tried many different USB-cables, short and long, and USB 2.0 and USB 3.0 ports. I use Windows 10 64-bit.


texts: Initialize object with PROGMEM constants

texts:
I have a class which has a const char * property:

    class A
    {
    public:
        const PROGMEM char* text;
    };

    void setup()
    {
        // A a{"Hello World!"};
        // A a{PSTR("Hello World!")};

        A a;
        a.text = PSTR("Hello World!");

        Serial.begin(9600);
        delay(30);
        Serial.println(a.text);
    }

    void loop()
    {
    }

I’d like to spare some RAM using PROGMEM.

How to initialize a object then?

Obviously, it can’t be like this:

    A a{PSTR("Hello World!")};

This will do:

    A a;
    a.text = PSTR("Hello World!");

However, I need to pass string to the constructor.


texts:
I have a led strip, and each led should be turned on sequentially, such as this one:
[http://1.bp.blogspot.com/-CTT6yvYtdos/VihhhBItwjI/AAAAAAAAAvM/q1jbUylMMdM/s400/ezgif.com-video-to-gif.gif][1]
The time delay between 2 consecutive leds is ts, and that time should be adjusted externally through a pushbutton switch. Each time the button is pressed, the time period shoud increment in a fixed amount.
I've already used the timerOne library, but it just works with a fixed time delay ts. How can I solve this issue with VARIABLE time delay?
I prefer to use interruptions rather than polling, since this system will be more complex (other buttons and variables will be involved).
Thanks!
Fernando


texts: Capture output from external device using Arduino Uno

texts:
I was unable to find this question anywhere but I want to use my Arduino Uno to capture the output of a Code 39 signal coming out of a separate device. Currently, my setup is similar to this:

I have a biometric hand reader that outputs a Code 39 signal along D1 while D0 stays at a constant 0 which can be seen here:

Ultimately, I want to use the Arduino Uno to take the input from the data line and convert the Code 39 signal to ASCII. The process should functions like this:

User enters their code into the hand reader and hand reader measures their hand
Reader outputs Code 39 signal to Arduino and software on Arduino converts barcode format to ASCII.

Note: I believe the Code 39 signal will represent something similar to this *12345*. The user ID code will always be five digits. * represent the start and stop characters for Code 39 barcode format

Arduino sends ASCII code to computer which checks remote database to ensure user is valid

I have my correct pins set as follows:

#include <SoftwareSerial.h>
#define D1 3
#define D0 2

void setup() {
    pinMode(D1, INPUT);
    pinMode(D0, INPUT);
}

Is it possible to either print out the binary representation of the signal via the Serial console or write to a file that I can view later on? My idea is to use the loop function to listen for the signals via digitalRead()

void loop() {
    digitalRead(D1);
    digitalRead(D0);
}

The last part is the thing I'm having an issue with since I can't seem to get the information printed to the serial console or written to a file. I tried this but it didn't work:

void loop() {
    foo();
}

void foo() {
    digitalRead(D1) == HIGH ? Serial.print("0") : Serial.print("1");
    Serial.println("");
    digitalRead(D0) == HIGH ? Serial.print("0") : Serial.print("1");
}

Any ideas on how to make this happen or is it impossible? I want to see the output of device so I can verify it's outputting what I think it is.

Lastly, I am using Visual Studio with the Visual Micro plugin so I can attempt to debug my code. I also have a OS X machine that has the Arduino IDE installed on it if I need a Mac for anything.

Addendum: I don't have ready access to an oscilloscope. However, I have tested this device on an oscilloscope and I did have output that seemed all wrong. I want to see what the arduino says it is to verify things before I continue with this project.


texts:
I want to know the purpose of using the EEPROM because I can't get it,
I mean I know that it can store values for a long time, but I just can't get the goal here

#include<EEPROM.h>
void setup()
{
  Serial.begin(9600);
  EEPROM.write(0,4);
  int s=EEPROM.read(0);
  int f=10;
  Serial.print(s);
  Serial.print(" ");
  Serial.print(10);
}

void loop()  {}

For example, I'm using EEPROM to see the difference if I print a value inside variable s to the serial moniter using EEPROM and a normal value inside the variable f.
But I couldn't find the difference between both because when unplugging the power and turn it on again, both of them are printed.
Hope you got the idea and I hope to see some feedback.
Thank you..

the LED program

then I made this program that will compare the EEPROM value to num.4 and compares the F variable to num.4
known that both F and the EEPROM values are 4.
and then I changed both of the values to 3.
shouldn't the GREEN LED of the EEPROM still on because it has already stored num.4??

#include<EEPROM.h>
void setup()
{
  pinMode(12,OUTPUT);
  pinMode(11,OUTPUT);
}

void loop()
{

  EEPROM.write(0,4);                 //GREEN LED
  int f=4;                           //RED LED

  if(EEPROM.read(0)==4) digitalWrite(12,HIGH);
  if(f==4) digitalWrite(11,HIGH);
}


texts:
On a 2560 MEGA I use serial(0) and serial1.

Serial1 is connected to an AT-328P   (not an UNO but a single AT controller)

The 2560 use Interrupt (serialevent) and Serial1Event.
Serial(0) is connected to the PC(USB) and is used to get commands that are planned to control both microcontrollers. And RX1 /TX1 (Serial1Event) is connected to the AT-328P .

I plan to use single letter Commands (eg. 'A' , 'B' .... 'Z') followed by a
delimiter (space or comma) again followed by 1 to 4 hexadecimals arguments.

EG:  "A 00,FFFF,AA,00"  or  "B,00,FFFF,33,00"  or "C 00,FF,FFFF,11"  or
"D 01,0000,FFFF,01" or "E,00,0910,1"

Valid delimiters are space, comma and Carriage Return

First argument is the number of the controller (00 = 2560 / 01 = AT328P, second to 4'th is the actual command to the controller.

The problem is parsing the command line from the PC. The one I use is far to slow (I scan the inputBuffer char by char and take my desiscion from that) - much to slow.

Now I want to parse the inputBuffer BEFORE I check the command letter (saving time and get the param's before I go into the specific subroutine) but here I  am i trouble.  I dont' know how to convert the 4 (2) Ascii chars into a valid HEX (or INT) -value.

I have seen some code somewhere ( and naturally forgotten where) doing it, but the methods I have used till now is oldfashioned and (far) out of date, and I am not very good to C++ (but I wanna learn it), so  I will be ashamed showing it.

Can any one give me an idea how to proceed .

Thanks

Kris AKA Snestrup2016


texts: How can I program my self made Arduino board using USB to TTL converter?

texts:
Recently I got a coupon for JLCPCB which was 100% discount so, I designed my 10 Arduino board specially for my needs and ordered it from JLC PCB. The schematic of the board is given.  At the time while I was designing the board I  thought of using USB to TTL converter which I have one having RX, TX, VCC and GND pins. So, I forgot to add pinouts for MISO which was D13 and also D12. So, how can I program my board now with that USB to TTL converter?
Describing about my board, it has a separate pinout for programming which has pins like GND, VCC, TX and RX. I tried but couldn't upload the program. Please help me out.
Forgot to mention, it uses ATMEGA328P-AU.


texts: The voltage level fluctuates whenever ESP8266 receives signal

texts:
Good afternoon dear community,

I am trying to built a WiFi communication with Arduino using ESP8266 module. There is one servo, one step motor connected to Arduino and whenever the ESP8266 Wi-Fi module receives a signal, the voltage level on the motor and servo fluctuate dramatically, which causes inaccurate results on how motor and servo behaves. I have connected the ESP8266 module using SoftwareSerial, and even when the signal is not transferred into motor or sevo, the voltage levels change whenever a data is received by the WiFi module.

Below is my code,

#include <Servo.h>
#include "SoftwareSerial.h"
SoftwareSerial softSerial(10, 11); // RX, TX

// Components:
Servo servo1;
Servo firstESC;

// Motor:
const int MAX_SPEED = 1850;
const int MIN_SPEED = 1200;
int armValue = 1500;
int speedIncrease = 20;
int speedDecrease = speedIncrease * 3;

// Direction:
int currentPos;
const int MAX_ANGLE = 120;
const int MIN_ANGLE = 60;
const int MID_ANGLE = 90;

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

   softSerial.begin(9600);
   // softSerial.setTimeout(10);

   // Setup servo:
   servo1.attach(9);
   servo1.write(90);

   // Setup direction:
   Serial.println("The motor is arming in 2 seconds, please wait.");
   firstESC.attach(8);

   // Arm the motor after 2 seconds:
   delay(2000);
   firstESC.writeMicroseconds(armValue);

   Serial.println("Serial is setting up, wait time: 3000 ms.");
   delay(3000);

   // Check board communication:
   softSerial.println("AT");
   delay(1000);
   while (softSerial.available()) {
     String message = softSerial.readString();
     Serial.println(message);
     delay(1000);
   }

   // Connect to WIFI:
   Serial.println("Connecting to wifi, wait time 4000 ms.");
   softSerial.println(--- COMMAND TO CONNECT WIFI ---);
   delay(4000);
   while (softSerial.available()) {
     String message = softSerial.readString();
     Serial.println(message);
     delay(1000);
   }

   // Wait for connection to be stable:
   delay(2000);

   // Get IP address:
   Serial.println("Requesting IP Address.");
   softSerial.println("AT+CIFSR");
   delay(2000);
   softSerial.println("AT+CIPMUX=1"); // Set multiple connection available.
   while (softSerial.available()) {
     String message = softSerial.readString();
     Serial.println(message);
     delay(1000);
   }

   delay(2000);

   // Set up server:
   Serial.println("Connecting to server..");
   softSerial.println("AT+CIPSTART=3,\"TCP\",\"192.168.1.67\",1235");
   delay(2000);
   while (softSerial.available()) {
     String message = softSerial.readString();
     Serial.println(message);
     delay(1000);
   }

   Serial.println("Set up is complete, loop started.");

}

String inString = "";
bool reading = false;

void loop() {

   while (softSerial.available() > 0)
   {
    char inChar = softSerial.read();

    if(inChar == 'O') {
      reading = false;
    }

    if(reading) {
      if (inChar == ','){
        Serial.println(inString);
        int val = inString.toInt();

        //Motor input
        if (val >= MIN_SPEED && val <= MAX_SPEED){
          setSpeed(val);
        }

        //Direction input
        else if (val >= MIN_ANGLE && val <= MAX_ANGLE ){
          setRotation(val);
        }
        inString = "";
      }
      else{
        if(inChar !='\0' && inChar != '\n' ){
          inString += inChar;
        }
      }
    }

    if(inChar == ':') {
      reading = true;
    }

   }

   if (Serial.available())
   {
      String message = Serial.readString();
      // Serial.print(message);
      setSpeed(message.toInt());
   }
}

void setSpeed(int customSpeed){
  firstESC.writeMicroseconds(customSpeed);
}

void setRotation(int angles){
  servo1.write(angles);
}


texts: Converting three axis magnetometer to Degrees

texts:
I do not know if here is the best place to post this question.
I have a 9-DOF sensor (MPU 9150) and I want to use its magnetometer to retrieve the rotation angle, from 0 to 359. However, its library returns three values: x, y and z.

I do not know how to transform this into a single value. There's any way to do this?


texts: How can I maintain switch state when in sleep mode?

texts:
I'm using a esp8266 to build a remote control to power a gas fireplace. I'm using this guide to try and maximize battery life.

The concept is the controller uses its built in WiFi to access a RESTful API on a remote server; If the API discovers"1", it should close a switch and the fireplace turns on. If the arduino reads a "0" via the API it opens the switch and the fireplace turns off. After discovery and performing the required action the unit calls Deepsleep and shuts off for ten seconds, whereupon it powers up and the cycle repeats itself again.

I just realized that if the controller powers off, I don't know what happens to the switch. If the fireplace was turned on,  what happens when deep sleep starts. Is there a way (special switch?) that maintains its state in deepsleep mode?


texts:
so I have a circuit with a buzzer and a resistor:

This circuit should be working, but for some reason the buzzer doesn't sound. I pushed the buzzer into the breadboard as hard as I could, I put the + side to positive and the - side to negative but it still doesnt work :(. How can I fix this?

Quick curiosity question: When I was doing electricity in school, the teacher just called the buzzers 'buzzers' but when I started doing arduino I noticed that the arduino community seems to call them 'Piezo buzzers/piezo speakers'. Is there any significance in the word 'Piezo' and should I start referring to them as 'Piezo buzzers' myself?


texts: Is it possible to connect a camera to an arduino?

texts:
I working on a project that requires a small camera to be covering a (insect) nest entrance. The video needs to be transmitted to a computer to be processed. I am interfacing with Java using the RXTX library and will then be tracking objects using OpenCV.

This is the camera

My question is, it it possible to connect this camera to an Arduino (Uno or Yun) and transmit the data back to a computer?


texts:
How do we measure 100 Volts Arduino LCD Proje

#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
int analogInput = 0;
float vout = 0.0;
float vin = 0.0;
float R1 = 100000.0; // 100K ohm direnç
float R2 = 10000.0; // 10K ohm direnç
int value = 0;
void setup(){
   pinMode(analogInput, INPUT);
   lcd.begin(16, 2);
   lcd.print("DC VOLTMETRE-PROJEHOCAM");
}
void loop(){
   // read the value at analog input
   value = analogRead(analogInput);
   vout = (value * 5.0) / 1024.0;
   vin = vout / (R2/(R1+R2));
   if (vin<0.09) {
   vin=0.0;
}
lcd.setCursor(0, 1);
lcd.print("VOLTAJ V= ");
lcd.print(vin);
delay(500);
}


texts: What do symbols like UCSR0C, UMSEL01, etc. means?

texts:
I have a code with a connection to serial port:

// Set baud rate
UBRR0H = UBRRH_VALUE;
UBRR0L = UBRRL_VALUE;
// Disable USART rate doubler (arduino bootloader leaves it enabled...)
UCSR0A &= ~(1 << U2X0);
// Set async, no parity, 1 stop, 9bit
UCSR0C = (0<<UMSEL01)|(0<<UMSEL00)|(0<<UPM01)|(0<<UPM00)|(0<<USBS0)|(1<<UCSZ01)|(1<<UCSZ00);
UCSR0B |= (1<<UCSZ02); // 9bit
// Enable rx/tx
UCSR0B |= (1<<RXEN0)|(1<<TXEN0);

I see the comments but I want to know exactly what does these chunks means. Is there any complete documentation about these symbols?


texts:
I bought this LCD module. How many pins does this LCD module uses? They have written in the product description that this LCD module uses 8 bit communication, but the LCD module has 16 bit pinout (DB0-DB15). What is the right pin number?

Is there any Arduino LCD library that supports this LCD module, which uses the OTM4001A LCD driver? Usually for LCD the UTFT library works, but it does not support the OTM4001A LCD driver.

Thanks for your help!


texts: Alternative Rx/Tx Pins for Arduino Uno and Pro Mini

texts:
Do they have specific pins that is best to be use as Rx/Tx pins (aside from D0 and D1)? If so, what makes them special?

edit: What pin feature i should look out for when choosing the rx/tx pin? Is there any specific pins that will make it a better rx/tx pin?


texts: Using RTC DS1307 and OLED on Arduino MEGA

texts:
I'm using RTC DS1307 and OLED on an Arduino MEGA together.

When I try to use a rtc code like
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
or DateTime now = rtc.now(); the OLED display starts not showing what i wish in "void loop".

The summary of the code is below:

#include "Arduino.h"
#include "U8g2lib.h"
#include "U8x8lib.h"
#include "RTClib.h"
#include "Wire.h"
#include "SPI.h"
U8G2_SSD1306_128X32_UNIVISION_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);   // Adafruit Feather M0 Basic Proto + FeatherWing OLED
RTC_DS1307 rtc;
void setup() {

  Serial1.begin(57600);
 if (! rtc.isrunning()) {
    Serial1.println("RTC is NOT running!");
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
     }
     if (! rtc.begin()) {
    Serial1.println("Couldn't find RTC");
    while (1);
  }
  Serial1.end();

  Serial2.begin(9600);
  while (!Serial2) {
    ; // wait for Serial2 port to connect. Needed for native USB port only
  }
  u8g2.begin();

  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_6x13_te);
  u8g2.drawStr(30, 25, "WELCOME!");
  u8g2.sendBuffer();
  delay(2000);
  Serial2.setTimeout(1100);
}

void loop() {
 u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_6x13_te);
  u8g2.drawUTF8(0,12,"EepromA");
  u8g2.setCursor(55,12);
  //u8g2.print(EepromA);
  u8g2.setCursor(100,12);
  u8g2.print("EepromA");
  u8g2.drawUTF8(0,22,"EepromB");
  u8g2.setCursor(55,22);
 // u8g2.print(EepromB);
  u8g2.setCursor(100,22);
  u8g2.print("EepromB");
  u8g2.drawUTF8(0,32,"EepromC");
  u8g2.setCursor(55,32);
//  u8g2.print(EepromC);
  u8g2.setCursor(100,32);
  u8g2.print("EepromC");
  u8g2.sendBuffer();
      delay(50);

}

It seems like it is about i2c of Arduino Mega but how to solve the problem?
Note: After a search on the website I found some similar problems, I have removed R2 and R3 pull-up resistors on RTC module, this did not solve it.


texts:
How do the IO registers of Arduino Due work?
On Arduino Uno just set DDRx, then PINx to read, PORTx to write, I'd like to do the same thing with an Arduino Due, but it has many more registers, such as PIO_OWER, PIO_OSER, PIO_CODR, PIO_SODR, etc. I find no correspondence between Arduino Uno and Arduino Due registers.

There are also some useful functions such as pio_clear, pio_set, pio_get, and others, all explained here:

http://asf.atmel.com/docs/3.19.0/sam3x/html/group__sam__drivers__pio__group.html

Now, I think I've understood what the three mentioned functions do, but not others, for example:

pio_configure (Pio *p_pio, const pio_type_t ul_type, const uint32_t ul_mask, const uint32_t ul_attribute)

I can't figure out what ul_attribute and ul_type are.


texts: Creating arduino library linking question

texts: I know how to create my own arduino library and use it. I am using Xcode to create a c++ project. I have the arduino library files(Servo, Wire, Keypad, etc). If I want to include the Servo.h library file in my created library, how do I go about linking that? For some reason, I can't just add the Servo.h/.cpp files in my project because then I get other linking file problems that Servo.h references and are not linked in my project. Has anyone done this before?


texts:
I have two different ESP32 development boards labelled "ESP32S v1.1 NODEMCU" (A) and "ESP32 DEVKITV1" (B).  From what I can tell they have the same major components, but their pins and general layout are quite different. I assume they are both knock-offs.

When uploading from the Arduino IDE, both read the same revision number and features:
Chip is ESP32-D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz

From what I can tell NodeMcu has something to do with the firmware for the ESP8266 (wiki)?  Also, it seems my ESP32S NodeMcu board doesn't have the standard pin layout for ESP32 boards.
What exactly is this NodeMcu board and what are the differences between the two?