texts: Please help! My Bluetooth Controlled Car Isn't working

texts:
I followed this tutorial: enter link description here
I built it according to the schematic except I didn't connect an LED (I assume this isn't the problem). This is the schematic:

I'm a beginner so at first I connected the TX and RX of the HC-05 and the UNO but after getting errors I unplugged them from the UNO, uploaded the code, then plugged them back in (is this correct?)
This is the code that I uploaded to my UNO:
char t;

void setup() {
pinMode(13,OUTPUT);   //left motors forward
pinMode(12,OUTPUT);   //left motors reverse
pinMode(11,OUTPUT);   //right motors forward
pinMode(10,OUTPUT);   //right motors reverse
pinMode(9,OUTPUT);   //Led
Serial.begin(9600);

}

void loop() {
if(Serial.available()){
  t = Serial.read();
  Serial.println(t);
}

if(t == 'F'){            //move forward(all motors rotate in forward direction)
  digitalWrite(13,HIGH);
  digitalWrite(11,HIGH);
}

else if(t == 'G'){      //move reverse (all motors rotate in reverse direction)
  digitalWrite(12,HIGH);
  digitalWrite(10,HIGH);
}

else if(t == 'L'){      //turn right (left side motors rotate in forward direction, right side motors doesn't rotate)
  digitalWrite(11,HIGH);
}

else if(t == 'R'){      //turn left (right side motors rotate in forward direction, left side motors doesn't rotate)
  digitalWrite(13,HIGH);
}

else if(t == 'W'){    //turn led on or off)
  digitalWrite(9,HIGH);
}
else if(t == 'w'){
  digitalWrite(9,LOW);
}

else if(t == 'S'){      //STOP (all motors stop)
  digitalWrite(13,LOW);
  digitalWrite(12,LOW);
  digitalWrite(11,LOW);
  digitalWrite(10,LOW);
}
delay(100);
}

Then I paired with the HC-05 and used the ArduinoCar app which works as follows:
if I press forward it will send 'F'
if I press backward it will send 'G'
and so on.
I successfully connected to HC-05.
However when I press forward, the motors don't move this goes for all the other directions. The thing is when I press forward, for example, the UNO lights up (the L and TX LEDs light up) so I'm pretty sure it's getting received by the UNO but something is still wrong...
edit: I got it to work by powering the L298n (9V) and the UNO (rn connected to computer) separately and now the right and left work perfectly the problem is the forward and backward, when I press either of them only one wheel turns and it's stuttering and will stop quickly, is it because 9V is too small for both motors?


texts: measure +3V and -3V through resistor divider and switch on/off by digital pins

texts:
I've seen that resistor dividers can be used to read negative voltages, but I'ld like if there is a way to accomplish this with less components and having a way to turn this off.

I was thinking if there would be an extreme option of changing from pinMode INPUT to INPUT_PULLUP or INPUT_PULLDOWN to power the circuit and use the 20k pullups to make part of the divider, together with another resistances on the input. Alternatively, switching from INPUT to OUTPUT would be fine.

What I want to measure is an external +3V/GND/-3V power supply (battery pack) that shares the GND with the arduino SAMD21 (3.3V), measuring both +3V and -3V, and avoiding drain when not measuring (hence the pin mode changes)

Currently I'm using this schema to measure the voltage of +5V supply battery (connected through VIN, thus using the internal regulator), by dividing with 2 1Mohm resistances, ground to digital pin and measurement by internal adc. I don't need so much precision, so this is enough here. So I'm looking for the same or better alternatives, but for the -3V I don't know how to properly calculate the 3 resistor divider.


texts: How to run a timer every 12 hours (exceeding the max size of int) without an RTC?

texts:
I'm experimenting with a Nano, and trying to trigger an action around twice a day. I'm aware that it's not super accurate, but I don't really mind, as long as it's in the ballpark.

I've tried using the SimpleTimer library but I'm running into an issue because it takes milliseconds as an int, and 12 hours is 43200000 (larger than 32,767 max). Is there another library, or another technique I can use for this?


texts:
I know it's possible (in theory) to reprogram the VID PID details back into a chip. It is however way beyond me.

Recently I learned that Microsoft distributed a piece of malicious software as part of their Windows update service. This virus was written by the FTDI chip makers to brick any chips such as the CH341's found in many cheaper Arduinos et al.

The virus attacked my CH341A serial to USB chip by writing 0's to the VID PIC and probably other locations. This makes the hardware 'Unknown' and even if you have the correct driver software, the device is never associated with it.

Does anyone know a solution to get the zeroed information back into the CH341A?


texts: Size limitation on char Array on ESP8266

texts:
I'm creating a log of events, stored as a txt file. If it matters, I'm using ESP8266.
To display the log of each IOT, I'm publishing the txt file to a disgnated MQTT topic for all my IOT devices (later on to Telegram ). For sorting ( new first and old last ) I read each line into char array, post it to MQTT, and save it back to txt file.
Currently char array is defined as: char log_array[20][200] - meaning I'm keeping a log of 20 records, of 200 chars long.
Is it the right way ( declare a char array ) ? are there any limitation for size of array ( say 200 records )
Guy


texts: Changing address of MPU 9250 connected to ESP32

texts: Can I change the I2C address of a device (MPU9250) connected to ESP 32 using int pin. I understand that in arduino board if we connect the int pin to A0 the default I2C address of MPU 9250 changes from 0x68 to 0x69. Is something similar possible with ESP 32? Which Pin I should connect to?


texts: Is it possible to connect a 36 pin 4 digit 7 segment display on an Arduino Uno R3?

texts:
First of all,here's the datasheet of the 4 digit 7 segment display that I'm using:
http://www.kingbrightusa.com/images/catalog/SPEC/ca56-11ewa.pdf

How can I make a counter or a clock out of this particular led display,considering the fact that I don't have enough digital pins to manipulate led's pins?


texts:
I want to run 5v and 12v strips and halos together, i read that with the 12v strips, give 12v to the strip but the data is always 5 volts, and tie the ground to the ground of the 5v controller?

I use SP105E bluetooth controllers off ebay, and i use a 10/20a 12v to 5v buck converter to get me to 5v as i use my lights in vehicle accessories so thats why i dont have a power supply or anything.

So would i just take the 12v strip, run the +12v to the +12v then data to the data wire and tie the 12v strip ground to the 5v ground on the controller/step down converter?


texts: how to make GPRS/GSM SIM900 shield work with gps neo-6M module using Arduino UNO board

texts:
I'm a beginer to arduino program.i will like to make a program that will send latitude and longitude on my mysql database.so since 3 days i try to learn how to use all this material(GPRS/GSM SIM900 shield, gps neo-6M).But i only success to make them work alone.i also learn that i cannot use SoftwareSerial for GPRS/GSM SIM900 shield and  gps neo-6M at the same time.
so how can i make GPRS/GSM SIM900 shield and gps neo-6M work together using arduino uno

thank you for you help


texts: Lockup while evaluating Wire.requestFrom function (Arduino)

texts:
I am currently working on a Arduino project that combines an InertiaOne IMU sensor board (from Atmel), with an Arduino UNO and two motors driven by a Makeblock driver board. All sensors communicate using I2C, with different addresses. My issue is that the program runs just fine for a while (everything between 1 second and 2 minutes), but suddenly lock up inside the Wire.requestFrom-function that handles I2C communication. More specifically, I believe that the code hangs at one of these points in the Wire library (the code is a direct copy):

...
// wait until twi is ready, become master receiver
while(TWI_READY != twi_state){
    continue;
}
...
// wait for read operation to complete
while(TWI_MRX == twi_state){
    continue;
}

As far as I know, there are only two units that utilise I2C in the system, both of which are embedded onto the InertiaOne circuit board. What I find very strange is that reading these two sensors works just fine when no motors are running, but that the problem occurs when the motors are activated. My first reaction was to use separate power supplies for the motors and sensor board since the issue could have been caused by a dip in the voltage and a reset of the sensor board, but without any change of result.

I am running out of things to try, and do simply not have the required understanding of I2C and embedded systems to see what exactly the issue is. Could it simply be that some of my parts are faulty, or am I perhaps overlooking something?


texts: Arduino PWM output cannot drive MOSFET 0-12V

texts:
On an Arduino Uno, the PWM pin 3 is connected to the gate pin of an N-channel MOSFET STP16NF06L. The source pin is connected to ground of a 12 V power supply and drain pin connected to a multimeter. The other end of the multimeter is connected to the positive terminal of the power supply.

Question: When Arduino varies its PWM output from 0 to 255, the multimeter reading goes from 11.50 V to 12.10 V. Why isn't it 0 to 12 V?

When the FET gate is connected to the Arduino pin that outputs either 0 V or 5 V, the multimeter reading is as expected at 0 V and 12 V respectively.


texts:
I have an Arduino Due.  It communicate to the computer with the native usb port. It is also powered by the native port. Anyway, the connected sensors are pretty sensitive to the current, thus I would like to use a power supply (as a portable smartphone charger) in order to provide the current at the Arduino.

How can I say to the Arduino to get the current from another 'port' (e.g. the serial programming) and use the native port only for the communications?


texts: What’s the most common (and low cost) microprocessor with at least two threads?

texts: I want to make a next version of my current project. I’m hoping to use an Arduino compatible processor that also supports at least 2 processes simultaneously without using pro threading or any other software workaround. The more commonly used the processor is, the better the user support will be if something goes wrong.


texts: Arduino connection to brainwave analyzing module

texts:
I want to connect a TGAM module (detecting brainwaves) to an Arduino Uno. I know little of electronics, can someone advise me? To which pin of the Arduino should I connect the TGAM? How to get the right electrical supply from the Arduino to the TGAM? Here is data about the TGAM module: http://www.seeedstudio.com/document/pdf/TGAM%20Datasheet.pdf

The R pin on the TGAM module is providing digital data as an asynchronous serial stream of bytes: http://developer.neurosky.com/docs/doku.php?id=thinkgear_communications_protocol


texts: Does blinking an LED with no resistor for a few seconds harm my Arduino?

texts:
I am new to Arduino and I just made my first LED blink. I connected the LED to ground and digital pin 13 without resistance (for only a few seconds). Does this harm my Arduino?

Hilmi


texts:
I'm trying to use the RN 42 and Arduino Uno to control a bluetooth mouse. I configured the RN 42 with the commands S~,6 and SH,0220 and R,1 to put the device in HID mouse mode. Is there anything I missed? Below is the sketch I am using to send mouse reports to the bluetooth. The sketch compiles fine, but moving the joystick does not move the cursor. I included a line of code at the end to print on the serial port whatever data is being sent through software serial to the bluetooth. However when I view the serial monitor, I get back a lot of reversed question marks. Anyone know why this is? Thanks in advance.

const int bluetoothTx = 4;    // TX pin of RN-42, Arduino D2 (configure as RX pin of Ard)
const int bluetoothRx = 3;    // RX pin of RN-42, Arduino D3 (configure as TX pin)
const int button = 5;
const int xAxis = A0;         // joystick X axis
const int yAxis = A1;         // joystick Y axis
int range = 12;               // output range of X or Y movement
int responseDelay = 5;        // response delay of the mouse, in ms
int threshold = range / 4;    // resting threshold
int center = range / 2;       // resting position value

SoftwareSerial BT(bluetoothTx, bluetoothRx); // args SoftwareSerial(RXpin, TXpin)

