texts: Problem with Adafruit_SSD1306 library in .h fie

texts:
I have a project which includes OLED display, so I decided to use Adafruit_SSD1306 library. But I have problem with compiling code, which uses this library, in another .h file.
When I use this library in .ino file, everythings works, but in OLED.h file I get this error:
collect2.exe: error: ld returned 1 exit status
Multiple libraries found "DallasTemperature.h"
 Used: C:\Users\luky\Documents\Arduino\libraries\Arduino-Temperature-Control-Library-master
Multiple libraries found "OneWire.h"
 Used: C:\Users\luky\Documents\Arduino\libraries\OneWire-master
Multiple libraries found "SPI.h"
 Used: C:\Users\luky\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\libraries\SPI
Multiple libraries found "Wire.h"
 Used: C:\Users\luky\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\libraries\Wire
Multiple libraries found "Adafruit_GFX.h"
 Used: C:\Users\luky\Documents\Arduino\libraries\Adafruit_GFX_Library
Multiple libraries found "Adafruit_SSD1306.h"
 Used: C:\Users\luky\Documents\Arduino\libraries\Adafruit_SSD1306
Multiple libraries found "SrcWrapper.h"
 Used: C:\Users\luky\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\libraries\SrcWrapper
Byly nalezené násobné knihovny "Adafruit_I2CDevice.h"
 Použitý: C:\Users\luky\Documents\Arduino\libraries\Adafruit_BusIO

The error is from this piece of code:
#include <SPI.h>
#include <Wire.h>

TwoWire Wire1(PB9, PB8); // Use STM32´s I2C2

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

STM32 Bluepill board is used.


texts: Not sure if programmer or ATMega is burned

texts:
some time ago i tried doing this with my original arduino uno r3. I guess i had to plug the power cables in wrong order(i think it's called reversing polarity)  because my arduino stoped working. It turns on (the power diode is on) but i cannot upload any sketch on it. I'm thinking about changing the ATMega chip but, before i do that i want to be certain that it's the chip issue ,not the programmer. I have another arduino uno, and i heard that i can upload sketch with it to another uno. So my idea is, if i do this i will be able to say whether it's the programmer or the chip issue. The only problem is that i don't know how to do this and i wasn't able to find any reasonable tutorials online. Please tell me what to do.
Many Thanks,
Jan


texts: avrdude: ser_open(): can't open device "\\.\COM4": Access denied

texts:
I installed the new IDE Environment 1.6.6 and I got this error when compiling a program. I am using an Arduino Uno

avrdude: ser_open(): can't open device "\\.\COM4": access denied

I need your help.


texts: Detecting an incoming 7.875 kHz pulse to use as trigger

texts:
I have written a code that detects an incoming pulse (square) of 7.875 kHz to trigger the output High for the entire duration of pulse, and trigger the output low if the pulse is off or not detected.
CODE
// Define pins
volatile int pulse1 = 2;    //incoming pulse 1 on pin 2

const int ledPin = 13;   //output to trigger LED

void setup() {

  pinMode(pulse1, INPUT);

  pinMode(ledPin, OUTPUT);

  // Timer Setup

  TCCR1A = 0;               // set entire TCCR1A register to 0
  TCCR1B = 0;               // same for TCCR1B
  TCNT1  = 65282;           // initialize counter value
  TCCR1B |= (1<<CS10);      // set prescaler to 8 bit
  TIMSK1 |= (1 << TOIE1);   // enable timer overflow interrupt

}
ISR(TIMER1_OVF_Vect){
  TCNT1 = 65282;
  attachInterrupt(digitalPinToInterrupt(pulse1), ISR_UV2, FALLING);
  }

void loop() {
  attachInterrupt(digitalPinToInterrupt(pulse1), ISR_UV1, RISING);

}

// Interrupt routines

void ISR_UV1(){
  digitalWrite(ledPin, HIGH);      // Send high signal
}

void ISR_UV2(){
  digitalWrite(ledPin, LOW);      // Send low signal
}

Is it the correct approach, or am I doing it wrong. One last thing that is bothering me is, every time I connect a wire (not connected to anything) to the input pin 2, it sends a high signal, and keeps the signal high until the Arduino is reset.
The pulse is a square wave 50% duty cycle generated by a device. I dont need to measure it or count it. I am just using it as a trigger to send a HIGH signal when it occurs. So it stays on (occurs) for 25ms & turns off during which its freq. is 7.875MHz & then it is repeated by the device according to the device parameters. I am aware it is a very short pulse but for the purpose of project nothing else can be used as the trigger
Any help will be appreciated.


texts: Upload sketch via Bluetooth using HC-06 module

texts:
I'm dealing with an application in which I need to upload sketches remotely to an arduino UNO board. I successufully managed to upload sketches using an HC-06 bluetooth adapter. The only problem is that I am forced to manually press the reset button once the bluetooth link is established. Is there a way to automatically reset the arduino, in a software or hardware way,  so that it will be able to accept and install the incoming and sketch?
Would it be enough to activate a digital pin connected to the reset at the right timing prior the upload process starts?


texts: Can Bluetooth HC-05 Module detect other modules and relay data back to phone?

texts:
I want the following to happen:

The HC-05 is paired to a phone. The module is called "Amy". The module is worn, say, as a wristband by a person.
Amy passes another wristband-with-HC-05-module called "Bob".
Amy inquires about Bob, and if the RSSI signal received is strong, it relays the name "Bob" to the phone which will somehow store the information in an app.
The HC-05 will pass many other modules, each with different usernames. A list of names will be stored by the phone app.
All other HC-05 modules, i.e. Bob and co. , would be doing the same thing with their own phones.

How feasible is this?


texts:
I am using WiFiEsp Library, ESP8266-01 Wifi Module, Arduino UNO and Arduino v.1.8.13.
ESP Details: AT version:1.2.0.0.
SDK version:1.5.4.1(39cb9a32)
v1.0.0.
The module is also in AT+CWMODE=1.
My module connection is as follows:
RX: Pin 6
TX: Pin 7
VCC: 3.3V
GND: GND
CH-PD: 3.3V
I have created a wifi hotspot on my phone which I try to connect to using the module, so that I can be able to pass some variables from arduino sensor to my php script which is hosted locally on phpMyadmin.
However, I can not seem to make the connection past connecting to wifi, since it says wifi shield is not present. Even the AT commands dont work.
What could I be doing wrong? Below is my code snippet:
#include "WiFiEsp.h"
// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif
char ssid[] = "Googz";            // your network SSID (name)
char pass[] = "********";        // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status
char server[] = "localhost/bella/espdata.php";

// Initialize the Ethernet client object
WiFiEspClient client;
void setup(){
  // initialize serial for debugging
  Serial.begin(115200);
  // initialize serial for ESP module
  Serial1.begin(9600);
  // initialize ESP module
  WiFi.init(&Serial1);
  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true);
  }

  // attempt to connect to WiFi network
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }

  // you're connected now, so print out the data
  Serial.println("You're connected to the network");

  printWifiStatus();

  Serial.println();
  Serial.println("Starting connection to server...");
  // if you get a connection, report back via serial
  if (client.connect(server, 80)) {
    Serial.println("Connected to server");
    // Make a HTTP request
    client.println("GET /asciilogo.txt HTTP/1.1");
    client.println("Host: arduino.cc");
    client.println("Connection: close");
    client.println();
  }
}

void loop()
{
  // if there are incoming bytes available
  // from the server, read them and print them
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

  // if the server's disconnected, stop the client
  if (!client.connected()) {
    Serial.println();
    Serial.println("Disconnecting from server...");
    client.stop();

    // do nothing forevermore
    while (true);
  }
}


texts: I am unable to run code on Arduino Due that I earlier ran on an Arduino Uno. The error indicates it is unable to recognize the library. Could this library access problem be due to difference of the micro-controllers of the 2 boards?


texts: global volatile variable not being updated in ISR

texts:
Running on atmega168p, I've got an interesting behavior I can't explain. A global volatile var that's called pos over here is not updated as it should. Once I add some code below the assignment, it starts working.

#define ENCODER_DO_NOT_USE_INTERRUPTS
#include <Encoder.h>

Encoder myEnc(A2, A3);

void setup() {
  Serial.begin(115200);
  while (!Serial); Serial.println("Started.");
  PCMSK1 |= bit(PCINT10) | bit(PCINT11) | bit(PCINT12);
  PCIFR  |= bit (PCIF1);   // clear any outstanding interrupts
  PCICR |= bit(PCIE1);
}

volatile int pos  = 0;
int oldpos = 0;

void loop() {
  if (oldpos != pos) {
    oldpos = pos;
    Serial.println(pos);
  }
  delay(100);
}

// PCINT10, PCINT11
ISR(PCINT1_vect) {
  pos = myEnc.read();
  //  adding digitalRead(A0)
  // or even Serial.println(pos) updates the var correctly
}

Switching from int to byte doesn't change anything. Encoder library is https://github.com/PaulStoffregen/Encoder. Any clues?


texts: power nodemcu with battery and LDO, what if battery is empty?

texts:
I've read a lot but im still confused..
i want to battery power my nodemcu while it will be mostly deep sleeping and waking up every 1-2 minutes.
i've seen the best way to power it with the least wasting power is though a lithium battery.
so i've bought a 18650 rechargable battery and a MCP1700 LDO which will give me constant 3.3V, that ill connect straight to 3.3V pin and bypass nodemcu's regulators as i understand from here
My question is: if all the previous are correct, what will happen when 18650 batter power fall down the 3.5V (3.3V + 0.2V (from MCP1700 dropout))
Will it stop automatically giving power at all? Will it provide less than 3.3V but it will harm nodemcu?


texts:
I have a small project I am working on that accepts power from either a 5v DC power source or a USB power source.
Now, I know that both of the power sources are effectively 5v. I have measured the power on both with my meter and can see that the USB supply is at 5.4 and the DC supply is at 5.01v.
I would like to be able to build something that switches over to the USB supply when the cable is connected. However, I have never done this before. I have taken a look around on Google already and have read some things about P Channel MosFETs and PowerPath controllers - but I am a little confused as to whether the two incoming voltages I have are suitable for this?
Would someone be able to give me a little advice on this at all?
Cheers,
Rafa


texts:
I have a function that dumps the contents of the arduino's ram, and it works, but I still dont understand why it says my stack pointer is at 0x08C9 If the ram of the arduino is 2kb, or 2048 bytes, shouldent the max addressable size be 0x0800?

RAM: SP->0x08C9 HP->0x0371 FREE:1368

And the code:

void printAddress(uint16_t val)
{
  Serial.print(F("0x"));
  if(val < 16)
{
 Serial.print(F("0"));
}
if(val < 256)
 {
  Serial.print(F("0"));
}
if(val < 4096)
{
  Serial.print(F("0"));
}
Serial.print(val,HEX);
}

void setup(){
Serial.begin(115200);
//0x0800 2048
uint8_t *heapptr, *stackptr;
stackptr = (uint8_t *)malloc(4);        // use stackptr temporarily
heapptr = stackptr;                     // save value of heap pointer
free(stackptr);                         // free up the memory again (sets stackptr to 0)
stackptr =  (uint8_t *)(SP);            // save value of stack pointer

Serial.print(F("RAM: SP->"));
printAddress(stackptr);
Serial.print(F(" HP->"));
printAddress(heapptr);//(int)&__heap_start);
Serial.print(F(" FREE:"));
Serial.print(stackptr - heapptr);
Serial.println();
}

As a note, Comments are not mine.


texts:
I'm trying to read in an analog signal (a heartbeat) to pin A0 on the Arduino Uno and then convert it to digital. I'm hoping to use the digital signal to make an LED light up every time the voltage of the heartbeat signal goes over 1 volt. This is the code I have right now, but something is wrong because it isn't lighting up the LED.

unsigned int analog0;             // Raw data from A0 ranging from 0 to 1023
unsigned long data_range = 2000;  // Length of time to record data for
double volts;                     // The analog data from A0 converted to volts
int ledPin = 13;
unsigned long start_time;
unsigned long data_time;

void setup() {
  Serial.begin(9600);             // Initialize and set serial port baud rate
  pinMode(ledPin , OUTPUT);
}

void loop() {
  start_time = millis();
  while ((millis() - start_time) < data_range)
  {
    // Record current time of analog acquisition
    data_time = millis();

    // Record analog data on A0
    analog0 = analogRead(0);

    // Convert raw data into voltage
    volts = (analog0 / 1023.0) * 5;

    Serial.print(volts);
    Serial.println();

    // Slow the rate of data acquisition
    //delay(1);

    if (volts > 1.5){
      digitalWrite(ledPin, HIGH);
      //delay(50);
    }
    else{
      digitalWrite(ledPin, LOW);
    }
  }
}


texts: 3.3v Arduino I2C communication with motor controller powered at ~6v

texts:
I am trying to just use the voltage from 4 Alkaline AA batteries in series (6v nominal) to power a motor with the TI drv8830 IC.

My question is, will this circuit (specifically just pulling the sda and scl pins to 3.3v) work reliably?   The datasheet says at maximum of 6.8v vcc the chip will still recognize 3.3v i2c lines (minimum 3.13V at that vcc voltage) but will the varying voltage of the battery cause the communication to be unstable?   There is a 10uf capacitor between vbat and gnd (not shown).


texts: Can two LEDs attached to different pins share their resistor?

texts:
I'm designing an Arduino style board with built-in LEDs for several of the pins. To simplify assembly of the board and save on components, I was wondering whether it would be safe for those LEDs to share a single resistor, as in this diagram:

Obviously, the power dissipated through the resistor (3mA per pin @ 3V) is not a real problem. The reason I was hesitating is that LEDs in a parallel configuration should not share resistors, but is it safe to think that separate microcontroller pins don't count as a common anode, even if both pins are high?


texts: Reading byte per byte from a txt file on SD Card without using the 512Bytes buffer

texts:
I am trying to read every sequenced-byte that is located on a txt file in the SD card. I have been reading quite a lot about the SPI and SD libraries, But I have found a lot of different information that makes me feel confused.

Is it really possible to read information byte per byte without buffering by default as usually happens when you use the SD or SDFat? Do you know a Library that makes it really possible?

Also, I found on the SDFile.cpp that is located in the src folder in the SD library, a part that mentions " // no buffering needed if n == 512 or user requests no buffering" How is it possible to request no buffering? I found the unbufferedread() function but I am afraid that this actually reads the number of bytes and not the information on the bytes (Is it possible?).
Do you know where may I found examples of this kind of low level functions for me to find out How may I use them  for the mentioned purpose. Or a library that would make my life easier in order to get the unbufferred read.
I want a continuous data sending into a DAC, that's why I am trying no to get the unbufferred in order to make all the data's sent as continuous as possible.

Sorry for making so many questions, I just started to use Arduino a couple of months ago  so I am not that familiarized with all the terms.
Thanks for your advise.


texts:
I have this Parallel LCD TFT. I want to connect it with an ESP32 (NodeMCU). I am using the TFT_eSPI library.
In the TFT_eSPI documentation, it says that the connection should be as following:

// The ESP32 and TFT the pins used for testing are:
//#define TFT_CS   33  // Chip select control pin (library pulls permanently low
//#define TFT_DC   15  // Data Command control pin - use a pin in the range 0-31
//#define TFT_RST  32  // Reset pin, toggles on startup

//#define TFT_WR    4  // Write strobe control pin - use a pin in the range 0-31
//#define TFT_RD    2  // Read strobe control pin  - use a pin in the range 0-31
//#define TFT_D0   12  // Must use pins in the range 0-31 for the data bus
//#define TFT_D1   13  // so a single register write sets/clears all bits.
//#define TFT_D2   26  // Pins can be randomly assigned, this does not affect
//#define TFT_D3   25  // TFT screen update performance.
//#define TFT_D4   17
//#define TFT_D5   16
//#define TFT_D6   27
//#define TFT_D7   14

P.S. My tft does not have DC PIN. So, I wired nothing to GPIO15

After I wired the TFT, the ESP32 stop responding to flash process. and obviously, it did not run anything(even if I flash it without the screen and then wiring it again)

My question is:

What is the mistake did I do? How can I link this parallel LCD with ESP32


texts:
First sorry for my bad english, not my native lenguage.

Today I started working on my Arduino nano (first time used). When plugged for the first time the "L" led started blinking, after that I tried to write a simple program but I noticed that the "Port" option on the Arduino IDE was Gray. So I couldn't choose the port. After that I searched A LOT but nothing seems to work.

While trying to test if the problem was the Arduino and not the PC, I make a simple circuit with 1 LED, 1 resistor of 1Kohm, and a breadboard. I connected the 5V pin to the LED and GNG to the other point, And when I did this the "L" LED stopped blinking forever. I am 100%  sure that I did not make a short circuit. ¿Maybe the breadboard is in a bad state?

Additional info:

-Windows 10.
-The port doesn't appear at Device manager (tried every port of my notebook).
-The "POW" led is ON when I plug the USB.
- The Arduino is a clone (chip CH340G).

So now I don't know if the problem is the port or if the Arduino Nano is dead because of a possible short circuit between 5V and GND pins.

thanks in advance!


texts: What is the purpose of putting a data type in brackets before a calculation?

texts:
sorry for the nooby question but I can't seem to find the answer to this anywhere, probably because I'm unsure what to search for with this problem!
I'm just wondering what the reason is for including a data type in brackets before a calculation takes place? In the code below, all the variables have already been declared at the top of the program, so I'm unsure what the reason / effect of including the (float) has. acc_y and angle_pitch_acc have been declared as floats and acc_total_vector has been declared as long
angle_pitch_acc = asin((float)acc_y/acc_total_vector)* 57.296;

Thanks!


texts:
I need some motor drivers that can control a DC motor with 10-15 A and 25 V. I can't find any shield that can do the job. I need to control 4 motors with these.

Can you suggest some models that are good with this?

And one more question: if a driver can control a DC motor in 2 directions, can it control 2 DC motors in one direction each?


texts: How to change colors and theme settings in 'Windows Store app' version of Arduino IDE?

texts:
In the standard Windows (Win32) version of the Arduino IDE, theme settings like syntax coloring can be modified in C:\Program Files (x86)\Arduino\lib\theme\theme.txt.

For the Windows Store app version of the IDE the theme files are stored in protected app storage space.

Is there a simple/safe way to change theme settings for the Windows Store app version of the IDE without messing up security settings and inadvertently lowering Windows security?

(It would be easier and better if theme settings could be moved to the ArduinoData user folder where preferences.txt is stored.)


texts: Will an in-circuit programmer mess up my board?

texts:
I am designing a circuit board that will contain, among other things, an ATtiny85 and an NRF24L01 module. I would also like to use an SOIC-8 ATtiny variant. In order to program this chip I will then need an in-circuit programming header. On the circuit board, many of the traces that go to the radio will also be electrically connected to the programming header.

I know that I can't power the ATtiny from a 5v source as this will mess up my radio. My question is if the programming signals from my ISP (Arduino Uno) will do something to the radio or if it will be OK for normal use after programming.

Edit:
MOSI and MISO and SCK will be connected to the programming header.


texts: Read from serial monitor and put it in a array of byte

texts:
I'm a new here and this is my first question.
I would like to read from serial monitor and stock the information in a array of bytes. then I want to print this array in serial monitor.
This is the code that I tried:

byte A[6];

void setup()
{
}

void loop() {
  A[6] = Serial.read();
  Serial.write (A);
}


texts: How to solve Atmega 16A Serial write (println) hang with Arduino Uno firmware?

texts:
For doing some experiments I bootloaded an Atmega16a with Arduino Uno. I am powering my Atmega16a from Arduino UNO. I am not using any external clock. Atmega16a is connected to a breadboard. For bootloading I refer the site http://hardwarefun.com/tutorials/use-arduino-as-an-isp-programmer-to-program-non-arduino-avr-microcontrollers I can run blink sketch on my Atmega16a using Arduino as ISP. TX and RX of Atmega16 is connected to Max485's DI and RO respectively.

Atmega16a pin 14 (RXD) -> MAX485 pin 1-RO
Atmega16a pin 15 (TXD) -> MAX485 pin 4-DI
Atmega16a pin 17 (D3)  -> MAX485 pin 2 and 3. Also connects a LED to the pin

I used a boards.txt downloaded from https://github.com/sudar/arduino-extra-cores/blob/master/boards.txt

Issue: hang at Serial.println

I faced issues when I started to interface with MAX485.

The program wont run if I add a Serial.println, see my program below.

void setup() {
   Serial.begin(76800); // I tried 9600 too
   pinMode(3, OUTPUT);
}

void loop() {
  digitalWrite(3, HIGH);
  delay(400);
  Serial.println("20"); //comment this code and could see the led blinks
  delay(2000);
  digitalWrite(3, LOW);
  delay(400);
}

Regression

I tried Latest Arduino IDE as well as 1.0.6 version

I could do a serial communication with Raspberrypi and Arduino Uno via MAX485 without any issues. For the complete connection detail of MAX485 and other Arduino, check my blog.

Some times I receive some string to serial port of Raspberry pi like below. I run a nodejs app in RPi, using serialport npm and parser is RAW.

<Buffer fa>
<Buffer 82>
<Buffer 86 ff>
<Buffer fe>
<Buffer fe>

How to prevent these hangs?


texts: 0.96 oled i2c display not working with my Arduino Nano

texts:
So what I've tried is: Changing the i2c address from 0x3D to 0x3C and it still doesn't work.

Ive also tried an i2c scanner and it hasn't worked either.

First I connected the screen like this: GND-GND, VCC-5V, SCL-A5, SDA-A4. And it didn't work. So I added some 10k pull up resistors at SCL-VCC and SDA-VCC, but it still didn't work.

In the picture you can see what I was trying to do. (This is a picture from a tutorial)

I tried looking at something similar on this website but it didn't really help much.


texts:
I want to bypass the PGA to change the input signal range from +/-2.5 to 0/5 V range.

I have taken the reference of example given in this library.

I have interfaced protocentral-ads1262-32-bit-precision-adc-breakout-board with Arduino Ethernet Board.

In the example, I have put #define VREF 5 but it shows the double the input voltage in serial window and when I put VREF 2.5, it shows regular input voltage.

For input voltage range 0 to 5V (single signal), I need to bypass the PGA but I dont know how to do it.

When the input signal is more than 2.5V then it always give the 2.5V only. If the input signal is, say 4.86V then it should give 4.86V but its gives 2.5V.


texts: Serial available doesn't work right after upload

texts:
I have 2 programs to test serial communication, an simple arduino program that echoes whatever is on the serial port and a python program that writes to the serial port and prints the reply.

I'm having an issue where whenever I upload the arduino program and try to run the python code the arduino code wouldn't detect serial available on the first run.  I would have to either