void mouseCommand(byte buttons, byte x, byte y) {
  BT.write((byte)0xFD);
  BT.write((byte)0x05);
  BT.write((byte)0x02);
  BT.write((byte)buttons);
  BT.write((byte)x);
  BT.write((byte)y);
  BT.write((byte)0x00);
}

int readAxis(int thisAxis) {
  // read the analog input:
  int reading = analogRead(thisAxis);

  // map the reading from the analog input range to the output range:
  reading = map(reading, 0, 1023, 0, 12);

  /* threshold prevents the mouse from reading small unintentional movements.
  If the output reading is outside from the rest position threshold, use it: */
  int distance = reading - center;

  if (abs(distance) < threshold) {
    distance = 0;
  }

  // return the scaled distance for this axis:
  return distance;
}

void setup() {
  pinMode(button, INPUT);
  pinMode(bluetoothTx, INPUT); // bluetoothTX is equivalent to arduino RX pin
  pinMode(bluetoothRx, OUTPUT);
  Serial.begin(115200);  // Begin the serial monitor at 115200bps
  BT.begin(115200);  // RN-42 defaults to 115200bps
}

void loop() {
  // read and scale the two axes:
  int xReading = readAxis(xAxis);
  int yReading = readAxis(yAxis);
  int buttonState = digitalRead(button);

  // move the mouse:
  mouseCommand(buttonState, xReading, yReading);
  delay(responseDelay);

  if(BT.available())  // If there's data being sent to the bluetooth module
  {
    // Send any characters the bluetooth receives to the serial monitor
    Serial.print((char)BT.read());
  }
}


texts: How to create a 1 hour timer with ATtiny13A microcontroller?

texts:
I want to control an AC load such that it powered on for 1 minute, then off for 1 hour, then on again for 1 min, and so on, in a loop.
I just modified the blink sketch to do:

Turn A1 on
Then delay for 60,000 ms
Then turn A1 off
Then delay for 3,600,000 ms (3,600 sec, or 1 hr)

...but it doesn't seem to work.
It looks like the LED connected to A0 turns on but instead of turning off after 1 min, it turns off after 8 min 30 s.
Any suggestions?

I rectified the sketch. Now its takes 1 sec as actual 1 sec 1 choose 1 MHz clock in IDE.
int ledPin =  A3;      // the number of the LED pin
int ledState = HIGH;             // ledState used to set the LED
unsigned long previousMillis = 0;        // will store last time LED was updated
unsigned long OnTime = 60000;           // milliseconds of on-time
unsigned long OffTime = 10000;          // milliseconds of off-time

void setup()
{
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  // check to see if it's time to change the state of the LED
  unsigned long currentMillis = millis();

  if((ledState == HIGH) && (currentMillis - previousMillis >= OnTime))
  {
    ledState = LOW;  // Turn it off
    previousMillis = currentMillis;  // Remember the time
    digitalWrite(ledPin, ledState);  // Update the actual LED
  }
  else if ((ledState == LOW) && (currentMillis - previousMillis >= OffTime))
  {
    ledState = HIGH;  // turn it on
    previousMillis = currentMillis;   // Remember the time
    digitalWrite(ledPin, ledState);    // Update the actual LED
  }
}

then it turns on for 1 sec and then turn off for 1 sec,
then randomly turning on at 30 sec or 1 min 30 sec.
I want to make it on for 1 min every hour.
I tried blink sketch modified as follows:
void setup() {
  pinMode(A3, OUTPUT);
}

void loop() {
  digitalWrite(A3, HIGH);
  delay(60000);
  digitalWrite(A3, LOW);
  delay(900000);
}

but it still turns on for 1 min and turns off for 1 min.
I also tried this:
void setup() {
  pinMode(A3, OUTPUT);
}

void loop() {
  digitalWrite(A3, HIGH);
  delay(60000);
  digitalWrite(A3, LOW);
  delay(3.6e+6);
}

No matter what I do on time and off time always remain same.
I just wanted to know one thing: can I set 1 hour off and 1 min on timer using ATtiny13A or not?
Tried 1.2 MHz, 1 MHz, all clocks in the IDE, nothing seems to work.


texts: File include error while using Arduino Nano

texts:
I am using the code below to interface the Arduino nano and android cell phone to enable serial communication through the USB port. I downloaded the filter library from GitHub https://github.com/JonHub/Filters

I am getting an error saying thet the library is not found.
I would really appreciate some suggestions on this.

Here is my code:

 //This code is for arduino communicating to android phone through USb serial port.
 //For arduino nano

 #include <Filters.h>   //implements digital filters which mimic the analog filter, keep track of variable statistics in realtime

char data_read; //character datatype takes up to 1 byte of memory
unsigned int analog_out;
unsigned long time;
float filterFrequency = 10.0;
FilterOnePole lowpassFilter( LOWPASS, filterFrequency );//implements digital RC type filter; both highpass and lowpass

 void setup()
 {
  Serial.begin(115200); //open the serial port and set the baud rate for communication
  // create a one pole (RC) lowpass filter

 }
 void loop()
 {
 }

 void serialEvent() { //Used when data is unavailable yet
 if (Serial.available()) //checks the number of bytes available for reading from the serial port
 {
data_read = Serial.read();

if (data_read == '0') {
  Serial.print("#");

  //Serial.print("10100");
  analog_out = lowpassFilter.input( analogRead(0) );
  Serial.print(analog_out + 10000);

  Serial.print(":");

  //Serial.print("20200");
  analog_out = lowpassFilter.input( analogRead(1) );
  Serial.print(analog_out + 20000);

  Serial.print(":");

  //Serial.print("30300");
  analog_out = lowpassFilter.input( analogRead(2) );
  Serial.print(analog_out + 30000);

  Serial.print("p");
}
/*if(data_read == '0' || data_read == '1' || data_read == '2' || data_read == '3' || data_read == '4' || data_read == '5'){
  analog_out = lowpassFilter.input( analogRead( data_read-48 ) );
  Serial.print((analog_out)+(data_read-48)*10000);
  Serial.print(":");
  }else if(data_read =='p'){
  Serial.print("p");
  }*/
   }
 }

Here is my error message:

  Arduino: 1.8.5 (Windows 10), Board: "Arduino Nano, ATmega328P"

  C:\Users\daphn\Documents\Arduino\Analog_Serial_out\Analog_Serial_out.ino:4:129: fatal error: Filters.h: No such file or directory

  #include <Filters.h>   //implements digital filters which mimic the analog filter, keep track of variable statistics in realtime

                                                                                ^

  compilation terminated.

  exit status 1
  Error compiling for board Arduino Nano.

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


texts: REST API on Industrial 101 (Yún family) lags, then crashes