open and close serial monitor before I run python program
run the python program, quit, and run it again

and it would continue to work until I re-upload the arduino then the same thing happens.  Does anyone know what is the issue?  This is on Ubuntu.

arduino

String str;

void setup() {
// Turn the Serial Protocol ON
  Serial.begin(115200);
}

void loop() {
  if (Serial.available()) {
      str = Serial.readStringUntil('\n');     // Read the serial input
      Serial.println(str);             // sends ascii code

  }
}

Python

import serial

ser = serial.Serial('/dev/ttyACM1', 115200)

for i in range(0,4):
    str = "test string\n"
    ser.write(str)
    print ser.readline()


texts:
I've been at this all day, and I just can't seem to wrap my mind around how to use sprintf() to set a width for my string so that my characters are right justified.

What I'm trying to do is scooch my output over to the right on my touchscreen when the value is positive.
My output string is always a predictable length, so it seems like it should be easy.
I tried concatenating a string with just a space in it, and every other way I could think of to add a space to the beginning of my string. No luck.

char stringval[8] = 1.08;
char juststringval[8];
            if (hashpos > 0 && hashpos < 10) {

                sprintf(juststringval,  " %5s" , stringval);
                Serial.println(juststringval);
            }

output:

1.08 (no spaces in front)

In case you're curious why I need to use a string, my touchscreen will print floats, but my library won't rotate them properly.
Only strings can be rotated the way I need them.

Isn't there some simple way of doing this?

EDIT:

It seems I can use the width trick as long as I include some character besides an empty space.
For example:

void setup()
{
char stringval[33] = "1.08";
char juststringval[33];
char space[] = "rr";         ////THIS WORKS: OUTPUT IS  rr      1.08
float hashpos = 1.08;
if (hashpos > 0 && hashpos < 10) {

    sprintf(juststringval, "%s  %7s", space, stringval);
    Serial.println(juststringval);
}
}

void setup()
{
char stringval[33] = "1.08";
char juststringval[33];
char space[] = " ";     ////THIS DOESNT WORK. OUTPUT IS 1.08 LEFT JUSTIFIED
float hashpos = 1.08;
if (hashpos > 0 && hashpos < 10) {

    sprintf(juststringval, "%s  %7s", space, stringval);
    Serial.println(juststringval);
}
}

But I can't live with other characters in my string.
Isn't there something I can do?


texts:
I'm trying to upload a Blink example from Arduino IDE to an atmega8a via USBasp. I have edited the boards.txt file with the specifications of the atmega8a, and I am using the "Upload with programmer" option.

AVRdude gives no errors, only a warning that my usbasp firmware needs an update. I assume the code is uploaded, but it does not execute. My fuse settings are hfuse - 0xc0, lfuse - 0x9f, but i have tried different ones to no avail.


texts: Communicating Via Serial1 on Arduino Mega

texts:
Apologies if this a relatively simple question, but I am rather new to Arduino's and cannot seem to find any concise information on the topic.
This is my XBee, mounted on a shield and placed onto a MEGA 2560. I want to leave Serial for USB debugging and use the Serial1 for XBee communication.

Just to confirm, the two XBee's do communicate if I use SoftwareSerial.   This is the code that works using SoftwareSerial:
#include <SoftwareSerial.h>

// XBee's DOUT (TX) is connected to pin 10 (Arduino's Software RX)
// XBee's DIN (RX) is connected to pin 11 (Arduino's Software TX)
SoftwareSerial serial1(10, 11); // RX, TX
boolean nextLine = false;
void setup()
{
  Serial.begin(9600);
  serial1.begin(9600);
}

void loop()
{
   while(serial1.available()){ // there is data being sent from the xBee
    char read = char(serial1.read());
    if(read == 'A'){
      //Where ~ is the EOT character
      serial1.write("55.134~");
    }
  }
}

How do I communicate using Serial1?


texts:
I want to upload/pubish RAW IR Code to MQTT server received through my ESP8266. I have received the following RAW IR code from the Television using the IR receiver sensor:

RAW IR CODE = {
  4650,4250, 700,1550, 650,1550, 700,1550, 650,450,
  650,500, 600,500, 600,500, 600,550, 550,1700, 550,
  1650, 600,1650, 550,550, 600,500, 600,550, 550,550,
  600,500, 600,550, 550,1650, 600,550, 550,550, 600,500,
  600,550, 550,550, 600,500, 600,1650, 600,500, 600,1650,
  550,1700, 550,1650, 600,1650, 550,1650, 600,1650, 600
}

I want to create a new variable with the following structure:

value = RAW IR CODE+";" + "ESP8266-01"(This is the ID of the esp8266)

value =  {
  4650,4250, 700,1550, 650,1550, 700,1550, 650,450, 650,500,
  600,500, 600,500, 600,550, 550,1700, 550,1650, 600,1650, 550,550,
  600,500, 600,550, 550,550, 600,500, 600,550, 550,1650, 600,550,
  550,550, 600,500, 600,550, 550,550, 600,500, 600,1650, 600,500,
  600,1650, 550,1700, 550,1650, 600,1650, 550,1650, 600,1650,
  600
}; ESP8266-01

I am unsure: which data type do I need to save the variable value so that it can later be retrieved/subscribed and sent to another IR sender using irsend.sendRaw, because I want to split the variable "value" into 2 parts after receiving it, the ID and the RAW code. After getting the RAW code, I want to use the irsend.sendRaw(RAW CODE, length of RAW , 38).

Could someone help me?

My attempts:
At first I tried to save it as a string, so that it can be retrieved and separated for irsend.sendRaw. However I am unable to compile it.

This is the code which I used to upload:

      /*
     * IRremoteESP8266: IRServer - MQTT IR server
     * An IR LED must be connected to ESP8266 RX port (GPIO-3)
     * An IR receiver to GPIO 0
     * used library:
     * https://github.com/markszabo/IRremoteESP8266
     */
    #include <WiFiClient.h>

   #include <ESP8266WiFi.h>

 #include <IRremoteESP8266.h>
    #include <PubSubClient.h>
    int RECV_PIN = 0; //an IR detector/demodulator is connected to GPIO pin 0

    IRrecv irrecv(RECV_PIN);
    decode_results results;

    const char* ssid = "MY-SSID";
    const char* password = "MY-WIFI-PSK";

    const char* topicRaportPrefix = "esp8266/02/info/";
    const char* topicSubscribe = "esp8266/02/sender/#";
    const char* topicPrefix = "esp8266/02/";

    const char* mqtt_server = "10.10.10.10";
    const char* mqtt_user = "mqtt_user";
    const char* mqtt_pass = "mqtt_pass";

    String clientName; // MQTT client name
    char message_buff[100];

     void dump(decode_results *results) {
        const int count = results->rawlen;
          Serial.println(c);
          c++;
          Serial.println("For IR Remote ");
          for (int i = 1; i < count; i++) {

          if ((i % 2) == 1) {
            Serial.print("+");
            Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
        uint16_t  raw_ir_code[count] = results->rawbuf[i]*USECPERTICK;
            client.publish( "esp8266/02/sender", raw_ir_code);

After doing the changes proposed, I still get an error in compiling:

  no matching function for call to 'PubSubClient::publish(const char [18], uint16_t [(int)count])'


texts:
I want to pass the preprocessor values(AT commands) to the Serial.println function. Im trying TCP connection using arduino-SIM900A. I've declared all AT commands to each preprocessor variables like below

#define A "AT\r"
#define B "AT+CPIN?\"
...

I've assigned all preprocessor variables in char array and pass it into Serial.print using for loop.

char varAT[12]={'A','B'....};
for(int i=0;i<=12;i++)
{
Serial.print(varAT[i]);
}

Its not printing AT, instead it print preprocessor variable name A. I searched the google how to convert char value to variable, in C there is a function called "eval". Using eval we can acheive, but it wont work in arduino lang. How to solve this?

Thanks.


texts:
I have problem to send data from processing to arduino mega.

Processing Code :

import processing.serial.*;

Serial myPort;

void setup()
{
println(Serial.list());
String arduinoPort = Serial.list()[0];
myPort = new Serial(this, arduinoPort, 9600)
}

void draw()
{
byte a= 3;
myPort.write(char(a));
}

Arduino Code :

#include <Servo.h>
#include <Wire.h>

Servo myservo1;
Servo myservo2;

void setup()
{
Serial.begin(9600);
myservo1.attach(9);
myservo2.attach(10);
myservo1.write(90);
myservo2.write(90);

}

void loop()
{

if(Serial.available()>0){
myservo1.write(70);
myservo2.write(70);

}

}

Code is really simple, processing send a value to trigger arduino mega turning 2 servo
motors.

But it doesn't response at all..
Please help if anyone has any clue.

Thanks :))


texts: AMIS30543 - Library code | Order of pinDirection and pinOut

texts:
This piece of code was taken from AMIS30543- Arduino library,
void init(uint8_t slaveSelectPin) {
    ssPin = slaveSelectPin;
    digitalWrite(ssPin, HIGH);
    pinMode(ssPin, OUTPUT);
}

Facts I know

digitalWrite - makes the pin to the corresponding voltage level
pinMode - makes the pin either input or output
ssPin is active low pin usually.

So I was wondering before setting the pinDirection why the pin is made HIGH, Then immediately after that the pinDirection was declared as OUTPUT
Also I know , if a pin was made HIGH and on the next line if the direction of the same is set as  INPUT will bring the internal pull up resistor in action .
So what am I missing here. More over in Arduino does the order of pinMode/digitalWrite matter.? if So what is the meaning of this particular lines of code Github link to the library


texts: Updating Array Values Incrementally Overwrites The Existing Values, Why?


texts: Esp8266 12E is printing random characters whenever I reset the board, not even uploaded a code

texts: I have a nodemcu esp8266 12E board. It's working properly, but whenever I reset it, it prints random characters like ??I%^, even if hasn't a code uploaded in it.


texts: Nothing is working even though every thing is right & it is new?

texts:
I have bought a new 'SunFounder Arduino uno R3' and started learning, the first lesson was 'Blinking LED' of course.

I have done it all, connected Jumper-Wires and the Sensor and the LED light, I wrote the code:

const int ledPin = 9;
void setup()
{
   pinMode(ledPin,OUTPUT);
}
void loop()
{
   digitalWrite(ledPin,HIGH);
   delay(500);
   digitalWrite(ledPin,LOW);
   delay(500);
}

BUT NOTHING HAPPENS !!!, I checked out every thing over and over, it just does not work ???
Every thing is well about the board and the UNO R3 it is new.
I have checked the code and the connections and checked the Device Manager to know that the serial port of the arduino is 'COM3'...
I dont know what is wrong with it ?!!


texts: nRF24L01+ RF24 library - can send but can't receive

texts:
I'm prototyping out a board with temperature, humidity, windspeed sensors, and using an NRF2401+ board to send values to a Raspberry Pi base station that will record the data.

Using a Leonardo clone board, I'm able to successfully run the pingair_dyn sketch to send test payloads to the RPi and receive acks.  (So I know the RPi can send and recieve OK.)

Moving the same NRF2401+ to a breadboard setup with an ATMEGA328P-PU, the same sketch can send payloads which are received on the RPi, but always hits the timeout trying to get the ack (which the RPi is dutifully sending).

In fact when running pingair_dyn as a receiver, it just spins in the loop waiting for radio.available() to return true, which it never does.

The immediate problem is that radio.available() is always returning false.  So basically I can send but can't receive.

I have checked my wiring several times, and I'm mostly confident that it's right.

  CE - physical pin 14 (arduino digital pin 8 )
  CSN - physical pin 13 (arduino digital pin 7)
  SCK - physical pin 19, per atmega328 datasheet
  MOSI - physical pin 17, per datasheet
  MISO - physical pin 18, per datasheet

In the software, I construct the RF24 instance:

  RF24 radio(8,7);

Any ideas?  I tried swapping CE <--> CSN, then nothing worked.  Is there some wiring problem that would cause XMIT to work but RECV to fail?

I've tried putting a 2.2 uF capacitor across the 3.3V - GND as I've seen mentioned in other threads, but no difference.

Any suggestions on what is useful information to dig out of the RF24 library to give some idea of what's going on?

More background

Here is the RF24 debug info from the mega328

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

Here is the debug info from the base station (Raspberry Pi):
pyRF24/examples/pingpair_dyn/

================ SPI Configuration ================
CSN Pin          = CE0 (PI Hardware Driven)
CE Pin           = Custom GPIO22
Clock Speed      = 8 Mhz
================ NRF Configuration ================
STATUS           = 0x0e RX_DR=0 TX_DS=0
MAX_RT=0 RX_P_NO=7     TX_FULL=0         RX_ADDR_P0-1     =
0xe7e7e7e7e7 0xc2c2c2c2c2
RX_ADDR_P2-5     = 0xc3 0xc4 0xc5 0xc6
TX_ADDR          = 0xe7e7e7e7e7
RX_PW_P0-6       = 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA            = 0x3f
EN_RXADDR        = 0x03
RF_CH            = 0x4c
RF_SETUP         = 0x07
CONFIG           = 0x0e
DYNPD/FEATURE    = 0x3f 0x04
Data Rate        = 1MBPS
Model            = nRF24L01+
CRC Length       = 16 bits
PA Power         = PA_MAX


texts: I have a project made with Arduino, and I want to replace it by a miniaturized circuit with just a microcontroller. Is there any tutorial that can guide me in doing this? Any reference is wellcome. Thank you!


texts:
I have a nice sketch running which monitors a few things and displays output on an OLED display. Now I want to save the data to an SD card, but with or without the card module attached I'm getting constant reboots when I add 1 single line of code:

#include <SD.h>

Any idea what may be happening?


texts: How to detect patterns in an FFT output?

texts: I have an FFT output from a microphone and I want to detect a specific animal's howl from that (it howls in a characteristic frequency spectrum). Is there any way to implement a pattern recognition algorithm in Arduino to do that? Thanks!


texts: Use of progmem in ESP8266 vs AVR and also how to handle large dynamic strings

texts:
This is a somewhat tricky question dealing with implementation and best-practices of the ESP8266. I'd ideally hope that it's answered by people with in-depth knowledge on the problem.

As you are hopefully aware, the Arduino (AVR) platform requires the use of the PROGMEM or F() instructions to avoid copying all strings to RAM. The ESP8266 platform also provides a PROGMEM instruction, but is memory-mapped.

I thus have several questions about what the PROGMEM instruction actually does on the ESP8266.

For the next few questions, until otherwise marked, I am referring to character-array-style C strings, not the Arduino String type.

Storage of constant strings: If I were to declare a string (global, for now) on the ESP8266, would it be read from flash only when it's accessed, or will it always take up RAM (like it would on the AVR. Assume that in this case I do NOT declare it as PROGMEM; I wish to find out what the default behavior is on the ESP8266)?
Local Constant Strings: What happens with strings that are used inside a function? I am fairly sure that they ALSO exist in RAM, at least in AVR. Does the ESP8266 do this too, or does it (potentially) store it in flash until it is read (it is fine if it ends up inside a cache somewhere, as long as it can be evicted if needed)?
Use of String(F("mystring")): If I wrap a PROGMEM string in this manner, does this truly convert the string into a RAM-based string only when this line is reached, or does this for some reason initialize the String() early (and consume the RAM anyway)? Do the systems differ in this behavior?
If I define several instances of the above (as in, the identical wrapped string shown above appears several times, perhaps in different functions), do all of them point to the SAME F() instance (since they are identical) or does it get duplicated since it's part of code rather than a referenced variable? On ESP8266? On AVR?
On the ESP8266, I discovered that the server.on() function for the built-in webserver read F()'d constant strings just fine, but failed to work once the file grew beyond the size of the RAM. It was clearly stored correctly, but it could not be read. I thus conjecture that the method was making a local copy to RAM, even if the file was stored in Flash. There was also a on_P version that worked after that point (I believe I used PSTR rather than F at this point as well, since -- correct me if I am wrong -- the two are not compatible). Is this the real point of PROGMEM on ESP8266? That the data is only stored in Flash, but it also tells the function reading it to make as few copies as possible or chunk it?

I am also curious what happens with large strings that aren't constant. The web server can return data that was passed via querystring, for instance, which in my case can be quite large. If I copy that data to a string (and then into a function), does it pass the heap pointer directly, or does each String make a new copy? I am concerned about fragmentation or other fun ways of running out of RAM even if one copy should in theory fit.

Does doing something like bool myFunction(String &str){...} help? Some sort of way to actually ensure that it's the same string, rather than copying (and can I do String &myStr=server.arg(...) -- is a return value different from an assignment)? It's confusing for me, since strings are clearly passed by value, despite being a complex datatype with dynamic memory somewhere in there. So, did they override the assignment operator (and/or the one that handles reference passing, since I think there's more than one) to duplicate the string as pass-by-value of a basic type would normally do, or do they share pointers (and thus memory) as a class passed-by-value would normally do?


texts: Multiple node network communication over I²C

texts:
I am working on a project where I want to send data from and to different Arduinos on a network. At the moment I²C seems the best option for my needs since I can specify where to send the data. But using this method I have a bit of an issue I can't seem to find a solution for :(.

I will try to explain my problem using the following image:

In the backend all the nodes are connected like in the first image (above the example network). But the nodes may be connected in a different sequence by a user. See the example network.

In this example network, the node with ID 1 needs to send data to ID 10 and not to any other node on the network. Node ID 12 also needs to send data to node ID 10, but no other nodes. Etc. Etc. Etc. But the node that needs to send data to the next node doesn't know the id of the node it needs to send to.

So at first the nodes need to find out what nodes they are connected to and where they need to send their data.

I thought of doing this by connecting a wire between each node (blue wire in possible solution) and when a node gets added to the network the nodes send a high signal over the blue wire and sends its ID to all nodes on the network and then all nodes on the network check if they receive a high signal and an ID.

If this is true they will send its id to the node that has been added. This works fine if you add a node one by one to the network. But it fails when you replace a node in the middle of the network or disconnect power from the network.

What would be the best way to do this (I am also open to use different data transfer protocols)?


texts: Defining an NFC tag as NDEF using the Arduino Uno and the PN532 NFC module

texts:
I bought a bunch of blank Mifare Classic NFC cards and I'd like to write NDEF records to them using my Arduino Uno. When I read them using my Uno and a PN532 NFC module using Don's NDEF library however, it tells me they're not NDEF formatted.

Is there any way to define my NFC tags as NDEF using just the PN532 module and an Arduino Uno? (My Android phone doesn't support NFC.)


texts: How much low analog voltage can Arduino uno read?

texts:
Today I was playing around with arduino analog voltage ranges, the error in output
 with respect to a digital multimeter started to happen when the reading was around 0.0014volts. How much low an arduino can read?


texts: Sharing serial Rx to read a push button on ESP8266-01

texts:
I'd like to know if it's possible, and if so how to use the serial Rx pin in a shared way to read a push button?

I've seen people using it in sort of a dedicated way but my idea is to use it dynamically. Which means it would stay as a standard Rx pin, with a push button sharing it. So the question is, what would happen if the push button was pressed? Would it be possible to detect it from the Rx stream?


texts:
According to this example, creation of an Arduino library is quite understandable.

But a few things I would like ask (mostly regarding to what to be defined where) when a library is not that simple:

Where to put additional libraries (such as <Wifi.h>) in .h or .cpp, since it works when defined in each one of them?
What is the purpose of defining variables in the :private section? Since they can be defined inside constructor, and as far as I know/tested, it works as well.
In a .cpp file, does it matter when instances or variables are defined outside a class (at the beginning of code ), since again, it works the same?


texts: Http request in interrupt esp8266 not working

texts:
So i have this code that whenever i click a button a interrupt starts.
In this interrupt i want to do a get request to a webserver.

The thing is seperate the code, the interrupt code works and without an interrupt the http request also works.
But when i put this together it doesn't.

Does anybody have an idea why this doesn't work?

// Libraries
#include <ESP8266HTTPClient.h>
#include<ESP8266WiFi.h>

char ssid[] = "";
char pass[] = "";

int ledpin = 5; // D1(gpio5)
int button = 4; //D2(gpio4)
int buttonState=0;

ICACHE_RAM_ATTR void ISR() {
  static unsigned long last_interrupt_time = 0;
  unsigned long interrupt_time = millis();

  if (interrupt_time - last_interrupt_time > 200)
  {
      Serial.println("Drukknop ingedruk");
      Serial.println("Sending message to server");
       if (WiFi.status()==WL_CONNECTED)
      {
        HTTPClient http;
        String url="<httpurl>";
        http.begin(url);
        http.addHeader("Content-Type","text/plain");
        int httpCode=http.GET();
        Serial.println(httpCode);
        String payload=http.getString();
        Serial.println("While sending I received this from server : "+payload);
        http.end();
      }
      else
      {
        Serial.println("Internet Problem!");
      }
  }
  last_interrupt_time = interrupt_time;
}

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid,pass);

  while(WiFi.status() !=WL_CONNECTED)
  {
    delay(500);
    Serial.println("Waiting for connection");
  }

  Serial.println("Connected...");
  delay(1000);
  if (WiFi.status() ==WL_CONNECTED)
  {
    Serial.println("Wi-Fi Connected!");
  }
  delay(5000);
  Serial.println("ok");
  pinMode(button, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(button), ISR, RISING);

}
void loop() {

}


texts:
I'm wanting to power a USB device from an Arduino Uno. Forgetting about the two data pins, it just requires power. Using a power meter, I can detect the 5v pin at about 4.95 volts, however I don't have access to any resistors at the moment so cannot test the amperage because it just shorts.

The USB device I want to power requires ~300mA (can't remember specifically). First of all, does the Arduino get 100mA or 500mA when getting power from the USB? Is this changeable depending on the setting on the USB Host (High 500mA, or Low 100mA)?

Secondly, how much would actually be usable? I assume the Arduino itself would require some of that current? Even more if a program where running on it at the same time? (I have no idea how computers utilize power) I would like to just hook up my usb device to ground and 5V with whatever resistors (and any other electrical components) in between to bring it down from 500mA to the required ~300mA.


texts:
I'm getting a "'Serial' does not name a type" error when this program is compiled. I need for the 8 channels of voltage to be displayed. I'm sure it's a simple fix, however I'm still learning Arduino programming. I thank you for your help.

int pin_Out_S0 = 8;
int pin_Out_S1 = 9;
int pin_Out_S2 = 10;
int pin_In_Mux1 = A0;
int Mux1_State[8] = {0};
//float Mux1_State[i] =0;
int RawValue=0;
float Voltage = 0;
void setup() {
  pinMode(pin_Out_S0, OUTPUT);
  pinMode(pin_Out_S1, OUTPUT);
  pinMode(pin_Out_S2, OUTPUT);
  pinMode(pin_In_Mux1, INPUT);
  Serial.begin(9600);
}

void loop() {
 RawValue = analogRead(pin_In_Mux1);
 Voltage = (RawValue * 5.0) / 1024; //scale the ADC
  updateMux1();
  //Serial.println(Mux1_State);
  for(int i = 0; i < 8; i ++) {
    if(i == 7) {
      Serial.println(Mux1_State[i]);
    } else {
      Serial.print(Mux1_State[i]);
      Serial.print(",");
      //vout = (value * 5.0) / 1024.0;
    }
  }
}

void updateMux1 () {
  for (int i = 0; i < 8; i++){
    digitalWrite(pin_Out_S0, HIGH && (i & B00000001));
    digitalWrite(pin_Out_S1, HIGH && (i & B00000010));
    digitalWrite(pin_Out_S2, HIGH && (i & B00000100));
    Mux1_State[i] = analogRead(pin_In_Mux1);
  }
}
Serial.print("Raw  Value = " );
Serial.print(RawValue);


texts: Adafruit Huzzah ESP8266 Battery Power issue

texts:
I'm trying to connect a ~5.5V (2 x 3V coin cells in series, but their voltage drops a little) to the VBat (or V+) of my Adafruit Huzzah ESP8266 module (not the black Feather one, the smaller blue one: https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/pinouts)
Whenever I do that the voltage output from the 3.3V pin drops to ~0-1 V and thus the ESP stops working.

However when I use the FTDI cable (3.3 V) and connect it to my laptop, there is no problem, I get almost 3 V.

I also added a 1000mF capacitor to smooth out voltage signals and actually that also helps to increase the volt a little (without it I get almost a 0 V on the 3.3V output)

Any ideas?


texts: Rfid reader and SD card shield won't work together

texts:
I recently encountered a problem that's been bugging me for days. I want to make a project using a RFID reader and log data on an SD card with an Arduino Nano, but apparently no matter what I do, I can't seem to make them work together on SPI. They both work individually, and the SD shield works in parallel with the RFID reader, but the RFID doesn't work in parallel with the SD shield.

I'm absolutely sure that the wiring is correct, slave select on both modules are wired to different digital pins, and both are connected through bidirectional level shifters.

I noticed that the RFID reader works fine when I disconnect the MISO pin from the SD shield. I tried putting a diode between SD MISO and digital pin 12, I tried adding pullup resistors on both SS pins, I tried adding resistors on MISO lines, I tried pulling HIGH the SS i don't use, and low the one I want active. Nothing seemes to work and I'm out of ideas. The last thing I will try is conencting the modules on separate VCC, but I don't have faith that it will make any difference.

I hope someone has some advice for my problem.

Thanks in advance


texts:
For the last couple of day I've been trying and failed many times just to not use the delay() funtion in Arduino. I have to admitted that my coding skill are extremely bad.

What i trying to do is:
If button is pressed:
Motor A and B move for 1 second at slow speed == > Motor A keep moving but at fast speed and motor B stop.
else:
Motor A and B both stop.

I managed to wrote the code by using delay function for that 1 second. However i got no idea how to do it WITHOUT DELAY() there will be sensor reading as well at the same time, i cant afford that 1 second delay of sensor reading).

Here is my code:

int dir1PinA = 2;
int dir2PinA = 3;
int speedPinA = 9; // Needs to be a PWM pin to be able to control motor speed

// Motor 2
int dir1PinB = 4;
int dir2PinB = 5;
int speedPinB = 10; // Needs to be a PWM pin to be able to control motor speed

int button = 6;

void setup() {  // Setup runs once per reset
// initialize serial communication @ 9600 baud:
Serial.begin(9600);

//Define L298N Dual H-Bridge Motor Controller Pins

pinMode(dir1PinA,OUTPUT);
pinMode(dir2PinA,OUTPUT);
pinMode(speedPinA,OUTPUT);
pinMode(dir1PinB,OUTPUT);
pinMode(dir2PinB,OUTPUT);
pinMode(speedPinB,OUTPUT);

// Define button pin
pinMode(button,INPUT);

}

void loop() {
  if( button == LOW){           // if button is pressed
    // Motor A (move slow) and B  moving
    analogWrite(speedPinA, 100);//Sets speed variable via PWM
    digitalWrite(dir1PinA, LOW);
    digitalWrite(dir2PinA, HIGH);
    analogWrite(speedPinB, 255);
    digitalWrite(dir1PinB, LOW);
    digitalWrite(dir2PinB, HIGH);
    delay(1000);

    // After 1 second Motr A (move fast)and B stop every time button pressed
    analogWrite(speedPinA, 255);//Sets speed variable via PWM
    digitalWrite(dir1PinA, LOW);
    digitalWrite(dir2PinA, HIGH);
    analogWrite(speedPinB, 0);
    digitalWrite(dir1PinB, LOW);
    digitalWrite(dir2PinB, LOW);
  }
  else
  {
    // Both motor not moving
    analogWrite(speedPinA, 0);//Sets speed variable via PWM
    digitalWrite(dir1PinA, LOW);
    digitalWrite(dir2PinA, LOW);
    analogWrite(speedPinB, 0);
    digitalWrite(dir1PinB, LOW);
    digitalWrite(dir2PinB, LOW);
  }
}

Please point me out the direction or give me an example of code. And I have already try the Blinkwithoutdelay Arduino example but it does not work for this case.

Very much appreciated.


texts: What is the best board for setting up an SSH protocol to an Arduino?

texts: I currently have a project using an Arduino R3, set up across the room from my computer. This has become quite annoying, as every time I want to push something to the Arduino I have to get up and move either the computer or the Arduino to another location, plug it in, and hope my code works the first time, lest I have to repeat the test over and over again. I am trying to set up an SSH server between my Raspberry Pi 2 and computer so I can just push new sketches over SSH, however, I use my Pi 2 for other projects occasionally and want to purchase a second board specifically for this purpose. Is there a good, cheap, board with wifi built in (besides the Pi 3) that I could use for this? Any suggestions?


texts: Do multiple ultrasonic sensors need an external power source?

texts: So maybe it's a very low class form of question, but please bear with me. I'm working on a project with 7 HC-SR04 ultrasonic sensors connected to one Arduino. I tried to unify the trigger and echo pin, but the sensing isn't good enough, so I dropped the Uno and convert it to Mega. My question is, do I need external power source for those 7 Sensors? And how do I connect all of them? Thanks


texts: Print out times tables from 1 to 10 with array

texts:
I would like to Serial.print(); the multiplication tables, 1 - 10. This is my work so far. Is there an easier way to do this with array? Thanks

// "MultiTable"

//Define global array, is this needed? Makes no difference for my output in serial monitor.
//int number[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

//Define variable
int prod;

void setup() {
  // Open serial connection at 9600Bd
  Serial.begin(9600);
}

void loop() {
  //Print the times table for 1

  for(int i = 0; i <=9; i=i+1) {
   prod = i*1+1;
   Serial.print(prod);
   Serial.print(",  ");
  }

  Serial.println();
  delay(3000);
  Serial.println();

//Print the times table for 2

  for(int i = 0; i <= 9; i=i+1) {
  prod = i*2+2;
   Serial.print(prod);
   Serial.print(",  ");
  }

  Serial.println();
  delay(3000);
  Serial.println();

//Print the times table for 3

  for(int i = 0; i <= 9; i=i+1) {
  prod = i*3+3;
   Serial.print(prod);
   Serial.print(",  ");
  }

  Serial.println();
  delay(3000);
  Serial.println();
}


texts: Arduino Nano and SIM800L on Battery Power

texts:
I'm very new to Arduino and everything related but I'm highly interested to learn more. However, I've run into a problem right in the beginning.

I want to build some sort of portable emergency/notification button. One pushes the button and an SMS is sent or an HTTP call made to a server. I want to base this project on the Arduino Nano as it's quite small and therefore easily transportable. To have GSM/GPRS connectivity I found the SIM800L which seems quite suitable to what I have in mind. Now to the big question, how to power the Arduino Nano as well as the SIM800L on an portable power source, preferrably only one power source.
From my understanding, the SIM800L requires a peak current of 2A when doing handshakes and sending signals. Is there any way I can power the SIM800L through the Arduino Nano, like Battery -> Arduino Nano -> SIM800L, or do I need to connect both the Arduino Nano and the SIM800L to the battery?
Regarding the lifespan, for now it would be sufficient if I could press the button a few times and afterwards it'd stop working.


texts: How to connect D1 mini and ATTINY85 over data wire

texts:
I’m trying to connect my D1 mini module and attiny85 USB module together over a data wire, but I don’t know how to do it.
Basically, what I want to do is have the D1 broadcast a hotspot with a web page that when a button is pressed, it sends a signal to the attiny85. The D1 is connected via power wires to the attiny85.
I have the sending signal and web server setup on the D1 but I don’t know how to let the attiny85 receive it.
If it helps, I’m using the wire.h library on the D1
(edit: sorry for inactivity, just haven’t been able to test it)


texts: can this piece of a camera flash send an input signal to my arduino?

texts:
I have a piece of a broken camera flash (an old Yongnuo one) that has a single pin that tells the flash when to fire. The pin looks like this :
(I guess the ring is the return/ground?)

The other side of the piece looks like this:

If my guess isn't completely wrong, those four wires are the only thing that tell the rest of the flash unit what's going on, when. So if I plugged (two, three, all four?) of those pins into my arduino I could use it as an input, yes?

I.e. Arduino would detect when the camera has taken a picture via this unit, and do something else (in my case open the gate on a mos for a length of time). No actual camera flash involved (just the signal)

My question is: how do I determine which of these four wires carry the signal to the rest of the circuit, and can I plug this into my Arduino input pin? My multimeter is a cheap crappy one so I don't think it would react fast enough to measure a pulse like that...


texts:
This is a home heating system hack.

I want to add an arduino in-line between my thermostat and air handler; and possibly between the air handler and outdoor compressor. The long-term goal is to post long-term statistics to an RRD web page (run time, power consumption, temp, etc.) and control the blower (without the heat) automatically when we are burning our wood stove.

The product is a Nordyne IQDrive (notable in that the equipment comes with 5 separate brand logos to adhere to the equipment: Tappan, Frigidaire, Westinghouse, Nutone, and Broan).

At this stage, all I want to attempt to do is to tap the serial links and record the conversations. I would prefer not to shoot myself in the foot.

The "System Field Wiring Instructions" describe both links as "serial." The wiring diagrams label the connection points as:

air handler interface board --> [description] --> thermostat

      G --> GND --> C
      - --> DX- --> B-
      + --> DX+ --> A+
      R --> R   --> R

Googl'ing these might indicate that this is an RS485 (never heard of it).

How do I tap and record the communication?


texts:
I currently have a servo wired to my Arduino and have imported the Servo.h.  Here is my sketch:

#include <Servo.h>

Servo s1;
Servo s2;

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

  s1.attach(8);
  s2.attach(9);
}
int pos = 0;
void loop()
{
  pos = 0;
  if(s1.read() != pos)
    s1.write(pos);
  if(s2.read() != pos)
    s2.write(pos);

  delay(1000);
}