texts:
I have tried to set up a very simple REST API on an Arduino Industrial 101 (which is, as far as I understand, equivalent to a Yún). The Arduino is hooked up to a temperature sensor, which value is returned over the REST interface. Everything works fine at first, but over the course of a day it starts taking longer and longer for the device to respond until it completely crashes and becomes unresponsive. (At that point it also doesn't respond to ping and ssh anymore.)

On the Arduino forum there are several threads reporting similar problems (e.g. this one) but they all seem to be at least a few years old and have been solved in the mean time. (The solution reported here, for instance, has already been incorporated in my Linino version.)

If I reset the ATMega the problem persists, but if I reboot the OS it is solved for a day, so I have reason to suspect something on the Linino side is not working properly. Any help would be much appreciated, although I realize this is quite an old board.

My sketch is basically a dumbed-down version of the Bridge example:

#include <Bridge.h>
#include <BridgeServer.h>
#include <BridgeClient.h>

BridgeServer server;

void setup() {
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  Bridge.begin();
  digitalWrite(13, HIGH);

  server.listenOnLocalhost();
  server.begin();
}

void loop() {
  // Get clients coming from server
  BridgeClient client = server.accept();

  // There is a new client?
  if (client) {
    // Process request
    process(client);

    // Close connection and free resources.
    client.stop();
  }

  delay(50); // Poll every 50ms
}

void process(BridgeClient client) {
  // no matter what the command is, return value on A1 sampled 4096 times

  int pin = 1;
  float val = 0;
  for (int i = 0; i < 4096; i++){
    val += float(analogRead(pin))/4096.0;
  }
  client.println(val*5.0/1024.0, 5); //multiply by 5/1024 to get volts

}


texts:
I have put together a system that uses multiple Arduinos and a couple of 20x4 LCD displays to monitor my PV sun tracker and a weather station.  I am using I2C to link them all together.  One of the LCDs has been modified to have a different address (0x3b) so as to not conflict with the first one (0x3f).  So far, so good.   The sun tracker shows its display on the yellow one and the weather station shows its data on the blue one.

In order to connect this together I am using the Mayhew I2C&Power devices, so one power source energizes the entire system.  I send 12 Volts on the wire, then at each node I use a 12v to 5v converter to provide power for the I2C&Power board and the Nanos.  (The anemometer on the WX needs 12V to operate so that's a plus)

Each Arduino has a unique I2C address - there is no master in the system.

I have learned to set the screen updates to be quick (take readings and do any calculations before writing to the LCD in one swell foop), and to stagger the display update timings (the WX info updates every 65050 ms (full display update) and the PV info updates every 67050 ms (4 characters) and 605550 ms (full display refresh).  I chose these (arbitrarily random) values to make it less likely that they would try to update at the same time, because when both systems try to update their respective displays at the same time it causes some very interesting results - basically wiping out one or both displays.  It works most of the time but eventually one or the other screen will get wiped out.

Question:  Is there any way to implement collision detection on the I2C bus to prevent transmitting while other devices are communicating?  Something like CSMA/CD (Carrier Sense Multiple Access with Collision Detection) on Ethernet..


texts:
I have been trying to push the data of temp, humidity, and pressure from a sensor to MQTT using ESP 32Cam, and was able to do using the following code:

pressure = bme.readPressure();

//Convert the value to a char array
char preString[16];
dtostrf(pressure, 1, 2, preString);
Serial.print("Pressure: ");
Serial.println(preString);
client.publish("esp32/pressure", preString);

When I started off with the following code for getting the mac address:

chipid=ESP.getEfuseMac();//The chip ID is essentially its MAC address(length: 6 bytes).
Serial.printf("ESP32 Chip ID = %04X",(uint16_t)(chipid>>32));//print High 2 bytes
Serial.printf("%08X\n",(uint32_t)chipid);//print Low 4bytes.

But when I tried to publish the Chip id, that I was getting on the serial monitor, to the MQTT, an error came up with this:

call of overloaded 'String(uint64_t)' is ambiguous

Here's my code that I tried:

char macValue[16];
String(ESP.getEfuseMac()).toCharArray(macValue,16);
client.publish("esp32/ChipID", macValue);


texts: U8glib Code Help - Simple text display with new line

texts:
I havent coded in C++ for about 10 years and need to relearn,  in the meantime, i have a project that i would like to get working.

I have a sensor which i store uint16_t variables.  I would like to have my loop print my variable at the bottom with some text for the unit, example  "Deg F: (variable)"  and then shift up one line for the next reading.

Im having a lot of trouble with this.  The U8glib example "console" functions almost exactly how i want my code to work,  i simply cannot figure it out.  Ive been experimenting and reading documentation for a week and cannot get it to work.  I can get it to print on top of the old data but I cannot seem to figure out how to shift the line and keep the older data.  im using a SSD1306 128x64 I²C Oled with Arduino uno re.

Thanks.


texts:
I'm trying to communicate with SPI slave using Arduino DUE as master. Device requires commands to be 32 bit wide, SPI mode 3.

I've ran the minimum code (using Arduino IDE 1.8.12) to send some 32 bit wide nonsense, and I've noticed that clock stops for a while after each octet is sent. Also the pause after CS goes LOW is too long.

What is the best practice to achieve a clean 32 bit wide transmission?

#include <SPI.h>

const int cs_pin = 25;
const SPISettings spi_settings(2000000, MSBFIRST, SPI_MODE3);
uint8_t tx_buffer[4];

void setup() {
  pinMode(cs_pin, OUTPUT);
  SPI.begin();
}

void loop() {
  tx_buffer[0] = 0xDE;
  tx_buffer[1] = 0xAD;
  tx_buffer[2] = 0xBE;
  tx_buffer[3] = 0xEF;

  SPI.beginTransaction(spi_settings);
  digitalWrite(cs_pin, LOW);
  SPI.transfer(tx_buffer, 4);
  digitalWrite(cs_pin, HIGH);
  SPI.endTransaction();
}

SCLK - CH1 (Yellow)
CS - CH3 (Purple)
MOSI - CH4 (Blue)

Expected signal:


texts: Is it possible to reduce the size of this program to 1KB

texts:
I want to use attiny13 in my project but this program is going over 1KB

void setup()
{
  Serial.begin(9600);
  delay(2000);
  Serial.println("AT+CMGF=1");
  delay;
}
void loop()
{
  for (int i=0 ;i < 1 ;i++)
  {
    delay(1500);

    Serial.print("AT+CMGS=\"");
    Serial.print("+918269394684");
    Serial.println("\"");
    while(Serial.read()!='>');
    {
      Serial.print("22.7010709,75.9372517");
      delay(500);
      Serial.write(0x1A);
      Serial.write(0x0D);
      Serial.write(0x0A);
      delay(5000);
    }
  }
}


texts:
My google fu must be off.
But I'm trying to get the value of a variable on a ESP8266.
(ie: is pin 2 high?)
I've found tons of examples for the ESP pushing the data (GET/POST) but for the life of me, can't find a way to pull/ask/request for the data/value.
A simple curl or python requests  solution is all I need.
TIA


texts: Can I connect a camera to an arduino mini?

texts: I was wondering if it was possible to connect a camera like this onto an Arduino mini and have the Arduino save video and audio to a micro SD card.


texts: I am facing a problem of firing multiple interrupts on nodemcu 1.0 on single rising edge pulse.what is problem and what are the solutions?

texts: I am working on a project which involves counting the drops falling in a drip chamber of a IV fluid gravity based therapy bottle(saline bottle).I am using IR trans-receiver at the drip chamber to detect a drop falling. I am using a comparator to generate a pulse when ir voltage drops below a certain threshold. The output of comparator is connected to D1 of nodemcu. The ISR is called at rising pulse of comparator .But the nodemcu calls the ISR 3 to 5 times on a single drop.what should I do?plz help.


texts: SIM800l doesn't respond on arduino micro

texts:
I want my Arduino Micro to interact with my SIM 800 L module. But unfortunately nothing happens, may you can help me figure out where I made a mistake. Here's my wiring:

Summary of my wiring:

External Battery ---> 800L
plus ---> 5VIN
minus ---> GND (both in POWER and UART TTL-Section)

Arduino ---> 800L
RX ---> RXD
TX ---> TXD

With that setup I'm using the following code:

#include <SoftwareSerial.h>
#include<Arduino.h>

//Arduino Micro
//SIM 800l

SoftwareSerial mySerial(1, 0); // RX, TX

void setup()
{
  // Open serial communication
  Serial.begin(9600);

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);

  Serial.println("Setup finished");

}

void loop() // run over and over
{
  Serial.println("Sending AT command");
  mySerial.write("AT"); //OK should be returned
  delay(1000);
  //read sim-module response
  Serial.println("Response: ");
  while( mySerial.available() )
  {
    char c = mySerial.read();
    Serial.print(c);
  }

  mySerial.write("at+cmee=2"); //set sim-module into debug mode

  delay(1000);

  mySerial.write("at+cpin?"); //check if pin is necessary

  //read sim-module response
  while( mySerial.available() )
  {
    char c = mySerial.read();
    Serial.print(c);
  }

}

But it gives me the following output as a loop:

 Sending AT command
 Response:
 Sending AT command
 Response:
 Sending AT command
 Response:

And I've noticed that a yellow LED is blinking on the Arduino while running the program so I assume there has to be some input from the SIM800 but I can't read the data at the moment. On the 800L-board itself is also an LED that blinks in an interval of about one second, wich tells you that it has no connection (I live in a relatively remote area) but even if there's no connection shouldn't it still return OK when sending AT?

If you need any further information feel free to ask. I would appreciate every idea you come up with :)

Edit: On the photo the wire goes from the Arduino directly to the 800L but I've changed it so the 800L-power comes from a battery now.


texts: What is the type parameter on the NRF24NetworkHeader member

texts:
Link of the member
What is the character parameter in the above member of the class NRF24Network
I cannot understand the use of it.


texts:
on an ardunio, is there a way to detect if a data connection (vs power only) is present? I want to have my arduino behave differently if connected to a pc, or on stand alone power.

specifically, I have a project that sends keystrokes to a midi piano program I wrote, but when a pc is not connected, I would like to have the arduino send the notes to a peizo buzzer attached to the circuit instead.
Im using a teensy, or a leonardo, or an Uno.


texts: How can I find the time taken while a function is being called?

texts: I tried using millis, but I wanted to know if there is any better way to find out the exact time from when a function is called and finally when it terminates.


texts:
Background:

I am new to Arduino world, and I like to buy a board. I am a bit confused how Arduino products are being sold. Coming from Raspberry world, it seems that I don't know what actually Arduino is.

Question:

I am trying to understand what is it that this product offers:

.

Why it says "For Arduino UNO R3"? 2. Isn't it actually an "Arduino UNO R3"? So why it says "For"?
What are MEGA328P and CH340? Does "Arduino UNO R3" comes with other chipsets?


texts: Arduino Uno - why doesn't memory leak crash the program?

texts:
I wrote this test program:

void loop()
{
    digitalWrite(13,1);
    delay(300);
    digitalWrite(13,0);
    delay(300);
    void *a = malloc(10000000000000000000000000000000000000000);
}

Curiously, the LED keeps blinking and so it means the loops continues.

My question is how can it continue when it runs out of heap memory like that?


texts: query of arduino sketch with regards to employment of gsm sim900a module

texts:
what i'm trying to do is to send message to one whose no. is used in code about balance of sim_card plugged in sim900a.
but i get commands in message or blank message after using ATE0.
what i was thinking is, a kind of response to the commands would be generated in the gsm module which in turn be extracted by me by "String balance=readString();" command then will use it as message context to send to next person.
but this is something i'm having difficulty in accomplishing or there is something i'm probably unaware of.
any help would be greatly appreciated...thanks...
#include<SoftwareSerial.h>
SoftwareSerial gsm(2,3);

String n="+921234567899";

void setup()
{
  gsm.begin(9600);
  Serial.begin(9600);
  //
  gsm.println("AT"); resp();
  gsm.println("AT+CMGF=1"); resp();
  gsm.println("AT+CUSD=1"); resp();
  gsm.println("AT+CUSD=1,\"*111#\"\r"); resp();
  String balance=gsm.readString();
  //
  gsm.println("AT"); resp();
  gsm.println("AT+CMGF=1"); resp();
  gsm.println("AT+CMGS=\""+n+"\"r"); resp();
  gsm.println(balance); resp();
  gsm.println((char)26);
}

void loop()
{
  resp();
}

//////
void resp()
{
  delay(500);
  while(Serial.available())
  gsm.write(Serial.read());
  //
  while(gsm.available())
  Serial.write(gsm.read());

}


texts: What is a safe way to power arduino nano with 7.4V Lipo battery?

texts:
I'm trying to power Arduino Nano with 7.4V LiPo battery and use it to run 2 DC motor using L293D. I have figured out how power it with the connection just like in the figure below(the diagram uses Uno and the battery is 9V but try to imagine it as Nano and 7.4V).  I also found another way to power it by connecting the red wire from battery to Vin on the Arduino instead of connecting it to the positive power rail.

So, my question is which is a safer way to power it and what is the difference and risk of one the way I mention.


texts: Migrating from ATMega2560 to ARM based -- Teensy vs Due?

texts:
I currently have a project that is working on an AtMega2560 platform (heavily derived off the Arduino Mega). It mainly involves a GPS module and SD card.

Going forward I am looking to add a few more sensors (IMU etc.). I would like to a more powerful microcontroller -- for the high rate logging I need and also it seems best from a future scalability perspective.

I would like to start with using one of the ARM based uC platforms available out there, transition my software to it using a breadboard setup, and then eventually make a custom board.

So my QUESTION is:
Which would be an easier option from a migration/transition and community support point of view --- Teensy or Due? I currently use the SDFat and Adafruit GPS libraries, the SDFat being a major concern for migration.

Any other considerations/suggestions/advice will be appreciated.

Thank you.


texts:
I am testing the basic Software Serial example on the arduino website, but I cant get the myserial to print

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

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

 Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(4800);
  mySerial.println("Hello, world?");
}

void loop() { // run over and over
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
}


texts:
For the past couple of weeks, I have not been able to find a solution to my problem.  My problem is that I cannot retrieve the data from my homemade ECG that I created from Arduino.  I am a total amateur at this, but I'm pretty sure it's a circuitry issue.  Here is what my circuit looks like now.  (Note: the thing that says 'Dual O' on the far left is the instrumentation amplifier, not an operational amplifier like the one near the middle)

Here is the code I'm using:

const int  signal = 5;    // Pin connected to the filtered signal from the circuit
unsigned long currentBeatTime;
unsigned long previousBeatTime;

unsigned long frequency;

// Internal variables
unsigned long period = 0;
int input = 0;
int lastinput = 0;

void setup() {
pinMode(signal, INPUT);
Serial.begin(9600);

previousBeatTime = millis();
}

void loop() {
delay(500);
input = digitalRead(signal);

if ((input != lastinput) && (input == HIGH)) {
    // If the pin state has just changed from low to high (edge detector)
    currentBeatTime = millis();

    period = currentBeatTime - previousBeatTime; // Compute the time between the previous beat and the one that has just been detected
    previousBeatTime = currentBeatTime; // Define the new time reference for the next period computing
}

lastinput = input; // Save the current pin state for comparison at the next loop iteration

// Detect if there is no beat after more than 2 seconds
if ( (millis() - previousBeatTime) > 2000 )
{
    Serial.println("dead");
}
else
{
    if (period <= 0)
    {
        frequency = 0;
    }
    else
    {
        frequency = 60000/period; // Compute the heart rate in beats per minute (bpm) with the period in milliseconds
    }

    Serial.print(frequency);
    Serial.println(" : alive! ");
}
}

I would appreciate if someone could get back to me as soon as possible.  Thank you!

EDIT:
Here's a schematic.  I used Fritzing, and since I am a total beginner at this, it looks like a complete mess.  Anyways, here it is:

Thank you for your help.


texts:
I've been working on image transmission using XBee S2B Pro modules and Arduino Mega. Main task is to transmit a jpg image taken by a jpeg serial camera at the transmitter and send it to a microSD memory at the receiver, but I've been dealing with one unique trouble: I need a delay of 2 seconds to send and receive 1 byte successfully. If I set fewer seconds I lose information and the received image gets corrupted. Here you will see my codes:

Transmitter code:

byte ZERO = 0x00;
byte incomingbyte;
long int a=0x0000,j=0,k=0,count=0,i=0;
uint8_t MH,ML;
boolean EndFlag=0;

void SendResetCmd();
void SetBaudRateCmd();
void SetImageSizeCmd();
void SendTakePhotoCmd();
void SendReadDataCmd();
void StopTakePhotoCmd();

void setup()
{
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  Serial1.begin(38400);
}

void loop()
{
  byte a[32];
  int ii;
  SendResetCmd();
  delay(4000);
  SendTakePhotoCmd();
  delay(1000);
  while(Serial1.available()>0)
  {
    incomingbyte=Serial1.read();
  }
  while(!EndFlag)
  {
    j=0;
    k=0;
    count=0;
    SendReadDataCmd();
    delay(20);
    while(Serial1.available()>0)
    {
      incomingbyte=Serial1.read();
      k++;
      if((k>5)&&(j<32)&&(!EndFlag))
      {
        a[j]=incomingbyte;
        if((a[j-1]==0xFF)&&(a[j]==0xD9))     //tell if the picture is finished
          EndFlag=1;
        j++;
        count++;
      }
    }
    for(j=0;j<count;j++)
    {
      Serial.write(a[j]);
      delay(2000);// observe the image through serial port
    }
    i++;
  }
  while(1);
}

void SendResetCmd()
{
  Serial1.write(0x56);
  Serial1.write(ZERO);
  Serial1.write(0x26);
  Serial1.write(ZERO);
}

void SetImageSizeCmd()
{
  Serial1.write(0x56);
  Serial1.write(ZERO);
  Serial1.write(0x31);
  Serial1.write(0x05);
  Serial1.write(0x04);
  Serial1.write(0x01);
  Serial1.write(ZERO);
  Serial1.write(0x19);
  Serial1.write(0x11);
}

void SetBaudRateCmd()
{
  Serial1.write(0x56);
  Serial1.write(ZERO);
  Serial1.write(0x24);
  Serial1.write(0x03);
  Serial1.write(0x01);
  Serial1.write(0x2A);
  Serial1.write(0xC8);
}

void SendTakePhotoCmd()
{
  Serial1.write(0x56);
  Serial1.write(ZERO);
  Serial1.write(0x36);
  Serial1.write(0x01);
  Serial1.write(ZERO);
}

void SendReadDataCmd()
{
  MH=a/0x100;
  ML=a%0x100;
  Serial1.write(0x56);
  Serial1.write(ZERO);
  Serial1.write(0x32);
  Serial1.write(0x0c);
  Serial1.write(ZERO);
  Serial1.write(0x0a);
  Serial1.write(ZERO);
  Serial1.write(ZERO);
  Serial1.write(MH);
  Serial1.write(ML);
  Serial1.write(ZERO);
  Serial1.write(ZERO);
  Serial1.write(ZERO);
  Serial1.write(0x20);
  Serial1.write(ZERO);
  Serial1.write(0x0a);
  a+=0x20;
}

void StopTakePhotoCmd()
{
  Serial1.write(0x56);
  Serial1.write(ZERO);
  Serial1.write(0x36);
  Serial1.write(0x01);
  Serial1.write(0x03);
}

Receiver code:

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

File myFile;
int pinCS = 53; // Pin 10 on Arduino Uno

void setup()
{
  Serial.begin(9600);
  pinMode(pinCS, OUTPUT);
  if (!SD.begin()) {
    return;
  }
}

void loop() {
  byte buf[5000];
  if (Serial.available()>0)
  {
    myFile = SD.open("imgrx.jpg", FILE_WRITE);
    Serial.readBytes(buf,sizeof(buf));
    Serial.println((byte)*buf);
    myFile.write((byte)*buf);
    while(Serial.available()>0) Serial.read();
  }
  else{
    myFile.close();
  }
}

I've tried a MicroSD -> XBEE -> MicroSD also and that trouble continued there, maybe I've passed through something and I'd like to tell me where. Let me add these methods give me images identical to the ones I send, so even slowly, it's very effective. I changed baudrates without any success. Xbee adresses are connected as unicast. I also tried using only Serial.readBytes and I got Bytes faster but as decimal values and is unreadable.

I would really appreciate any information or experience approach to solve this problem. Ask me anything you don't understand about my question.


texts: How can I maintain PWM output while still performing other tasks?

texts: I want to generate a PWM signal that I can turn on and off with a button press without using interrupts.  Is there a way to keep the PWM output going while running other processes?


texts: Flash a hex file to an MCU/Arduino over the air?

texts:
I have a processor AT328 , Arduino bootloaded, and a Bluetooth on the serial lines Tx,Rx .

I would like to program the chip over Bluetooth, not using a computer or IDE, but mobile phone with my own Hex uploader.

So, if the hex file was just a huge text that you have to send, i would obviously just send it and thats it, as I understand there is a mechanism ?

Question : How exactly a Hex file is sent over serial to program the chip ? is it like any other text file? is there any mechanism I have to write? specific baud rate? is there any article about this ?


texts:
I am using the following code to check if the value is 0 e.g there is no weights placed and if so, it will ignore this value and do nothing with it. The code runs correctly but keeps outputting the following:

  Soft WDT reset

        stack>>>

  ctx: cont sp: 3ffffd70 end: 3fffffc0 offset: 01b0 3fffff20:  00000050
  00000000 31310010 36323439   3fffff30:  00000000 00000000 00000010
  00000001   3fffff40:  3ffee408 00000000 00000000 40202927   3fffff50:
  4022dff2 a0000000 bf2cc404 3ffe84dc   3fffff60:  3ffee408 bf2cc404
  3ffee408 40202962   3fffff70:  3ffeeb9c 40202c00 3ffee408 40202996
  3fffff80:  3ffee448 bf2cc404 3ffee408 40202664   3fffff90:  3fffdad0
  fffe2d7e 3ffee448 3ffee4b0   3fffffa0:  3fffdad0 00000000 3ffee480
  40203848   3fffffb0:  feefeffe feefeffe 3ffe8514 40100a41
  <<