The problem is that even when my servos are at the position 0 it still tries to turn and I hear it trying.  What do I have to do to tell it to stop turning once it is already at the desired position?

So this is my second bit of code:

s1.write(0);
  delay(5000);
  s1.write(100);
  delay(5000);
  s1.write(180);
  delay(5000);

When I write them to 100/180 (or any number) they are silent after the turn, but when I write them to 0 I hear them keep trying to turn...


texts:
What is the meaning of BitSet = bitRead(numeral[number], segment);?

const byte numeral[10] = {
  //ABCDEFG /dp
  B11111100,  // 0
  B01100000,  // 1
  B11011010,  // 2
  B11110010,  // 3
  B01100110,  // 4
  B10110110,  // 5
  B00111110,  // 6
  B11100000,  // 7
  B11111110,  // 8
  B11100110,  // 9
};

// pins for decimal point and each segment
//                          dp,G,F,E,D,C,B,A
const int segmentPins[8] = { 5,9,8,7,6,4,3,2};

void setup()
{
  for(int i=0; i < 8; i++)
  {
    pinMode(segmentPins[i], OUTPUT); // set segment and DP pins to output
  }
}

void loop()
{
  for(int i=0; i <= 10; i++)
  {
    showDigit(i);
    delay(1000);
  }
  // the last value if i is 10 and this will turn the display off
  delay(2000);  // pause two seconds with the display off
}

// Displays a number from 0 through 9 on a 7-segment display
// any value not within the range of 0-9 turns the display off
void showDigit( int number)
{
  boolean isBitSet;

  for(int segment = 1; segment < 8; segment++)
  {
    if( number < 0 || number > 9){
      isBitSet = 0;   // turn off all segments
    }
    else{
      // isBitSet will be true if given bit is 1
      isBitSet = bitRead(numeral[number], segment);
    }
    isBitSet = ! isBitSet; // remove this line if common cathode display
    digitalWrite( segmentPins[segment], isBitSet);
  }
}


texts: TI ADS7250 Read From SPI and SPI1 Simultaneously

texts:
I'm so confused by the ADS2750 datasheet here, I can't seem to figure the proper bit shift to read data from bits 15-27 properly. I'm not even sure what some of the acronyms mean on page 23 table 1. I get that the first 15 bits are empty while the ADC takes a reading and then the last 12 bits for the 12 bit ADC are the value from that ADC that matches the SPI A or B input. Would someone be willing to explain to me how you would read data based on this datasheet using information from table 2 page 24?
My hardware set up to ADC7250
VCC 5 Volts

D5 SS fro Both SPI & SPI1
D13 SCK for Both SPI & SPI1
D11 MISO SPI_A from ADC
D4 MISO SPI_B from ADC
No MOSI connected

I'm not sure what to send in the SPI.Transfer(0x00). I'm also not sure if I'm setting up the modes properly, SPISettings settings(24*MHZ, MSBFIRST, SPI_MODE1); as I not 100% on the clock speed. I also I'm confused if this is LSB or MSB as the datasheet has two conflicting notes, the transfer function used LSB and then two paragraphs say "MSBs of ADC_A and ADC_B are output"
I'd love some help decoding this data sheet and getting a script that can read data from this chip using both SPI and SPI1 simultaneously.
Working on only reading SPI first the will add SPI1.
unsigned int readRegister(byte thisRegister, int bytesToRead);

const int CS_ADC_ISOLATOR = D5;
__SPISettings settings(24*MHZ, MSBFIRST, SPI_MODE0);
const int buffersize = 30;
unsigned char dataBuffer [buffersize];
const byte READ = 0x22;

// setup() runs once, when the device is first turned on.
void setup() {
  Serial.begin(115200);
  pinMode (CS_ADC_ISOLATOR, OUTPUT);
  digitalWrite (CS_ADC_ISOLATOR, HIGH);
  SPI.begin();
  SPI1.begin();
}

// loop() runs over and over again, as quickly as it can execute.
void loop() {
    digitalWrite (CS_ADC_ISOLATOR, LOW);
    SPI.beginTransaction(settings);
    for(unsigned char i = 0; i < buffersize; i ++)
    {
        dataBuffer[i] = SPI.transfer(0x00 << 14);
    }
    digitalWrite (CS_ADC_ISOLATOR, HIGH);
    SPI.endTransaction();
    for(unsigned char n = 0; n < buffersize; n ++)
    {
        Serial.print(dataBuffer[n]);
    }
    Serial.print("::");
}


texts: Calculate sensor unique address with a 8 position DIP Switch

texts:
I have a large amount of sensor boards that I need to be able to configure setting unique addresses. Each sensor is attached to it's own arduino, I'm using a 8 position DIP switch for setting the address.

I have tried diferent approaches. When I switch On and OFF I get random values. I understood that I would be able to get up to 255 possible positions, but without being able to get the proper byte data I would have to manually code each possibility, which seems wrong.

Schematic :

Code

#include "DipSwitchI2C.h"

DipSwitchI2C::DipSwitchI2C(int address)
{
    _address = address;
}

void DipSwitchI2C::begin()
{
    Wire.begin();
}

int DipSwitchI2C::read()
{
    unsigned int address = 0;
    unsigned int value = 0;

    Wire.requestFrom(_address, 1);
    if (Wire.available())
    {
        value = Wire.read();
    }
    Wire.endTransmission();

    for (int i = 0; i < 8; i++)
    {
        address += (value & (1<<i)) > 0;
    }

    return address;
}


texts:
I wrote the code below and the result is not what I expected at all! I'm not sure why it's happening!
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

const uint8_t pat[] PROGMEM = {
  0xff,
  0x00,
  0xff,
  0x00,
  0xff,
  0x00,
  0xff,
  0x66
};

void loop() {
  delay(100);
  Serial.println(sizeof(pat));
  for (int i=0; i<8; i++){
    Serial.print(pat[int(i)],HEX);
  }
  Serial.println("");
  Serial.print(pat[0],HEX);
  Serial.print(pat[1],HEX);
  Serial.print(pat[2],HEX);
  Serial.print(pat[3],HEX);
  Serial.print(pat[4],HEX);
  Serial.print(pat[5],HEX);
  Serial.print(pat[6],HEX);
  Serial.print(pat[7],HEX);
  Serial.println("");
  while(true);
}

the output is surprisingly this:

8
008000010
FF0FF0FF0FF66

What is compiler doing in the background but it seems to be messing things up really bad! The loop should be doing the exact same thing as manually writing that code over and over but it's not! How can I fix the loop?


texts: How to slowly change direction of the stepper motor with AccelStepper?

texts:
I know that direction can be changed with
.setSpeed(speed);
... //check input
.setSpeed(-speed);

I need to slowly decelerate and accelerate backwards, so I have to use
.setAcceleration(200);
...
.setMaxSpeed(speed);
... //check input
.setMaxSpeed(-speed);

but documentation told that .setMaxSpeed argument Must be > 0.
So how to properly change direction with deceleration? Probably I have to use .moveTo with some very big values


texts: Why can't I upload a sketch while other components/devices are connected to my Uno?

texts:
I wanted to make a fairly simple circuit which would flash a series of LEDs in sequence, using my Arduino Uno (more specifically, a SainSmart clone). I wrote my sketch and it compiled fine. After that, I connected 8 LEDS+resistors to pins 0 through 7, and then connected the Uno to my computer via USB.

I've uploaded sketches successfully in the past, so I'm sure my settings and drivers etc. are correct. However, when I tried to upload my sketch this time, it didn't work.

I tried removing everything I'd connected to the Arduino's pins, and suddenly the upload worked again.

Why does this happen? Does it mean I have to disconnect everything from the board every time I upload a sketch?


texts:
I am trying to make a simple water overflow protection system for my home. I have created it using BC547 and NodeMCU (ESP8266). I have a simple circuit like this:

The problem here is I have 2 wires going into the tank. Which suppose to complete the circuit as soon as water touch both the wires. But the problem here is its by default complete the circuit without even touching, this is happening only in my rooftop water tank. I tried this circuit locally on my desk first and it is working fine. I feel the problem can be humidity inside the tank? Can this be a reason for false trigger?

Here is how I have my code.

    #define RELAY_1 D1
    #define TANK_CONNECTION D4

void setup() {
  Serial.begin(115200);
  delay(10);

  Serial.println("Started");
  secondsTick.attach(1, ISRwatchdog);

  //Set relay pins to outputs
  pinMode(RELAY_1, OUTPUT);
  pinMode(TANK_CONNECTION, INPUT);

  digitalWrite(RELAY_1, relay_on);
  delay(100);

}

void loop() {
  tankFull();
  delay(100);
}

void tankFull(){

  Serial.println(digitalRead(TANK_CONNECTION));
   if(!digitalRead(TANK_CONNECTION) && relay_on == 0){
      Serial.println(motorOnCount);
      motorOnCount++;
      motorOffCount = 0;
      if(motorOnCount >= 10){
        Serial.println("Motor Turn OFF");
        digitalWrite(RELAY_1, HIGH);
         if (client.connected()) {
            client.publish(motor_status, "off", true);
            client.publish(tank_full, "on", true);

          }
        motorOnCount=0;
        relay_on = 1;
      }
      delay(100);
   } else{
      motorOffCount++;
       if (client.connected()) {
          client.publish(tank_full, "off", true);
       }
      //Serial.println(motorOffCount);
      if(motorOffCount>=100){
        motorOffCount=0;
        motorOnCount = 0;

      }
   }
}

Obviously this is not the full code. I am just trying to share the pattern of its working for basic understanding of the setup I have.

Any one have idea about why its always shows circuit complete even without touching the wires. I have tried with 5v as well and 3.3v as well which are present on NodeMcu Board. But none of them worked properly.


texts: What is the tool to send file to SPIFSS on ESP8266/32?

texts: Is there good tools (IDE, CLI or IDE addon) to send file via USB port to SPIFSS internal espressif ESP hardware SoC ?


texts: arduino will not save data after receiving from serial communication

texts:
I'm new to Arduino and what I'm trying to do is change the variable by sending it from php to the Arduino.
I've added the delay as stated by other questions but it has not worked so far. The pin 13 LED so
Arduino Code
float val;
void setup() {

  Serial.begin(9600);

  pinMode(13,OUTPUT);
  digitalWrite(13,LOW);
  val=29.1;

  Serial.println("Start!");
}

void loop() {

  if(Serial.available()){
    String temp = Serial.readStringUntil('\n'); //read string
    val = temp.toFloat(); //convert string to float
  }

  if(val==62.10){
    digitalWrite(13,HIGH);
  }else{
    digitalWrite(13,LOW);
  }

  Serial.println(val);
  delay(1000);

}

PHP Code
<?php
$port = fopen("COM3", "w");
sleep(2);
fwrite($port, "62.1");
fclose($port);
?>

Any tips would be much appreciated. Thank you for reading.


texts: I am working on a project for my final in a first year programming course at my high school. I would like to make an Arduino based data logging device that I can bring with my on the mountain biking trails around where I live to create a map. I have found a lot of great sources online but I do not have a small budget. I have an Arduino Uno and a breadboard. My first question is whether it is easy to interface between an Uno and my phone for data logging, or if it would just be easier to buy a microSD card shield? And I need help finding a GPS unit. I have no preference and size is not really a problem. I just need to know how to interface with the Uno. Also if you have any links to other sources I can use that would be greatly appreciated!


texts:
The Arduino Uno manual (from the kit) instructs to connect a resistor to GND when lighting an LED on the breadboard with the 5V (socket?). The red, green, and yellow LEDs don't light up so brightly... actually they are barely bright enough to detect. Is it safe to apply all 5 volts by connecting the cathode to the ground with a wire? I tried it for a second and it worked... Just don't try it on the blue, I assume that beyond 5V it will explode, it burnt so bright..

Optional: Why does only the blue LED light visibly?