If I remove if(reading < 0.01){ the code runs fine. What could be causing this?

#include "HX711.h"
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

#define DOUT  D3
#define CLK  D2
const char* ssid = "Curtis";
const char* password = "password";

HX711 scale(DOUT, CLK);
float calibration_factor = -118470; //-7050 worked for my 440lb max scale setup
void joinwifi(){
    WiFi.begin(ssid, password);
  Serial.println();
  Serial.print("Connecting");
   while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println("success!");
  Serial.print("IP Address is: ");
  Serial.println(WiFi.localIP());
}
void setup() {
  Serial.begin(9600);
  joinwifi();
  Serial.println("HX711 calibration sketch");
  Serial.println("Remove all weight from scale");
  Serial.println("After readings begin, place known weight on scale");
  Serial.println("Press + or a to increase calibration factor");
  Serial.println("Press - or z to decrease calibration factor");
  scale.set_scale();
  scale.tare(); //Reset the scale to 0
  long zero_factor = scale.read_average(); //Get a baseline reading
  Serial.print("Zero factor: "); //This can be used to remove the need to tare the scale. Useful in permanent scale projects.
  Serial.println(zero_factor);
}
void loop() {
  while (WiFi.status() == WL_CONNECTED)
  {
    scale.set_scale(calibration_factor); //Adjust to this calibration factor
    float reading = scale.get_units(1);
    if(reading < 0.01){
      Serial.print("no need");
       Serial.println();
    }
    else{
      Serial.print("Reading: ");
      Serial.print(reading);
      Serial.print(" lbs"); //Change this to kg and re-adjust the calibration factor if you follow SI units like a sane person
      Serial.print(" calibration_factor: ");
      Serial.print(calibration_factor);
      Serial.println();
      if(Serial.available())
      {
        char temp = Serial.read();
        if(temp == '+' || temp == 'a')
          calibration_factor += 10;
        else if(temp == '-' || temp == 'z')
          calibration_factor -= 10;
      }
    }
  }
  while (WiFi.status() != WL_CONNECTED)
  {
    joinwifi();
  }

}


texts:
I am planning to make a laser tripwire but I have an issue. Let me explain what I am trying to do:
Making a laser tripwire is actually pretty easy at its core. You just need an LDR and a laser diode. You look at the normal results of the LDR; it's usually around 60.
When the laser hits the LDR, it's usually around 600 so you write an if statement saying if LDR value is below 500, power the LED or buzzer.
But there is an issue here. The LDR module must be connected to Arduino with cables for signalling. I don't want that. Luckily, I have a Bluetooth module but I have no idea how to use it for sending signal to my Android phone. I know how to send signals though. So to simplify things:
1Can I send any kind of signal to my phone with Bluetooth (I am using an app called Arduino Bluecontroll but I can upload a different app if necessary)? If yes, how?


texts: Using Temperature sensor arduino to trip off an ac device

texts: Using Temperation through arduino to trip off an ac device?


texts: How do I convert a program made on Notepad to my Arduino on Proteus

texts:
I had the Arduino IDE but I accidentally deleted it. I have no internet connection, so I could not download it again. I do not currently possess the Arduino hardware itself but I do have Proteus and the Arduino library in it.

So I want to program my Arduino. Previously I would simply write the sketch and compile it and go to where I compiled it and simply add it on my Proteus Arduino and run it. Since I don't have the Arduino IDE, I tried using Notepad and tried to save it as a .hex file and run it on Proteus and there was an error created saying Error reading hex file.

So how can I program my Arduino on Proteus with the given materials (Notepad, Proteus)? Can it be done? Or is there any other way?


texts:
I'm making a simple Arduino web server and I want to keep it turned on all the time. So it must endure to stay working continuously.

I'm using an Arduino Uno with a Ethernet Shield.
It's powered with a simple outlet power supply 5V @ 1A.

My Questions:

Will I have any problems leaving the Arduino turned on all the time?
Is there some other Arduino board better recommended for this?
Are there any precautions that I need to heed regarding this?


texts: Generating two 1MHz, 33% duty cycle PWM signals

texts:
I have been trying to generate two identical PWM signals. Both the signals should have a duty cycle of 33%. The first signal starting at 0us and the other at 0.5us. After watching the tutorials I came up with the following code but the code does not compile.

#include <PWM.h>

pinMode(3, OUTPUT);
pinMode(11, OUTPUT);
TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
TCCR2B = _BV(CS22);
OCR2A = 76;
OCR2B = 76;

The way I figured is

Duty cycle A & B= (76+1)/256= 33%. I'd appreciate any help that I can get. Cheers!


texts: Risks when commanding multiple chips with same address via I2C

texts:
I know that I2C devices are supposed to have unique addresses when used. What if I still use multiple devices with the same address, what can go wrong? Let me describe the situation:

I have multiple digital capacitors (NCD2400M by IXYS) and I would be using them so, that I always send the same command to every chip. I have no need of reading anything from those, which is the reason I was thinking why should I bother multiplexing my I2C line. I have no reason to identify them, only commanding. For the commanding I use Arduino (Nano currently, might change to some other Arduino model).

I have already tried commanding them simultaneously and it works like a charm. I tried so that I connected SDA and SCL of four chips and used RC circuit and square wave to check the rise time to verify that every chip indeed changes their capacitance.

However, I'm new to I2C protocol and I'm not yet aware of every detail. I guess there could be issues when one of the chips fail? Can I assume in this case that nothing goes wrong with the ACK/NACK bit since the chips are "identical"?

-RautSa

EDIT:
After using correct keywords for searching I found this previously asked question. Based on that I now understand at least there would be a problem when only one of the chips tries to send NACK bit.


texts: Is the SIM800L 3G? Or is it able to connect to 3G?

texts: I am working on SIM800L. I am using a 3G SIM with a SIM800L. I am able to send messages and call using SIM800L, but when I am using the AT+HTTPINIT command it is not working. It is giving an error like operation unavailable. If wonder whether the SIM800L supports 3G/4G, or whether it only supports 2G.


texts:
Question:
Is there a way to collect any data (e.g. MAC addresses, installed devices, driver versions, etc.) from a PC by simply connecting an Arduino via USB to it, so that this PC can be clearly identified?

Background:
Basically, I`m using an Arduino to send some text to a computer by emulating a keyboard, but I don´t want the text to be sent to any computer I connect the Arduino with. That is why I want the PC to be identified first.

To be clear: this should be done without having to install programs on the PC in the first place.


texts: Can a DC motor use more current than its datasheet?

texts:
I am using small dc motors connected to the 5V of the arduino which is known to provide 200mA without damaging it.

The motor I am using is a very common one found in toys -> https://www.sparkfun.com/datasheets/Robotics/ROB-09608.jpg

As I see the maximum current of this motor is 170mA. Does it mean that the motor will not drain more current than that or it means that I need to use a resistor in series with my 5V in order to make sure the current will not pass 170mA?


texts: if two arduinos are connected by I2C and one of them is using an ethernet shield, does that grant both of them access to the internet?

texts: i have two arduino mega and they send data to each other by an I2C connection. But one of those arduinos is connected to an ethernet shield which allows it to send data to a web server. Being both connected does that mean that they both can send or access the web server. Sorry if any ambiguity was found but I didnt find a better way to ask this question.


texts:
I am using a custom built arduino UNO for some personal projects. I am using a custom optiboot bootloader given by Nick in this post. This was done to prevent the three LED flashes on digital pin 13.

I have noticed a weird thing with the setup. During normal operation, I am able to reset it by pulling the reset pin low. Sometimes, my microcontroller freezes due to noise and I am unable to reset it by pulling the reset pin low. However powering it off and back on still works.

I am wondering what could be a possible cause for this. Is it the custom bootloader or whether power on reset is different as compared to normal reset? Is there a way to ensure atmega328 always resetting through reset pin? Can noise affect the chip and make it behave in such a way?

After some google searches, I found an issue where people disable the reset pin functionality by setting a fuse but this doesn't seem to be that case because I am able to reset the chip during normal operations.

Updates and edits:

@Nick - Bootloader seems to be working fine. I have ruled out any issues due to the bootloader that you provided because I am having similar issues with original ones as well.

Custom arduino has all the necessary circuit elements - including reset pin pullup 10K resistor and 1N4148 protection diode. I am able to program and run the code without any trouble.

Sometimes, due to electromagnetic noise, the atmega locks up. GPIO doesn't work. Here is a separate question explaining this.

During tests, I leave the board running and wait for that hang-up to occur. During this time period, I deliberately try to induce noise in ac lines (by switching on/off appliances, turning the fan regulator knob etc). When it hangs up, I try to reset it by pulling the reset pin low using a wire. Sometimes it resets and sometimes it doesn't. When it doesn't, the only way out is to power it down and power it up back again.


texts: millis() function always returns same value

texts:
I'm trying to program an Arduino MKR1000 and I am using the millis() function to emulate a traditional timer.  The problem is that any call to millis() inside the debounceTimer() function returns the same value.  I only added the Serial.print to debug.

I left out a decent bit of the code to simplify your reading of it.  It works by waiting for an interrupt on pin 4 which then calls the runTimers() function and that calls the debounceTimer() function and within that the millis() function is called. The debouncetimer() function keeps getting called until the 10 ms has elapsed and then should end the timer.  The problem is that the millis() function stops returning a value that goes up.

#define doorIntPin 4
unsigned char sysEnabled = 0;
unsigned long debounceTimerPlace =0;
unsigned char debounceTimerOn =0;

void setup() {
  Serial.begin(9600);
  attachInterrupt(doorIntPin, doorOpens, LOW);
  interrupts();
}

void loop() {

}
void runTimers(){
  Serial.print('r');
  while(alarmTimerOn || debounceTimerOn || enablingTimerOn){
     if(alarmTimerOn)
      alarmTimer();
    if(enablingTimerOn)
      enablingTimer();
    if(debounceTimerOn)
      debounceTimer();
  }
}

void debounceTimer(){
  unsigned long time = millis()- debounceTimerPlace;
  Serial.println(millis() & 0xFFFF, DEC);
  if(sysEnabled && time> 10){
    debounceTimerOn=0;
  }
}
void doorOpens() {
  Serial.print('o');
  if(!debounceTimerOn){
      debounceTimerPlace = millis();
      debounceTimerOn=1;
  }
  runTimers();
}

I suspect that in the background an interrupt is being called than increments the value millis() returns and somehow my external interrupt is disabling that.  I don't know why this is happening or how to fix it.

Any ideas?


texts:
Using old NXP HEF4094BP shift register chips, for the reason of fixing some old hardware. These chips were popular in the 90's because they could accept 3-15V VCC and directly drive series+parallel LED chains. Think: gas station price signs, etc.

I'm green. Using this post and the 4094 datasheet, I've successfully modeled your typical shift register count-to-100 binary, with an LED on each SR out. Powered by 5V, works great. This was phase 1 for me.

For phase 2, I powered the Arduino via 12V (via p30, Vin). Still supplying 5V to the 4094 (Nano pin 27 output), works great.

Phase 3, I need help. I remove the 5V jumper that was from Nano pin 27 going into 4094's VCC pin. In it's place, I run 12V directly from the (regulated) PS and I get NO LED output.  I know I haven't burned anything out because at 12V I get brief "flashes" when I'm "plugging" in the 12V power supply. I can revert to 5V VCC input and it works fine as before.

I've read the datasheet 3X and it's not clear how the chip's output pin voltage is managed when you alter the VCC to be higher (is it limiting current or voltage on the outputs?)


texts:
I'm really new to coding and Arduino so I would be eternally grateful for the help.

I'm trying to make a really basic flame sensor that beeps, lights up an LED and displays the distance from the sensor to the flame when activated. I keep getting a "'Serial' does not name a type" error message for the line that reads - Serial.println(analogRead(A0));

I’ve tried to figure it out from the information on this forum of similar questions to try to correct the issue but it seems like every time I fix one thing another 2 errors come up. I’ve been stuck on this one for a little while so I’m hoping I might be able to receive some kind of assistance from the Arduino community.

Below is the entire code - any help is appreciated, thanks :)

int Led = 4;
int Buzz = 7;
int Sensor = 11;
int Fire = HIGH;
void setup()
{ Serial.begin(9600);
pinMode(Buzz,OUTPUT);
pinMode(Sensor,INPUT);
pinMode(Led,OUTPUT);
}
void loop()
{
Fire = digitalRead(Sensor);
if(Fire == HIGH);
Serial.print("analog Read = ");
Serial.print(analogRead);
}
Serial.println("HELP! A FIRE!");
digitalWrite(Buzz,HIGH);
digitalWrite(Led,HIGH);
delay(200);
digitalWrite(Led,LOW);
delay(200);
Serial.println(analogRead(A0));
}
else
{
Serial.println("No fire detected");
digitalWrite(Buzz,LOW);
digitalWrite(Led,LOW);
}
delay(500);
}


texts: What are all the cameras that are compatible with ATtiny microcontroller?

texts: I need a tiny camera to attach with my ATtiny microcontroller for a light weight and small sized application to take pictures at a particular time and send to the device. So, what are the camera models that are compatible with ATtiny series?


texts: Pro Mini 5v with Adafruit motor shield v1 power sharing problems

texts:
I am trying to convert a RC car into autonomous car using Arduino Pro Mini 5v 16 Mhz. I have done this with UNO and Adafruit motor shield 1.0 with 4 gear motors and one micro servo for mounting range finder sensor. That worked fine.

Need to mention here that originally the RC car was using 5 AA cells for 2 motors and its RC reciever which looks like a customized motor shield as well.

I tried to move everything to Arduino Pro Mini 5v, and motor shield v1 to reduce space. Now how I wired everything.

Uses 8 AA cells to power the motor shield on EXT-PWR input.
From EXT-PWR in motor shield one wire goes to RAW in Pro mini.
From Pro Mini, VCC connected to +5v on motor shield.
One micro servo having range sensor getting its current from motor shield.
Motor shield has to run two motors, 1 for rear wheels and 1 for turning front wheels. (they are small motors look like 3v)

Now when I turn on the power the motor sometimes run and sometimes sound like bee and no movement. That also cause the L293d chip on motor shield becomes very hot and I think I have burnt one yesterday and replaced it from another motor shield. Same for servo it sometimes move or not move but sounds like hmmmmmmmm. The Arduino power light on and red. But sometimes it flickers and other light is also on and off.

At this point I have no idea whats wrong here. I changed the input voltage to lower but no progress. Tried to disconnect the 5v input from Pro Mini to motor shield and give 9v input to motor shield but nothing works. Please suggest best or correct power distribution in this case.

Thanks

Qazi


texts:
We're complete beginners with Arduino and we're working on a project that moves a pointer based on a color sensor reading.

We used two servo motors each: one performs a specific task, the small servo works pretty fine. The problem is with the larger one.

We used this servo motor model: (towardpro MG996R), Arduino Uno and a color sensor. Because the motor is large we connect it to a 9 V power supply.

But when we run the code it just vibrates in place and the arm won't move :(

Is there anything else we need to add to the circuit like a resistor or some thing?

#include <Servo.h>
Servo largeServo;

void setup() {
  largeServo.attach(6);
  largeServo.write(0);
}

void loop() {
  largeServo.write(0);
  delay (2000);
  largeServo.write(30);
  delay (2000);
  largeServo.write(60);
  delay (2000);
  largeServo.write(90);
  delay (2000);
}


texts: What type of relay will handle a 51 amp 10 hp motor and a 75 amp 15 hp motor?

texts: I'm using an arduino uno and gprs gsm shield with Numato relay.


texts:
I use Arduino IDE 1.6.6 on Ubuntu 15.10.

Starting the Arduino IDE without using sudo fails for both:

uploading the code to the Arduino Uno
starting the serial monitor

The group I need to add my user to is called dialout:

myuser@mycomputer:~$ ls -l /dev/ttyACM*
crw-rw---- 1 root dialout 166, 0 Dez 12 17:57 /dev/ttyACM0

So I added myuser to dialout:

sudo usermod -a -G dialout myuser

Somewhere I read that I have to add myuser to tty as well, so I did it:

sudo usermod -a -G tty myuser

Though I still fail with the above mentioned when trying to use the IDE with myuser.

What do I have to do to get the IDE working with myuser?


texts:
I'm using MPU9250 which has both accelerometer and gyroscope in a vehicle. What I want is to just know that if the vehicle is currently moving or not. I searched and find out that I can't get velocity easily so I skipped that but I was wondering how can I found movement with an IMU.

Edit:
As @Duncan said, it seems that it cannot be examined with only IMU. I also have a GPS sensor in my device and having the speed value from GPS but it is not very accurate. For example, if the vehicle is stopped for 5 minutes I get variable speeds between 0 to 10.0 kmph and on the other hand getting the location as lat/long has about 20 meters error. So I can't really rely on it. I was wondering can I combine both GPS and IMU to find out if it is really moving or not?
One solution that I came was relying on GPS speed but for spikes just check the accelerometer variations and if it is beyond a threshold, it means that it actually moved.


texts:
I have the Arduino shield described here, I have run the example code compiled to the device, both v1 and 1.1 example, and it shows nothing whatsoever on the screen.

https://www.dfrobot.com/wiki/index.php/Arduino_LCD_KeyPad_Shield_(SKU:_DFR0009)

Is there a special trick to initializing this or did I yet again get a lemon that will not display anything?


texts: How to use #define in a library I'm trying to write?

texts:
I have written simple code to enable toggling of serial.print debug data.

  #define DEBUG
  #ifdef  DEBUG
    #define DEBUG3(x,y,z) Serial.print(x);Serial.print(" ");Serial.print(y);
     Serial.print(" "); Serial.println (z)
    #define DEBUG2(y,z) Serial.print(y);Serial.print(" ");Serial.println
     (z)
    #define DEBUG(z) Serial.println(z)
    #define DEBUGln  Serial.println("");
  #else
    #define DEBUG3(x,y,z)
    #define DEBUG2(x,y)
    #define DEBUG(x)
    #define DEBUGln
  #endif

Then I can just call DEBUG3("words",value,"words"); anywhere in the sketch and it will automatically print out the text, int, strings, etc with a single space between and automatically go to next line etc etc.

Just define the correct number of fields to print and separate using commas.

If I want to turn off debug then I just comment out #define DEBUG at the top.

Now the issue is I don't want to copy in this code every time I want to use it, so it makes sense to make it a library so that I can just call something like:

#include <SERIAL_DEBUG.h>
#define DEBUG     (or //#define DEBUG) //to enable or disable

The reason being that sometimes I might want to print up to 10 things on a single line (not very often but it could happen).

This is my first library attempt and I'm having a hard time finding any information on how I would go about setting up the .h and .cpp files for this type of #define DEBUG(x) Serial.println(x) and the #define DEBUG (from sketch) parts.


texts: How to assign an interrupt to a button press with an ATtiny? (interrupt not fired with my code)

texts:
(Here is finally a solution).

I'm using the following code on a ATtiny45 to assign an interrupt to a button press (pin #7, PB2, INT0). However the LED doesn't blink when the button is pressed, as if the interrupt is not working. Why?

Note: I'd like to use the least power when no interrupt happens, to have a current in the order of magnitude of ~ 1 µA, to run from batteries for years.

#include <avr/sleep.h>

void setup()
{
  pinMode(4, OUTPUT);  // LED
  pinMode(0, INPUT_PULLUP);
  pinMode(1, INPUT_PULLUP);
  pinMode(2, INPUT_PULLUP);      // pin #7 = PB2
  digitalWrite(4, HIGH); delay(100); digitalWrite(4, LOW);  // LED blink, working here
}

void wake()
{
  sleep_disable();
  detachInterrupt(0);
  digitalWrite(4, HIGH);  // LED not working here when pressing the button
}

void loop()
{
  sleep_enable();
  ADCSRA = 0;
  attachInterrupt(0, wake, CHANGE);
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  sleep_cpu();
}

Note:

I'm using Arduino IDE with damellis' attiny, I also tried with Spence Konde's ATtinyCore but it's the same
In my real code, I have 3 buttons, on pin #5, #6, #7, so eventually I'd like to have interrupts for all these three pins.
I've read https://gammon.com.au/forum/?id=11497 but using noInterrupts() / interrupts() did not change anything in my case.
I've tried "Sketch J" from https://gammon.com.au/forum/?id=11497 but EIFR = bit (INTF0); gives an error: 'EIFR' was not declared in this scope (I'm compiling from Arduino IDE); probably this works on an ATmega but not ATtiny.

Edit: Here is a working code of deep sleep, with an interrupt when the pin #5 (PB0) changes...

#include <avr/interrupt.h>
#include <avr/sleep.h>

ISR(PCINT0_vect) {
  if (digitalRead(0) == LOW)
    digitalWrite(4, HIGH);
  else
    digitalWrite(4, LOW);
}

void setup() {
  pinMode(4,OUTPUT); // LED
  pinMode(0,INPUT_PULLUP);
  pinMode(1,INPUT_PULLUP);
  pinMode(2,INPUT_PULLUP);
  ADCSRA = 0; // ADC disabled
  GIMSK = 0b00100000;  // General Interrupt Mask Register, / Bit 5 – PCIE: Pin Change Interrupt Enable / When the PCIE bit is set (one) and the I-bit in the Status Register (SREG) is set (one), pin change interrupt is enabled. Any change on any enabled PCINT[5:0] pin will cause an interrupt. The corresponding interrupt of Pin Change Interrupt Request is executed from the PCI Interrupt Vector. PCINT[5:0] pins are enabled individually by the PCMSK0 Register. / see https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf
  PCMSK = 0b00000111;  // Pin-change interrupt for PB0, PB1, PB2
}

void loop() {
  sleep_enable();
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  sleep_cpu();
}

...but for an unknown reason, if I add this code:

ISR(PCINT1_vect) {
  if (digitalRead(1) == LOW)
    digitalWrite(4, HIGH);
  else
    digitalWrite(4, LOW);
}

the pin-change interrupt for PB0 still works (PCINT0), but not the interrupt for PB1 (PCINT1). Why?


texts:
So I have been trying to write a code where I use the millis() function to print the milliseconds of on-time of the board using Serial. But the condition is I want to stop printing the value once it reaches 10 seconds (10000ms).

I have been trying to use the exit() function but I get no output then.

#include<stdlib.h>

void setup()
{

  Serial.begin(9600);          //  setup serial

}

void loop()

{

unsigned long timer1;

while(timer1%10000!=0)

{

timer1=millis();

Serial.println(timer1);

}

    exit(1);

}


texts: Communication between Genuino Zero and Arduino Uno using UART

texts:
I want to make my Arduino Uno and Genuino Zero communicate using UART. My Genuino Zero is the transmitter and the receiver is the Arduino Uno.
For the Arduino Uno, I am using the SoftSerial library. I have uploaded the transmitter and receiver codes.
My connection is as below:

Genuino Zero (RX) pin 0 ---------------- Arduino Uno pin 11
Genuino Zero (TX) pin1  ---------------- Arduino Uno pin 10
Ground ----------------------------------   Ground

The Arduino Uno's pin 10 is Rx and pin 11 is Tx, using SoftSerial.
The transmitter transmits 'a'. The receiver receives 'a' and turns a LED on. My problem is that on the receiver, I am not getting anything.
My code is here:
https://www.dropbox.com/s/4w8o2h2k4zs0it5/transmitter.txt?dl=0
https://www.dropbox.com/s/d50uizoz3iove9w/receiver.txt?dl=0
-------------------receiver---------------------
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX

/* Simple Serial ECHO script : Written by ScottC 03/07/2012 */

/* Use a variable called byteRead to temporarily store
   the data coming from the computer */
byte byteRead;

void setup() {
// Turn the Serial Protocol ON
  Serial.begin(9600);
   mySerial.begin(9600);
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  char a[8];
  /*  check if data has been sent from the computer: */
  if (Serial.available()) {
    /* read the most recent byte */
    byteRead = Serial.read();
    Serial.print("rushin\r\n");
    /*ECHO the value that was read, back to the serial port. */
    if(byteRead == 0x61) {
      digitalWrite(LED_BUILTIN, HIGH);
      Serial.write(byteRead);
    }
  }
  if (mySerial.available()) {
    /* read the most recent byte */
    byteRead = mySerial.read();
    mySerial.print("rushin\r\n");
    /*ECHO the value that was read, back to the serial port. */
    if(byteRead == 0x61) {
      digitalWrite(LED_BUILTIN, HIGH);
      mySerial.write(byteRead);
     }
  }
}

-------------------transmitter----------------------------------

/*
  DigitalReadSerial
 Reads a digital input on pin 2, prints the result to the serial monitor
 This example code is in the public domain.
 */

// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 7;
// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  // make the pushbutton's pin an input:
  pinMode(pushButton, INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input pin:
  int buttonState = digitalRead(pushButton);
  // print out the state of the button:
  Serial.println("a");
  delay(1000);
  // delay in between reads for stability
}


texts: What are the sizes of each primitive datatype on a Metro M4 Express SAMD51?

texts: What are the data sizes of all the primitive datatypes on a Metro M4 Express SAMD51 C++ implementation? In some C++ implementations, int has 16 bits and in other implementations it has 32 bits. Is


texts: What does this error mean?? Arduino Due loop warning

texts:
I am getting this error on compilation of the code given further below;

warning: iteration 3u invokes undefined behavior [-Waggressive-loop-optimizations]
leds[XY (x, y)].r = redarray[x][y];
note: containing loop
for(uint8_t x=0; x < MatrixWidth; x++){

Code:
 // the header files for the RGB data

#include <FastLED.h>
#include "redarray.h"
#include "greenarray.h"   //g data header file (hex or dec)
#include "bluearray.h"   //b data header file (hex or dec)*/

 //matrix parameters

#define MatrixWidth 36 //columns (x)
#define MatrixHeight 1 //rows (y)
#define numled (MatrixWidth * MatrixHeight)

//pin details

#define datapin 7

#define clockpin 8

CRGB leds[MatrixWidth * MatrixHeight];

const bool  MatrixSerpentineLayout = true;

void setup() {

   FastLED.addLeds<APA102, datapin, clockpin>(leds,numled);
   FastLED.clear();
         }

void loop() {
   for(uint8_t y=0 ; y<1 ; y++){
     for(uint8_t x=0; x < MatrixWidth; x++){
         leds[XY (x, y)].r = redarray[x][y];
         leds[XY (x, y)].g = 0;
         leds[XY (x, y)].b = 0;

         FastLED.show();
         delay(50);
     }
   }
 }

  uint16_t XY( uint8_t x, uint8_t y)
  {
      uint16_t i;

      if( MatrixSerpentineLayout == true) {
          if( y & 0x01) {
          // Odd rows run backwards
          uint8_t reverseX = (MatrixWidth - 1) - x;
          i = (y * MatrixWidth) + reverseX;
    } else {
         // Even rows run forwards
         i = (y * MatrixWidth) + x;
    }
}
   return i;
}

The following is redarray header -
//RED
const byte redarray[3][36] PROGMEM = {
{0x00,  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
};
How to remove this warning. The redarray is not being read properly by arduino. THe above code should make the 36 LEDs turn off (black) as per the header file. They are randomly lit red... I am totally perplexed!
Plz help if somebody can.
Thanks!


texts:
I am playing with 3,5" (400x240) TFT display which is placed into Arduino Mega 2560 R3 board.

My final goal is taking .raw data from SD card and drawing it on display.

What I have done so far:

- My drawing method in the sketch:

void LoadImage(File& file)
{
    for (int y = 0; y < SCREEN_HEIGHT && file.available(); y++) {
        uint16_t buf[SCREEN_WIDTH];
        for (int x = SCREEN_WIDTH - 1; x >= 0; x--) {
            byte l = file.read();
            byte h = file.read();
            buf[x] = ((uint16_t)h << 8) | l;
        }
        myGLCD.drawPixelLine(0, y, SCREEN_WIDTH, buf);
    }
}

- For reference drawPixelLine method's implementation from UTFT library:

void UTFT::drawPixelLine(int x, int y, int sx, uint16_t* data)
{
    unsigned int col;
    cbi(P_CS, B_CS);
    setXY(x, y, x+sx-1, y);
    for (int tc=0; tc<sx; tc++)
    {
        char* p = (char*)&data[tc];
        LCD_Write_DATA(*(p + 1), *p);
    }
    sbi(P_CS, B_CS);
}
void UTFT::setXY(word x1, word y1, word x2, word y2)
{
    if (orient==LANDSCAPE)
    {
        swap(word, x1, y1);
        swap(word, x2, y2)
        y1=disp_y_size-y1;
        y2=disp_y_size-y2;
        swap(word, y1, y2)
    }
        LCD_Write_COM(0x2a);
        LCD_Write_DATA(x1>>8);
        LCD_Write_DATA(x1);
        LCD_Write_DATA(x2>>8);
        LCD_Write_DATA(x2);
        LCD_Write_COM(0x2b);
        LCD_Write_DATA(y1>>8);
        LCD_Write_DATA(y1);
        LCD_Write_DATA(y2>>8);
        LCD_Write_DATA(y2);
        LCD_Write_COM(0x2c);
}

My current rendering:

Desired image:

TFT Lcd and Mega Board

UPDATE1

I ran henningan test from utft library, drawing sin/cos graph and simple squares

Here is attempt to render yellow square 100x100 raw data


texts: SPI with a level converter in the other end of connection

texts:
I have an Arduino MEGA hooked up with a NRF24L01, and working nicely, talking with another Arduino Uno. It works as described, power supply to 3.3V, and SPI lines (MISO,MOSI,CLK) connected directly to the Arduino;

However, when I hook up a level converter in the end (5V to 3V, bidirectional) (making the NRF module in the middle, like in a T connection), the module stops working, and I don't know why. How does the level converter module is interfering in the connection? Is there any way I can prevent this and use it?

I intend in adding in the future, modules that talk in 3.3V SPI;

This is the level converter I'm using:

(source: at-the.space)

I suspect it is because of the pullups (5 think that these 10kΩ resistors are pull-ups, but I'm a noob in that part), but I really don't know if that is the problem, as the seller advertises it as being compatible with SPI, I2C, and UART. I have successfully used these for a UART.

I have checked Slaving multiple Arduinos via SPI and tried using an external 5V supply, and a 3.3V supply, but no dice.. However, the 3V side has no connections to it; But, being bi-directional, I don't think there is a problem with this...

I found that 74HCT245D works very well for this, but I'd like to know why with the level converter from JY-MCU this won't work.

Providing the library and connections just in case (the module works without the level converter):

Library & sketch comes from Optimized High Speed NRF24L01+ Driver Class Documenation.
Connection:

NRF2401 Pinout:
NRF24l01 http://ralphfox.at-the.space/imglink/nrf24l01.jpg
My connection:
Arduino with NRF24l01 and Level Converter  http://ralphfox.at-the.space/imglink/nrf_bb.png


texts: Can i use arduino code, without using arduino board but just using MCU included

texts:
I am developing a product, and to ease my job i am planning to use MCU inside the arduino with the library of Arduino.

Since all the registers are already defined inside the library, and all required things to registers of corresponding MCU are done to "make a pin input/output , enable interrupt , enable UART , enable I2C". I think that i can directly use the arduino coding enviroment even if i use MCU seperately.

Is it possible and how?  (can i use it in commertial product, i have already prototyped it with arduino)


texts: How to produce multiple DC voltages for a single project

texts:
So the title pretty much says it all, but for an example, I have an arduino board, 5-12 V, an LED bank 18 V, and an ultrasonic mister 24 V.

I know some brute force methods to power them from one outlet, but I was wondering if there is a more elegant way to get the voltage for each device with only one transformer instead of three. The solutions I've come up with are less than elegant, and only moderately compact.

I was just wondering what solutions you guys have employed and hoped I could find something helpful.


texts: Connecting LEDs and push buttons 12 feet away from Arduino UNO

texts:
I have a PCB (let's call it remote PCB) on which I have 4 LEDs and 4 buttons mounted. The remote PCB is far away from my desk (about 12 feet away). The LEDs are used to indicate the status and the buttons are for various state inputs.
All of them are connected to UNO directly.

I am planning to use a 10 pin IDC connector and IDC ribbon cable for the same.
THe LEDs' current is about 2 mA each (white LEDs)
The push buttons will make a ground connection when pressed, else the internal pull-up of the UNO will keep the GPIO at a high level.
I have put a capacitor of 10 nF across the switch to address denounce.
I have a series resistor of 1-kilo ohm for all four Switches on the remote PCB

I would like to know if this is okay? Will there be any problem due to the length. The LEDs are for indication and won't blink faster than 200 ms at any point in time. They will be used to indicate status which is very slow signals.
Thanks in Advance!


texts: I feel like an idiot, why can't I make a servo move with the boilerplate code?

texts:
So I was working on a far more grand project, until I discovered that I couldn't get any of my servos to move.

I've gone back to basics, and am trying to just get the boilerplate code found here, working.

#include <Servo.h>

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

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

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

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

Here are pictures of my setup.


texts: Does anyone know of a way to DIY a digital camera by buying a sensor and lens and processing the image using an Arduino?


texts:
I want to create a dynamic sized array of chars as a member in a class.
This is being done inside a library that I've created.
I have the .h and the .cpp files created. I'm not sure how to declare the array in the .h file. I've tried a few things so far:
char* content;
char content[];
But these don't seem to work.

Here's what I have in my .h file:

class bufr{
    public:
    //constructor and deconstructor
    bufr(char* _chars, uint8_t _len);
    ~bufr();

    //variables
    uint8_t len;
    char content[];

};

Here's what I have in my .cpp file (this is the constructor):

bufr::bufr(char* _chars, uint8_t _len){
    char* content = new char[_len];
    content = _chars;
    len = _len;
}

I've also tried replacing the line content = _chars with:

for (int i = 0; i < _len; i++){
    content[i] = _chars[i];
}

But this also doesn't work.  When I print the content member to the serial port from within the constructor, or in the main loop it prints nonsense characters, not what I passed it.

Here's my main loop:

void loop(){
    char chars[] = "1234";
    bufr buf(chars, 4);
}

Have I explained myself well enough?  Can anyone give me a hand?
Much appreciated!

Oh, and yes, I know - in my deconstructor that's not shown, I have delete [] content

I plan on using this class nested inside another class in a few spots and hoping to take advantage of the dynamic mem allocation.  I know I can simply declare an array of fixed length, but I wanted to learn the proper way to use new and delete.

Thanks!


texts:
In my recent project, I'm working with Arduino and JSON. Now, I get data from JSON and I can able to receive in Arduino side.

Below one is my Arduino code:

#include<LiquidCrystal.h>

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

String response = "";
bool begin = false;

void setup()
{
  Serial.begin(9600);
  lcd.begin(16, 2);
}

void loop()
{

  while(Serial.available() || !begin)
  {
    char in = Serial.read();

    if (in == '{')
    {
      begin = true;
    }

    if(begin) response += (in);

    if(in == '}')
    {
        break;
    }
    delay(1);
  }

  lcd.setCursor(0, 0);
  lcd.print(response);
}

Output :

{"TPS":"0.40","MAP":"1.05","LOAD":"14"}

Now, I want to split data means store 0.40 in one variable, 1.05 in another variable and 14 in another variable. I don't know how to split this.


texts: Problem in using COZIR W-100 with arduino

texts:
I was using the COZIR W-100 carbon dioxide sensor with an Arduino Mega 2560 with the example code from this site.

But the measured value of carbon dioxide by sensor was 90 ppm in fresh air and that is not correct. Please help me find the cause and a solution.


texts:
I'm doing a project in which I need to work on ATmega2560 standalone IC. So I created the circuit shown in the image on Eagle.

Let me explain each part:

First I'm going to power the IC by providing 5 V and GND to the IC's VCC and GND pin (all VCC and GND pins of ATmega2560 are shorted to 5V and GND respectively);
Then I will program this IC using ICSP and for the back up I kept Rx and Tx pins too;
Then I connected 10 KΩ pull up resistor for reset as it is logic low pin;
I build small indicator circuit for my PCB which is normal power indicator and LED indicator digital pin number 13 of IC;
For a clock signal, I have used crystal oscillator (I didn't use a resonator as I thought that a crystal oscillator would be more stable than resonator);
Lastly, I have used bypass capacitors between VCC and GND (I don't know what is the use of these capacitors but I connected these because I saw them in every other standalone circuit).

So is this circuit correct? If there are any mistakes [in my logic or elsewhere], or any advice you want to give, then let me know in comments/answers.

Link to the circuit diagram.


texts:
I am new to Arduino, and I am working through the "Arduino Projects book," with the Arduino Uno. I am working on project 5, "the mood cue." It is basically a potentiometer-controlled servo. I am certain that I have the code for it correct, and certain that I have all the wiring correct. I have the potentiometer value and the angle at which the potentiometer is turned printed on the serial monitor.

I upload the code, and the serial monitor begins printing correctly, changing when I twist the potentiometer. But the servo doesn't move. It lets off a faint buzzing sound, and that is it.

Does anyone know what the problem is? I don't know what I have done wrong. Do you think my servo is broken?

Here is my code:

#include <Servo.h>
Servo myServo;
int const potPin = A0;
int potVal;
int angle;

void setup() {
  myServo. attach(9);
  Serial.begin (9600);
}

void loop() {
  potVal = analogRead(potPin);
  Serial.print ("potVal:");
  Serial.print (potVal);
  angle = map(potVal, 0, 1023, 0, 179);
  Serial.print ("angle:");
  Serial.print (angle);
  myServo.write (angle);
  delay(15);
}

Here is my wiring:
file:///C:/Users/matth_000/Downloads/Arduino%20PotServ.jpg


texts: Adafruit Metro Mini FTDI chip overheating

texts:
I have an Adafruit Metro Mini board that I am using. After soldering the board and accessories to a perfboard the FTDI chip is overheating, the COM port will not show up on the PC, and the 3V pin does not produce any power while the board is plugged in.

Is there a way to fix this? Have I nuked my board?


texts:
simulate this circuit – Schematic created using CircuitLab

Its a simple project. I am trying to drive 3 RGB LEDs using Arduino Nano. Since Arduino Nano does not have 9 PWM pins, the only solution I can think of by multiplexing them. I have try multiplexing 12 7-segments driven by atmega16, the results was satisfying. Is it possible to do PWM multiplexing on Arduino Nano?
So far, here is what I have done:

const int R=9, G=10, B=11, M1=5, M2=6, M3=7;

//I use pin 5,6,7 as selector since they are on same PORT (PORTD)

void setup()
{
    pinMode (R,OUTPUT);
    pinMode (G,OUTPUT);
    pinMode (B,OUTPUT);

    pinMode (M1,OUTPUT);
    pinMode (M2,OUTPUT);
    pinMode (M3,OUTPUT);
}

void led(int r, int g, int b)
{
    analogWrite(R,255-r);
    analogWrite(G,255-g);
    analogWrite(B,255-b);
}

void loop()
{
    for(int i=0; i<256; i++)
    {
        led(0,0,i);
        __asm__("nop\n\t");     //one clock cycle delay
        PORTD = B10000000;      //select LED-1

        led(0,i,0);
        __asm__("nop\n\t");     //one clock cycle delay
        PORTD = B01000000;      //select LED-2

        led(i,0,0);
        __asm__("nop\n\t");     //one clock cycle delay
        PORTD = B00100000;      //select LED-3
    }

    for(int i=256; i>0; i--)
    {
        led(0,0,i);
        __asm__("nop\n\t");     //one clock cycle delay
        PORTD = B10000000;      //select LED-1

        led(0,i,0);
        __asm__("nop\n\t");     //one clock cycle delay
        PORTD = B01000000;      //select LED-2

        led(i,0,0);
        __asm__("nop\n\t");     //one clock cycle delay
        PORTD = B00100000;      //select LED-3
    }

}

But still, this does not work. The result is all the led turned on, with 'a little bit' different color, mainly white with a little addition of another color (while it supposed to be contrast, R, G and B for each LED), and its blinking. The blink is very short, but still, its annoying. One possibility I can think of my code still not optimum.
Someone had an idea?

EDIT
I fixed the diagram, I hope the diagram does not make any misunderstandings. As the suggestion from @jwpat7, I forget to inform that the led still error even if there is just one for-loop.
I am using __asm__("nop\n\t") as delay substitution because "theoretically", 1 clock cycle from 16mHz clock is shorter than 1 microseconds. (correct me if I am wrong, but I think its about 62.5 ns)

Thanks in advance


texts: 915Mhz vs Wifi (speed impact of duty cycle limitations)

texts:
I am currently using an esp32 with Wifi. I need at least 15kByte/s constant throughout. This works fine but I am not happy with the range.
I came across the RFM69HCW 915MHz module. It is stated with 300 kbps.
Now what is confusing me are duty cycle regulations. Various countries have a 1% limit.
Is this limit considered in the 300 kbps? Or do I effectively only get 3 kbps because I cannot constantly send?


texts: How to calibrate and use MQ-7 gas sensor?

texts:
Could anyone help me calibrate and use the MQ-7 sensor?

I've read guides, but some say I need RO, offset or heating cycles for calibration.


texts:
according to the tone() documentation using tone() interferes with PWM output:

  Use of the tone() function will interfere with PWM output on pins 3 and 11 (on boards other than the Mega).

On my Arduino Micro it seems to interfere with PWM on pin 5. After using tone() the PWM does not seem to work anymore. If I use pin 3,9 instead everything works fine.

So can someone explain why that is happening and if there is a way to circumvent that?


texts: How do I write an Arduino sketch and an Android application to talk to each other over a standard USB cable?


texts: Can I use this cheap GPS module with arduino

texts:
For my project I need a GPS module, it should be cheap and I should be able to use it with arduino, after some search I got a product on ebay, I'm a 16 year old school boy and I didn't know that it will work with Arduino or not. Help me.

Here is the link--
http://www.ebay.co.uk/itm/DIYMALL-VK16E-Module-Gmouse-GPS-Module-SIRF3-Chip-with-Ceramic-Antenna-TTL-Level-/181594912168?hash=item2a47e675a8


texts:
I am having some major issues with my Arduino Yun.

When attempting to read a value from the analog pins, the Yun is giving me incorrect constant values.

I have attached everything to a common ground, and I am supplying 3.3 volts to the A0 pin on the Yun.

The weird thing is, the pins all give constant values in ascending order, no matter what is connected to them, or if nothing is connected at all.

A0 - 18
A1 - 19
A2 - 20
A3 - 21
A4 - 22
A5 - 23

The code I am running is a very simple script.

float i;

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

void loop() {
  i = A0;
  Serial.println(i);
  delay(1000);
}


texts:
I am going to update the firmware of an ESP8266 module, but first I would like to know the current version or name.

How can I get it? Maybe with an AT command?

This is my ESP8266 module:


texts: Serial communication between nodemcu and Arduino Uno

texts:
For the last days, I am trying to establish serial communication between nodemcu and Arduino Uno but I failed to do this. Currently, I am working on a Home Automation project. I receive data from nodemcu and send it to Arduino Uno, but some dummy data also receive with original data. Please help.
Nodemcu code:
#include <ESP8266WiFi.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"

#define Automated   D0
#define Led         D1
#define Fan         D2

#define WLAN_SSID       "JioFi2_1EAFF8"
#define WLAN_PASS       "Ode9c@,1S%31ja$1xANkeL"

#define AIO_SERVER      "io.adafruit.com"
#define AIO_SERVERPORT  1883
#define AIO_USERNAME    "_inishu"
#define AIO_KEY        "aio_HZUG00TupkcsC2dvraQM7HLHrCd4"

WiFiClient client;
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);

Adafruit_MQTT_Subscribe speed = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME"/feeds/Fan");
Adafruit_MQTT_Subscribe inten = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME "/feeds/Led");
Adafruit_MQTT_Subscribe autom = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME "/feeds/Automate");

void MQTT_connect();
void datatransfer(int);

int on_off;
int sliderval1;
int sliderval2;
void setup(){
    Serial.begin(9600);
    pinMode(Automated, OUTPUT);
    pinMode(Led, OUTPUT);
    pinMode(Fan, OUTPUT);

    WiFi.begin(WLAN_SSID, WLAN_PASS);
    while (WiFi.status() != WL_CONNECTED) {
        delay(500);
    }

    mqtt.subscribe(&autom);
    mqtt.subscribe(&speed);
    mqtt.subscribe(&inten);
}

void loop (){
    MQTT_connect();

    Adafruit_MQTT_Subscribe *subscription;
    while ((subscription = mqtt.readSubscription(5000))){
        if (subscription == &autom){
            on_off = atoi((char *)autom.lastread);
            if (on_off == 1)   digitalWrite(Automated,HIGH);
            if (on_off == 0)   digitalWrite(Automated,LOW);
        }

        if (subscription == &speed){
            sliderval1 = atoi((char *)speed.lastread);
            analogWrite(Fan, sliderval1);
        }

        if (subscription == &inten){
            sliderval2 = atoi((char *)inten.lastread);
            analogWrite(Led, sliderval2);
        }
    }
    datatransfer(on_off);
    datatransfer(sliderval1);
    datatransfer(sliderval2);
}

void MQTT_connect() {
    if (mqtt.connected()) {
         return;
    }

    while (mqtt.connect() != 0) {
        mqtt.disconnect();
        delay(2000);
    }
}

void datatransfer(int value){
    Serial.println(value);
    delay(500);
}

Arduino Uno code:
int x = A0, y = A1, z = 1;
int fan = 11, led = 10;
float temp, lux;
int autom = 1;
int inten = 0;
int speed = 0;
int fanspeed, light;

int datareceive(){
    int receiver = 0;
    while(Serial.available()==0 );
    String s = Serial.readStringUntil('\r');
    receiver = s.toInt();
    Serial.println(receiver);
    delay(1000);
    return receiver;
}

void setup(){
    Serial.begin(9600);
    pinMode(fan,OUTPUT);
    pinMode(led,OUTPUT);
    pinMode(x,INPUT);
    pinMode(y,INPUT);
    pinMode(z,INPUT);
}

void loop(){
    autom = datareceive();
    speed = datareceive();
    inten = datareceive();
    if(autom == 1){
        fanspeed = 255 - speed;
        light = 255 - inten;
        analogWrite(fan,fanspeed);
        analogWrite(led,light);
    }
    else {
        temp = analogRead(x);
        if (temp >= 52 && temp <= 104){
            int fanspeed = -4.90384615*temp + 510;
            analogWrite(fan, fanspeed);
        }
        else if(temp > 104)  digitalWrite(fan,LOW);
        else digitalWrite(fan,HIGH);
        lux = analogRead(y);
        if (lux >= 430 && lux <= 594){
            int light = 1.342657*lux-577.342657;
            analogWrite(led,light);
        }
        else if (lux < 430) digitalWrite(led, LOW);
        else digitalWrite(led,HIGH);
    }
}


texts: Using delay(1000); without influence on analogWrite?

texts:
So, I'm trying to read the voltage on analog pin A0 and make a "regulation", where if the voltage will be lower than 2.5V (analog value 512), then it should be output pin 9 used as PWM with duty cycle of 50% ( analogWrite(ledPin, 128); ) unless the voltage rises again higher than 2.5V.

Where/how am I supposed to use mentioned line ( analogWrite(ledPin, 128); in IF sentence, so it will be used continuous untill it is reached the limit?

PS: I just want to refresh LCD with frequency of 1 Hz while PWM works independently of delay(1000). How is that even possible?

How am I able to do that?

#include <LiquidCrystal.h>

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

const int numRows = 2;
const int numCols = 16;

void setup() {
  lcd.begin(numCols, numRows);
}

void loop() {

    int sensorValue = analogRead(A0);
    float voltage = sensorValue * (5.0 / 1023.0);
        lcd.setCursor(0, 0);
        lcd.write(voltage);

        delay(1000);
}


texts: ESP8266 UDP multicast doesn't receive packets

texts:
I am currently working on an ESP8266 with the Arduino IDE. I try to implement an ESP8266 in STA mode as multicast receiver. I was writing my code with the help of this documentation. Especially the following part:

  The WiFiUDP class supports sending and receiving multicast packets on STA interface. When sending a multicast packet, replace udp.beginPacket(addr, port) with udp.beginPacketMulticast(addr, port, WiFi.localIP()). When listening to multicast packets, replace udp.begin(port) with udp.beginMulticast(WiFi.localIP(), multicast_ip_addr, port). You can use udp.destinationIP() to tell whether the packet received was sent to the multicast or unicast address.

Sending to the multicast group with udp.beginPacketMulticast(addr, port, WiFi.localIP()) and udp.write(message, messageLength)works flawlessly.

The receiving part of my code is as follows:

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

#define BUFFER_LENGTH 256

const char* ssid = "xxxxxx";
const char* password = "xxxxxx";

WiFiUDP Udp;
IPAddress multicastAddress(226,1,1,1);
unsigned int multicastPort = 4096;

char incomingPacket[BUFFER_LENGTH];

void setup(){
    WiFi.mode(WIFI_STA); //station
    WiFi.setOutputPower(0);
    while (WiFi.status() != WL_CONNECTED)
    {
        WiFi.begin(ssid, password);
        delay(500);
    }
    Udp.beginMulticast(WiFi.localIP(), multicastAddress, multicastPort);
}

void loop(){
    int packetLength = Udp.parsePacket();
    if(packetLength){
        int len = Udp.read(incomingPacket, BUFFER_LENGTH);
        if (len > 0){
            incomingPacket[len] = 0;
            Serial.printf("%s\n", incomingPacket);
        }
    }
}

When sending a packet with a simple multicast sender (with matching IP and port), my multicast receiver on my linux laptop receives the packet, but the ESP8266 doesn't.

Maybe some of you have experienced a similar behavior and are able to give me some hints, where I might be wrong.

EDIT:
Since the time I asked this question I completely ruled out an error of the sender on the linux machine by using a verified, 100% working sender. The ESP8266 still doesn't receive any multicast datagramms.


texts: Multiple MuxShield 2's connected to a single Arduino Mega

texts:
I am working on a project and need alot of toggle buttons to control various things around the house. I connected 5 MuxShield 2's to my Arduino Mega. The first two will serve as inputs and the last two will serve as outputs.
The problem is when I try to loop over all the outputs (connected to LED's for now) to turn them on/off, only the first 3 rows work as expected. The LED's turn on one by one, but when the loop reaches a row number which it has already looped over on another multiplexer the LED's turn on all at once.

I think it has something to do with the arrays in the MuxShield library being shared across all multiplexers and therefor breaking all signals the second time it gets used but I'm not sure.
It's not that much code but, too much to post here so I uploaded it to GitHub.

If someone could please look over it and point me in the right direction, I'd greatly appreciate it. Thanks.