texts: How can I make this code read a page every 10 seconds?

texts:
I got problems with the code and I have used most of today, trying to find a solution and it's starting to drive my crazy. I hope one of you guys will be able to help me out.

I need the code to check a specific page every 10 seconds, single character.

This is what I have now, working code:
Where should I start?

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 104 };
char server[] = "billigefittings.dk";

EthernetClient client;

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);

  delay(1000);

  Serial.println(Ethernet.localIP());
  Serial.println();

  Serial.println("connecting ...");

  if (client.connect(server, 80)) {
    Serial.println("connected");
    client.println("GET /lan.php");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if(client.available() > 0) {

    char c = client.read();

    Serial.print("page value:");
    Serial.println(c);

    if(c == '1') {
        digitalWrite(8, HIGH);
        Serial.println("8 HIGH ...");
        delay(5000);
        digitalWrite(8, LOW);
        Serial.println("8 LOW ...");
    }else{
        Serial.println("page value does not match '1' !");
    }

    // The code above should run even 10 seconds

  }

  if(!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;);
  }

}

Update: Edit the loop like the example below does not work either, it stops after the first loop (8 LOW):

void loop()
{
  if(client.available() > 0) {

    char c = client.read();

    Serial.print("page value:");
    Serial.println(c);

    if(c == '1') {
        digitalWrite(8, HIGH);
        Serial.println("8 HIGH ...");
        delay(5000);
        digitalWrite(8, LOW);
        Serial.println("8 LOW ...");
    }else{
        Serial.println("page value does not match '1' !");
    }

    delay(5000);

    // The code above should run even 10 seconds

  }

}


texts: How to write data in RAM memory using Arduino Uno or Arduino Due?

texts:
I know that it is possible to write data in ROM(Read Only Memory).
But what about if I want to write data in RAM(Random Access Memory)?
Can I do it using "Arduino Uno R3"?
RAM is normally associated with volatile types of memory.

There are several examples about writing data in EEPROM as in a (Read Only Memory) which may have 8 pins.
In order to store values read from analog input 0 into the EEPROM we need to use the "EEPROM.write()" function.
These values will stay in the EEPROM when the board is turned off and may be retrieved later by another sketch.
ROM is a Non-volatile type memory.
SD card is also Non-volatile type of memory.
We know that there are few SD card shields for "Arduino Uno" and it is possible create your own shields.

But what about volatile types of memory?
what about if I want to write data in RAM like a "DDR SDRAM" or in a DDR3 memory which may have 240 pins instead of 8 pins?
So my question is is it possible to write data in "DDR SDRAM" using "Arduiono Uno R3"?
How? Where should I connect those 240 pins?


texts: Nothng Written to Serial when using sprintf

texts:
I'm using sprintf to use a format specifier myTemplate with some strings. The result will then be written to Serial. Although the sketch compiles fine, it does not write any thing to the serial, nothing is seen in the Serial monitor.

Is sprintf being used wrongly here?

char* result;
char* myTemplate;

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

void loop() {
    myTemplate = "Welcome %s. You have slept %s times";
    sprintf(result, myTemplate, "Jane", "many");
    Serial.println(result);
    Serial.println("hello");

}

When I try the follwing sketch and write something to the Serial monitor, I receive gibberish echoed back to me!  Why is this?

Sketch

char received;
char* message = "";

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

void loop() {

    // Echos back
    if(Serial.available() > 0) {
        received = Serial.read();
        Serial.println(message);

        if(received == '\n') {
            message = "";
        }  else {
            message += received;
        }

    }
}


texts: Why isn't DigiSpark automatically recognized on other computers?

texts:
I bought a DigiSpark (it is a development board based on the ATtiny85 microcontroller) yesterday and I wrote my first script.

I have no problems to run it on my personal PC (which I am using to program my DigiSpark). The problem is when I try to plug my DigiSpark to another PC, which doesn't have DigiSpark drivers installed. I tried to run it on two different PCs (Windows 7) and Windows just can not find DigiSpark drivers so my script does not run.

Of course I tried to plug in to different USB ports - unfortunately it did not help.

Any ideas what can I do to make my DigiSpark run on other PC without installing drivers by myself?

Thank you.


texts: Hello sir , so can i cut the switch from the picture and connect the wires to my relay module ? Im sorry because im still learning . Thank you !


texts: ADXL345 hangs the micro-controller as vibrations increase

texts:
I am using ADXL345 accelerometer with Adafruit_ADXL345 library for vibration measurement.

I am reading acceleration at X, Y, Z-axis of a sensor placed on a vibrating platform.And serially sending it to PC at a baud rate of 115200.

When vibration is low sensor shows vibrations but as i increase the vibrations serial transmission seems to be halted. As shown in figure:(x-axis=Samples y-axis=Values )

I thought it may be due to loose connections so I soldered its terminals but it behaved the same way at higher vibrations.
 Here is the code that I’m using.

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_ADXL345_U.h>
/* Assign a unique ID to this sensor at the same time */

Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12);
int i=0;
struct measure
{
    int timestamp;
    float x;  // ACC in x direction
    float y;  //ACC in y direction
    float z;  //ACC in z direction
};
sensors_event_t event;
struct measure measurements;

int timestamp = 0;

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

  Serial.println("Accelerometer Test"); Serial.println("");

  /* Initialise the sensor */
  if(!accel.begin())
  {
    /* There was a problem detecting the ADXL345 ... check your connections */
    Serial.println("Ooops, no ADXL345 detected ... Check your wiring!");
    while(1);
  }
  accel.setDataRate(ADXL345_DATARATE_3200_HZ);
  accel.setRange(ADXL345_RANGE_16_G);
     pinMode(LED_BUILTIN, OUTPUT);
  delay(2000);
}

void loop(){

 accel.getEvent(&event);
   measurements.timestamp = timestamp++;
   measurements.x  = event.acceleration.x;
   measurements.y  = event.acceleration.y;
   measurements.z  = event.acceleration.z;

if(measurements.timestamp%2==0)
  digitalWrite(LED_BUILTIN, HIGH);
  else
    digitalWrite(LED_BUILTIN, LOW);

  /* Sending the array with data through serial*/

  Serial.print(measurements.timestamp);
 Serial.print(",");
 Serial.print(measurements.x+0.06);
 Serial.print(",");
 Serial.print(measurements.y+0.7);
 Serial.print(",");
 Serial.println(measurements.z-10.10);
}

Where does problem lie? How to resolve this issue?

Circuit Connections:


texts: Angle sensor to measure the stepper motor shaft rate of rotation

texts:
what Kind of Sensor that i can use to know how much angle stepper Motor shaft has rotated ?
Actually,I am thinking to rotate my stepper Motor at 1 rpm and my stepper Motor shaft Diameter is 8mm and length would be around 20 mm. I am using this stepper Motor in very sensitive Case that is the reason why iam  going to use microstepping Driver also.
Can anyone help me out form this query?
And ,Thanks in Advance.


texts: BLE scanner and WiFi web server on the ESP32 board

texts:
I am trying to put BLE and WiFi web server on the same ESP32 board, using Arduino IDE.
However, BLE library is too heavy. It spends about 73% of program size and there no room for WiFi.
Program too big. The size is 1328706 bytes (of a 1310720 byte maximum

These are libraries I am trying to use in the same solution:
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>
#include <EEPROM.h>
#include <WiFi.h>

Is there anything I can try to spare program size?
Is there any alternative?


texts:
I have the project to build a robot for my school. It will record button pushes then move according to this record.

Before usig motors, i'm trying to do this using leds.

Thanks from posts from this community, I've succeed in recording button pushes in an array.

Now I'm trying to light the leds according to this array.
I have 4 buttons with 4 leds and one button tu run the recording when it's ready.

I'm stuck in lighting the leds when I push the play_button.

I hope someone can help me...

Here's my script :

int arr[10];
boolean previous = LOW;
unsigned long time1 = 0;
int debounce = 200;
unsigned long time2 = 0;
int index_state = 0;

int play_button = 13; //define pin # for play button

int button[4] = {2,4,6,8}; //store button pins in an array
int leds[4] = {3,5,7,9}; //store led pins in an array

void setup()
{
  for(int n=0;n<10;n++) arr[n] = 0;//initialisition
 Serial.begin(9600);
}

void loop(){
 boolean mode = digitalRead(2) || digitalRead(4) || digitalRead(6) || digitalRead (8);
 while(mode == LOW) mode = digitalRead(2) || digitalRead(4) || digitalRead(6) || digitalRead (8);//wait here till one of the pushbutton goes high;
 //Serial.println("value");
 if( mode == HIGH && previous == LOW && millis() - time1 > debounce) {
 //find out which one is high and store that value in array;
 if(digitalRead(2)) arr[index_state] = 2;
 else if(digitalRead(4)) arr[index_state] = 4;
 else if(digitalRead(6)) arr[index_state] = 6;
 else if(digitalRead(8)) arr[index_state] = 8;
 else ;

 //print the value and the index;
 Serial.print(arr[index_state]);
 Serial.print(" Stored in index: ");
 Serial.println(index_state);
 index_state = (index_state + 1) % 10;
 //update value of time1 for button debouncing
 time1 =  millis();
}

  //update the value of previous button state
  previous = digitalRead(2) || digitalRead(4) || digitalRead(6) || digitalRead(8);

  }

Thank you


texts: Showing GPS Values on I2C LCD using Arduino and ESP8266

texts: I am working with Arduino. I'm using 2 Arduino boards along with 2 ESP8266 modules to transfer data from one Arduino to another Arduino. I want to transfer GPS values from system 1 to system 2 using Wi-Fi module ESP8266 along with Arduino UNO. I've written the main codes for server and client end. I'm not able to print anything on LCD if I'm using ESP8266 and selected 'generic ESP8266' boards.


texts:
Folks,
I want to use my arduino with ethernet shield to access the following webpage "http://www.met.ie/forecasts/sea-area.asp" and take some information.

On the website it has a line "Small Craft Warning"- This is always either "In Operation" or "Nil".

Basically i want to hook up a RGB LED to the duino and if "Small Craft Warning" is "in Operation" i want LED to be Red, and if "Nil" LED can be green.

My issue is i cant figure out hot to go about getting the information from the webpage.- Can the arduino read this directly?

I am confident with arduino but this is my first web based project!

Any Tips or advice would be savage helpful
Thanks


texts:
I am making a project involving the AutoConnect, ArduinoJSOn and LedControl libraries to fetch some values from an endpoint.

Basically what I do is connect to the internet, fetch the values from a JSON file in a given URL, store the values in variables and display the corresponding numbers in a 7segment module (using a max 7219 module).

Everything seems to work perfectly in the first iterations of the loop program, but after some iterations switching the values from one value to another, it starts to act strangely, as the input values changed on runtime:

[AC] WiFi.config(IP=0.0.0.0, Gateway=0.0.0.0, Subnetmask=0.0.0.0,
DNS1=0.0.0.0, DNS2=0.0.0.0) [AC] DHCP client(STARTED)
[AC] WiFi.begin()
[AC] Connecting........[AC] established IP:192.168.1.139
[AC] http server started
Wifi connected: 192.168.1.139
Connected to endpoint
Daily:13.37
Monthly:1111
4
13.37
4
1111
4
13.37
4
1111
4
13.37
4
1111
4
13.37
4
1111
2
h
0

2
h
0

2
h

As you can see in the previous serial output, after the 8th iteration, everything starts malfunctioning.
The output correlates with the number of digits that will be used in the 7-segment led module ( 4 ) and the number to display ( 13.37 and 1111 ). Then it starts getting the wrong values forever.

For getting the values in the JSON I use the following code:

void fetchJSONandPutValues(){

     HTTPClient http;  //Object of class HTTPClient
     http.begin(projectURL);
     int httpCode = http.GET();
     //Check the returning code
     if (httpCode > 0) {
      //Parsing
      const size_t bufferSize = JSON_OBJECT_SIZE(2) + JSON_OBJECT_SIZE(3) + JSON_OBJECT_SIZE(5) + JSON_OBJECT_SIZE(8) + 370;
      DynamicJsonBuffer jsonBuffer(bufferSize);
      JsonObject& root = jsonBuffer.parseObject(http.getString());
      // Parameters
      daily = root["daily"];
      monthly = root["monthly"];
      // Output to serial monitor
      Serial.print("Daily:");
      Serial.println(daily);
      Serial.print("Monthly:");
      Serial.println(monthly);

      finalDaily = (char *) daily;
      finalMonthly = (char *) monthly;
    }

    http.end();   //Close connection

   //setLCDValues(daily);
}

For displaying the numeric values in the 7-segment module I have made this function:

void setLCDValues(char * value){

  int charsInValue = strlen(value);
  boolean decimalPoint = false;
  int numLEDElements = charsInValue;
  char cleanedValue[8] ;

  //look for point position
  int positionPoint = 999;

  for (int i = 0; i < charsInValue; i++){
    if (value[i] == '.')
    {
      positionPoint = i;
      numLEDElements -= 1;
      break;
    }
  }

  int j = 0 ;
  for (int i = 0; i < charsInValue; i++){
    if (value[i] != '.')
    {
      cleanedValue[j] = value[i];
      j++;
    }
  }

  Serial.println(numLEDElements);

  for (int i = 0; i < numLEDElements; i++){

    if ( i == positionPoint -1 )
    {
      ledDisplay.setChar(0, numLEDElements -1 - i, cleanedValue[i], true);
    }
    else
    {
      ledDisplay.setChar(0, numLEDElements -1 - i, cleanedValue[i], false);
    }
  }
}

And in my loop() I have the calls to setLCDValues:

currentMillis = millis();

if (currentMillis - previousMillis >= interval){

      previousMillis = currentMillis;

      if (showDaily)
      {
        setLCDValues(finalDaily);
        showDaily = false;
        Serial.println(daily);
      }
      else
      {
        setLCDValues(finalMonthly);
        showDaily = true;
        Serial.println(monthly);
      }
}

I am guessing the problem I have here might be related to using pointers, although I haven't found yet the issue here. Could it be a problem with one of the libraries ? (ArduinoJSON?)


texts: Hooking up 12v Push button to arduino uno/nano

texts:
I want to use one an push button with an led in middle, similar to this one on eBay.
The push button has a 12v input I want to hook it up to an Aduino Uno or Nano.

Is there a way to hook it up and receive the signal?

Specifications from the eBay page:

  Latching type, push it—on, push it again — off
  Switch Rating: 3A/250VAC
  LED voltage: 12V only
  Contact Configuration: 1NO1NC
  Pin Number: 5


texts: How can I fix my HRLV-MaxSonar-EZ ultrasonic sensor so it does not give gibberish feedback?

texts:
I have hooked up my ultrasonic sensor to my Arduino correctly, I know this because I am getting feedback from it, but when I run this code:

int mode = 2;
double distance;
double calibration;
void setup()
{
  Serial.begin(9600);
  pinMode(12, INPUT);
}
void loop()
{
  if(mode == 1)
  {
  //Read duration in microSeconds
  long duration = pulseIn(12, HIGH);
  //58 uS per cm for MB1240 XL-MaxSonar
  //Operation Range: 20 cm min (50 cm for accurate)
  distance = duration / 58.0;
  calibration = -20;
  }
  else if (mode == 2)
  {
  //Analog In .49 mV per unit
  double voltage = analogRead(5)*.0049;
 //.49 mV per cm;
  distance = voltage/.0049;
  calibration = 0.0;
  }
  double cmToInch = 0.393701;
  //Analog Seems to be More Accurate due to PWM timing
  Serial.print((distance+calibration)*cmToInch);
  Serial.println(" in");
  delay(100);
}

I get sporadic results when it is just sitting there without anything moving in front of, let alone around it at all:

What is wrong here? Is it my code, is the sensor just very sensitive, or is it something else?

Thanks in advance.


texts: Extremely cheap "Arduino" for single tasks?

texts:
I have been thinking of a million things to do with my Arduino, but those things are extremely simple and it would leave my Arduino as a $25 waste.

For example, programming Arduino to control my living room lights with my smartphone ... I was thinking of connecting the Arduino in the wall, onto the light switch wires. I am looking for a "permanent" solution, but I figure this would leave me with a $25 waste of circuitry inside my wall.

Are there any "Arduino" types of electronics that perhaps have many less ports, JUST enough to get a single task done?


texts: MPU6050 or GY521/HMC5883 chips are burnt for no reason

texts:
I been trying to interface MPU6050 and HMC5883 with an Arduino Pro Mini/Nano. I²C scanner works just fine and identifies the device with no issues. I let the I²C scanner run like for 5 minutes and I see fumes coming out of the chips and sometimes the Arduino itself is burnt. I tried pull up resistors 2.2k, 7k without any luck. Has anyone got any inputs to this issue. Really frustrating to spend a weekend on this :(

To rule out the possibility of 5V supply causing the burn out I tried 3.3V from Nano and made promini 3.3V from 5V. Please see the pictures below.

Arduino Nano 3.3v was used to power up the I²C.

.

.

Pro Mini jumper was desoldered from 5V to 3.3V to see if the I²C chips are saved from being burnt. In both these setup voltage accross the I²C chip was measured and it was 3.3V.

Still no luck!

If you guys are to make the same circuit how would you do it and where would you get the components from? I must be doing something wrong and hope we together can figure it out.

Components are bought from eBay and the links are here.
GY521 = goo.gl/Y4aDph
HMC5883 = goo.gl/DfrC9l
Arduino Nano = goo.gl/CaAykI
PROMINI = goo.gl/79PVOM

This is some background of why this issue resolution is so important to me:
Just give you a backgroud of why I am doing this: I am building a quadcopter myself. Infact built one using GY80, but the module was expensive also it eventually got burnt out for the same reason mentioned above. Here is the first successful test flight of my first quadcopter goo.gl/rn6xWG (add https:// since I am rookie there is limitation on how many links I can post). If I can make the same thing work using GY521 and HMC5883 it would be awesome and cheaper.

Update on 08/11 @12:45 PM CST
I think it is because of the Pro Mini, I²C chips are getting fried. When using Nano, I think it is because of the voltage level difference between the SDA/SCL lines causing the problem. With Pro Mini tripped for 3.3V, I was not able to see any serial data from the chip too. To end all these I placed an order for 3.3V 8 MHz Pro Mini from amazon goo.gl/FjgTGj Let see how that goes.


texts: How to communicate with arduino uno when arduino motor shield connected to arduino uno?

texts:
I'm using this Dual Motor Shield

when I plug Arduino Dual Motor Shield into Aruino uno can't seen any way to communicate with Adruino uno.how can I communicate with uno ?


texts:
The core I use is this one
The chip I use is an ATtiny85
I run this using the Arduino IDE 1.8.2
RadioHead ASK library (slimmed down)

What I want to do is:

deep sleep
wake up every minute
turn on sensor
take measurement
transmit data
back to sleep

This works when I test it seperatly, where it goes awry is when I combine RadioHead with WDT and then try to use a delay. This always hangs.

Probably a timer issue, I am looking for a work around.
I need the delay because I need to start the sensor, wait .5 sec and then take a measurement. Maybe I should give the ATtiny85 just some job to keep it busy for 0.5 sec?

This is working code, when I uncomment //  driver.init(); it will fail.

// RadioHead ASK
#include <RH_ASK.h>

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

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

// Absolute reference PB to overcome inter-IDE issues
#define T_PIN 1 // transmission
#define L_PIN 3 // optional LED pin
#define S1 A2
#define S2 A1
#define BAUD 2000

// Baud rate, receiver, transmitter
RH_ASK driver(BAUD, 9, T_PIN); // pin 9 is non existent

// Watchdog
volatile boolean f_wdt = 1;

ISR(WDT_vect) {
  f_wdt=1;
}

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

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

  sleep_mode();                        // System sleeps here

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

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

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

void setup() {
//  driver.init();
  setup_watchdog(8);
}

void loop()
{
  if (f_wdt==1) {
    pinMode(0, OUTPUT);
    digitalWrite(0, HIGH);
    delay(500);
    digitalWrite(0, LOW);
    delay(500);
    system_sleep();
  }
}


texts: How can I interrupt a delay() when a button is pressed?

texts:
I have created a device that allows my son to track time spent on activities and exchanges that time into a time he can use with his electronics (eTime).

Full code in GITHUB

I am having trouble coding the part of the code that handles the countdown from his earned eTime. As it is right now it can count down and give him a warning when his eTime has run out, but the process can't be interrupted.

I would like to have him be able to stop his eTime and use the remainder later. I tried putting the function in a while loop.

while(digitalRead(button_9)==LOW){
    delay(60000);
    avail_time -= 1;
    if(avail_time<0){
      playAlarm();
      return;
}

This one registers the keypress but ignores the delay.

I have also tried using a for loop to count down and another to check every second for a keypress.

void useTime() {
  for(int i=avail_time+1; i>0; i--){
    displayTime(i);
    for(int minute=60; minute>0; minute--){
      if(digitalRead(button_9)==HIGH){
        avail_time = i;
        return;
      }
      delay(1000);
    }
  }
  while(digitalRead(button_9)==LOW){
    tone(buzzer, 2000);
    }
  noTone(buzzer);
  avail_time=0;
  displayOptions();
  return;
 }

That one does not register the keypress.


texts:
Here is mine circuit. Intially i used arduino UNO directly for programming. Now i am Using atmega 328 IC for programming. I am trying to connect 32 hall sensor via Mux circut. I wanted to How to upload boot loader or HExfile Here. Will avr pocket programmer satisfy above circuit or i need to add addtional circuit here
AVr pocket programmer


texts:
I'm looking to directly program an ESP8266 WiFi Module with out using a FTDI (USB-Serial interface) as suggested in this excelent tutorial. The real purpose is to have access to the GPIO ports of the module.

I heard (from this page) that one can use an Arduino UNO as an intermediate interface for burning the bootloader onto an AVR (e.g. ATmega168 or ATmega328). That is, using the ArduinoISP code example in the IDE.

Is it possible to use an Arduino UNO as temporal bridge to program the ESP8266? Can anyone please suggest some tutorial? Thanks


texts: On my ESP32 project I've run out of pins and have incorporated using a MCP23017 port expander.  I need to run multiple slow serial connections (9600 baud) thru the port expander.  Are there any software serial libraries available that would work over a port expander?


texts:
I'm trying to make a 4 channel RC using Arduino and nrf24L01 module.
I already know how to deal with this module, but the question is "What does 4 channel mean ?", and how to make it supports 4 channel ?


texts:
I have a doubt interfacing with fingerprint module (R305) with the Arduino Mega.
I have been able to interface it to Arduino Uno before but not Arduino Mega so far.

I have used the Mega's hardware Serial1 pins 19 (Rx) and 18 (Tx) pins.

However, I am unable to get output from the module. How do I connect hardware serial and what is a sketch to do this?