texts: PCINT0, PCINT1, PCINT2, etc. on ATtiny45/85

texts:
According to the datasheet:

we could think that, if we want to have a pin change interrupt for 3 pins, we have to create multiple instances:

ISR(PCINT0_vect){
   ...
}

ISR(PCINT1_vect){
   ...
}

ISR(PCINT2_vect){
   ...
}

void setup(){
  GIMSK = 0b00100000;
  PCMSK = 0b00000111;
}

However, this does not work, and I read here and here that we have to define just one interrupt function:

ISR(PCINT0_vect){
   if (digitalRead(0) == LOW)
     ...
   if (digitalRead(1) == LOW)
     ...
   if (digitalRead(2) == LOW)
     ...
}

Why is that so? What is PCINT1, 2, 3, ... made for then in this pinout schematics, if we don't have to use it?


texts: Measure movement distance - not sure what sensor?

texts:
I want to measure the length of a step / stride -not sure what sensor to use.

I am trying to get several people to march a pattern for a band.  I am thinking a Arduino to beep when step is too short or too small.  Thinking the Arduino will be tied to their shoe laces.  IR or Ultrasonic do not seem to be the correct sensor to use.

Ideas?


texts: nRF24L01 using sender as receiver and vice versa with RF24 library

texts:
I have two nRF24L01 modules (I tried 2 with antenna and 2 without antenna) paired with their power base module and connected to two different Arduino Mega 2560 boards.
I'm able to send from one module to another up to 32 byte of data and get the acknowledge without any problems. But when I switch them, when I try to send data from receiver and receive it on the sender I have nothing. No data received, no acknowledge sent as response.

As I said before, first part of this code works well, but when it comes to the second part, which is after delay(1000); there's silence...

my code is:

Receiver

#include <RF24.h>
#include <RF24_config.h>
#include <SPI.h>
#include "printf.h"

// Set pipes
const uint64_t pipe01_ = 0xE8E8F0F0A1LL;
const uint64_t pipe02_ = 0xE8E8F0F0A2LL;
const uint64_t pipe03_ = 0xA3LL;
const uint64_t pipe04_ = 0xA4LL;
const uint64_t pipe05_ = 0xA5LL;
const uint64_t pipe06_ = 0xA6LL;

RF24 radio(9, 53);

void setup()
{
    Serial.begin(115200);
    delay(250);
    radio.begin();
    radio.setChannel(0x57);
    radio.setPALevel(RF24_PA_LOW);
    radio.enableAckPayload();
    radio.openReadingPipe(1, pipe01_);
    radio.openWritingPipe(pipe02_);
    radio.enableDynamicPayloads();
    radio.startListening();
}

void loop()
{
    if (radio.available())
    {
        char newMessage[33];
        memset(newMessage, 0, sizeof(byte) * 33);
        while (radio.available())
        {radio.read(newMessage, 32);}

        Serial.println("newMessage: " + String((const char*)newMessage));
        delay(1000);
        radio.stopListening();

        char response[32] = "1234567890qwertyuiopasdfghjklzxc";
        radio.write(response, 32);
        unsigned long ack = 0;
        if (radio.isAckPayloadAvailable())
        {
            radio.read(&ack, sizeof(ack));
            Serial.println("ack: " + String(ack));
        }
        radio.startListening();
    }
}

Sender

#include <RF24.h>
#include <RF24_config.h>
#include <SPI.h>
#include "printf.h"
// Set pipes
const uint64_t pipe01_ = 0xE8E8F0F0A1LL;
const uint64_t pipe02_ = 0xA2LL;
const uint64_t pipe03_ = 0xA3LL;
const uint64_t pipe04_ = 0xA4LL;
const uint64_t pipe05_ = 0xA5LL;
const uint64_t pipe06_ = 0xA6LL;

RF24 radio(9, 53);

void setup()
{
    Serial.begin(115200);
    delay(250);
    radio.begin();
    radio.setChannel(0x57);
    radio.setPALevel(RF24_PA_LOW);
    radio.enableAckPayload();
    radio.openReadingPipe(2, pipe02_);
    radio.openWritingPipe(pipe01_);
    radio.enableDynamicPayloads();
    radio.stopListening();

    char message[32] = "qwertyuiopasdfghjklzxc1234567890";
    radio.write(message, 32);

    radio.startListening();
}

void loop()
{
    if (radio.available())
    {
        char respMessage[33];
        memset(respMessage, 0, sizeof(byte) * 33);
        while (radio.available())
        {radio.read(respMessage, 32);}

        Serial.println("respMessage: " + String((const char*)respMessage));
    }
}

Please help me.


texts:
Apparently these nRF24L01+ modules need 3.3v, but I've only got 5v Trinket Pros that I'm using.

How can I reduce the voltage to the RF transmitter?

Would a voltage regulator work? Specifically looking at this: http://addicore.com/product-p/165.htm


texts: Industrializing Arduino - 24V io? (Electronics)

texts:
I would like to make an arduino board that is capable of handling 24V i/o.

Powering the Arduino would be done through either a linear or switching regulator of some sort. Low amperages, so efficiency isn't the main problem.

For input:
24v to 5v input scaling could be created with a voltage divider.

As far as I know, there will never run a high current into the arduino? So the power loss is minimal?

For output:
5v to 24v can be easily achieved using a MOSFET? Since this will ramp up the possible load (higher amperages) given that I'm using a 24v supply/separate line.

So I could choose to make half the I/O only input and half only output.

Could I combine the MOSFET and voltage divider, and in what way?
Are my "assumptions" about the I/O correct, or are there beter ways of handling it?
What other things should I think of? Over voltage protection? Polarity inversion? Protection against too high currents?


texts: Arduino Due, program not there after power off

texts:
When i program my arduino Due after a RESET, my program is still there.
However, when i power off my Due and then turn it back on, no program is there!

There is no persistence in the program and i have to program it all again!
I am programming it throught the Programming port.

EDIT: If it doesn't boot properly with my code and then i press the RESET button, then my code is loaded and it works like i programmed it. But how can i make it so that it works straight away, after it's fed with power?


texts: NEMA17 and DRV8825 200 steps give only half revolution

texts:
I have this code:

#include <stdint.h>

# define STEP 14

void setup()
{
    pinMode(STEP, OUTPUT);
}

long steps = 0;
void loop()
{
    if (steps < 200)
    {
        digitalWrite(STEP, digitalRead(STEP) ^ 1);
        delay(10);
        steps++;
    }
}

Simple implementation and I have a nema17 motor with 1.8 degrees per step, which should give 200 steps per revolution, but I only have half a revolution on 200 steps, I tried connecting all MODEx pins to VCC and this should give me 6400 steps per revolution but 6400 steps also gives mi half an revolution.
Could there be an issue with the wiring of the motor? Why don't I receive a full revolution?
By full revolution I mean that the motor shaft should complete the whole circle but it completes only half.


texts:
I've written a program which allows me to use my Arduino Uno to send a PWM to an Electronic Speed Controller. 5 seconds after startup the ESC is sent a config via PWM to signal the low to high PWM range to be used by the ESC. Then I can type into the Serial Monitor a single digit 0-9 to pick the PWM I want to send to my ESC. (n*2 = pwm)
This works great when running code for one ESC, but adding code for a second ESC causes significant issues (I only have one ESC plugged in). When I send a serial command to specify PWM rate, my ESC only receives the PWM change sometimes. About 2/3 times it ignores the PWM change and keeps spinning at the same rate it was already at.
What's going on here?
Code
WorkingESCSoftware (main file of .eno)
#include <SoftwareServo.h>
#include "TestClass.h"

int val;    // variable to read the value from the analog pin
int stage = 0;

TestClass t, t2;

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

  t = TestClass();
  t.setPin(3);
  t2 = TestClass();
  t2.setPin(5);
}

void loop()
{
  t.loop();
  t2.loop();
}

TestClass.h
class TestClass {
  private:
    SoftwareServo servo;
    bool _initialized = false;

    int PWM_MAX = 180;
    int PWM_HIGH = 170;
    int PWM_MEDIUM = 80;
    int PWM_LOW = 40;
    int PWM_OFF = 25; // has to be between esc config off (stop) and low (slow spin)
  public:
    TestClass();
    void setPin(int);
    void loop();
};

TestClass::TestClass() {
  Serial.println("cycle lipo power to esc");
}

void TestClass::setPin(int pin) {
  this->servo.attach(pin);
}

void TestClass::loop() {
  //  Serial.println("loop");

  // 5 seconds after power, send PWM range to ESC
  if(millis() > 5000 && this->_initialized == false) {
    this->_initialized = true;

    Serial.println("esc setup");
    this->servo.write(PWM_MAX);
    delay(5);
    this->servo.write(PWM_OFF);
    delay(5);
    Serial.println("esc ready");
  }

  char r = Serial.read();
  String inStr = String(r);
  if(r > -1) {
    Serial.print("serial in: ");
    Serial.println(inStr);
  }

  use h, m, l, o, or 0-9 to control PWM of ESC
  if(r <= -1) {
    // void
  } else if(inStr == "h") { // high
    Serial.print("HIGH: ");
    Serial.println(PWM_HIGH);
    this->servo.write(PWM_HIGH); // highest spinning (same as 160?)
  } else if(inStr == "m") { // medium
    Serial.print("MED: ");
    Serial.println(PWM_MEDIUM);
    this->servo.write(PWM_MEDIUM);
  } else if (inStr == "l") { // low
    Serial.print("LOW: ");
    Serial.println(PWM_LOW);
    this->servo.write(PWM_LOW);
  } else if (inStr == "o") {
    Serial.println("OFF");
    this->servo.write(PWM_OFF);
  } else if (inStr.toInt() >= 0 && inStr.toInt() <= 9) {
    int val = inStr.toInt() * 20;
    Serial.println(val);
    this->servo.write(val);
  }

//  SoftwareServo::refresh();
  this->servo.refresh();
}


texts: How to power on Arduino a few seconds later after GSM module initialization?

texts: I've connected a SIM900A GSM module to Arduino and the circuit works standalone on a 12V power supply. The problem is when I provide the 12V power supply, both GSM module and Arduino starts but the Arduino don't initializes the program for GSM module and hence the send or receive message functions don't work. Also when I first power on the GSM module and let it initialize first and then power on the Arduino, everything works fine. How to deal with this problem?


texts: Measuring Battery level with ADC already in use

texts:
I have NodeMCU v3 with ESP8266 and I am running small project where I am measuring the input from IR phototransistor via ADC pin (A0) and everything is working flawlessly.
But now I want to transfer it to battery source (powerbank -> microUSB) and I want to be able to tell the remaining battery capacity, but all tutorials I found were going through switching ADC(A0) to internal, thus disabling it.
Is there any other way I can either measure the battery OR input from phototransistor?
Thanks!


texts: What is the fastest and easiest way to transmit arduino's sensor data to a PC wirelessly

texts:
I have a specific problem :

I'm working on a testing platform. It has to be absolutely isolated, so I cannot wire it back to my PC. I again reiterate it. There is no way to wire it to my PC. IT HAS TO BE ABSOLUTELY ISOLATED
It has about 10 different sensors on it and I need to read sensor's data simultaneously at 100Hz.  It is currently working fine with 16Hz, but I need to improve it further, so I think maybe in future sampling rates higher than 100 is beneficial. 7 Hz is the lowest possible value that doesn't botch the whole things up.
I have a laptop on the platform which reads the sensor data via RS232, then it processes them in a fraction of a second and produce a control signal and send it to the actuators. It has to happen at real-time. Control algorithm is not heavy, it is several PIDs.
It has 6 actuators with the fastest possible reaction time of 0.005 second.
The main sensor currently is Microstrain 3DM-GX1. It is a very good sensors.
I want to add a GY-80 sensor in parallel to 3DM-GX1. I want to test various filtering algorithms on the GY-80's output and compare them to 3DM-GX1.
Platform has 6 degrees of freedom so I think laser transmission is not practical.
Distance between the computer and the platform is at most 3 meters.

For some reasons I am not able to use the laptop anymore. I want to read the sensor's data with an Arduino, preferably Arduino Mega 2560. My problem is that I don't want to load the control algorithm to the Arduino.

IMHO the perfect solution is going to be a Wireless link between the Sensors via Arduino to my PC. This way my PC logs data and also the Control Algorithm can promptly calculate the feedback signal and send it to Arduino which will send them to the actuators. This immensely makes things easier for me.

I think I need a RS232 shield for the 3DM-GX1 & Arduino, + some wireless solution for sending data from both sensors to my computer. Then I need to send back the control signal back to the actuators wirelessly.

Now what is the fast and easy way to transmit the data between PC and Arduino in real-time?

Thank you in advance!


texts:
Is my GPS module broken?

My GPS returns $GPGGA,000250.262,,,,,210,,2,700,,*4C as NMEA. Why there is no latitude longitude? the first value is the UTC time, but there are so many null values ,,,,, Is my GPS module broken?

Edited

My Sim808 model is SIM808 Module GPRS SMS Development Board IPX SMA with GSM GPS Antenna

What makes me think why is this broken is because the day before, the module keep giving me location for every second. The lock was almost instant. I use the module at the same place like before. It is weird because the module is so unstable, yesterday was fine but the next day it takes forever to lock location.


texts: Convert fuel level sender resistance ranges - good Arduino project?

texts:
I've noodled around with Arduino a bit, worked some tutorials.  I have an engineering & programming background, but electronics isn't my first language.  So apologies if this is a dumb question.
Here's the problem.  I've swapped a 2007 GM engine into an older Toyota Land Cruiser.  I need to make it compliant with the emissions equipment that was originally on the 2007 vehicle.  Most of that is pretty straight forward - catalytic converters, O2 sensors, charcoal canister, purge & vent solenoid valves, a pressure sensor.  The one bit I haven't figured out yet is fuel level.  The evaporative emissions system requires a fuel level input to the PCM (Powertrain Control Module) so it can figure out when & how to run the fuel system pressure test - the one that turns on your check engine light if your gas cap isn't on tight enough.
One solution would be to put in a GM fuel level sender ... but that involves draining the tank, dropping it, maybe cutting new holes, more wiring, etc.  I'm hoping I can fix this in software :)
The GM fuel level sending unit reads 0 ohms empty and 90 ohms full.  The existing Toyota sending unit should be 110 ohm empty and 3 ohm full.
So ... is it a feasible thing to build an Arduino based project that reads the resistance from the Toyota sender (without interfering with the Toyota gauge) and translates that to the range expected by the GM PCM?
I'm thinking something like this is the core of it: https://www.arduino.cc/en/Tutorial/LibraryExamples/DigitalPotControl  But I don't know what I don't know.
Thanks folks - additional information based on responses:
The Toyota sender is definitely a 12V two terminal unit.  Car electrical systems are nominally 12V, but typically are about 13.3V in operation.
The GM sensor is two terminal also.  According to the wiring diagram, one terminal goes to a low reference pin on the PCM and the other goes to a pin on the PCM labeled fuel level signal.
But it doesn't tell you the voltage they're applying on that pin - could be just 5V, other stuff coming out of the PCM is.  I couldn't find a test procedure either.  I'll pin that connector and see what I can measure next time I'm out there.
The fuel level signal is used for two things in the evaporative emissions (evap) system.

The evap vacuum test can only run when the tank is between approximately 1/3 to 2/3 full.
The vacuum test is calibrated against how full the tank is - lower fuel level means more air space in the tank means the pressure will change more slowly then compared to a fuller tank.


texts: Memory usage in AnalogBinLogger of SdFat library

texts:
The AnalogBinLogger.ino file of SdFat library says the following:

  Each 512 byte data block in the file has a four byte header followed by up to 508 bytes of data. (508 values in 8-bit mode or 254 values in 10-bit mode).
   Each block contains an integral number of samples with unused space at the end of the block.

I was wondering why only 254 values can be stored in 10-bit mode instead of (508*8 bits/ 10 bits ~ 406 values ).

Is this because of the memory being byte-addressable and hence does a 10-bit value take up 2 bytes?
If so, how will a file-reader differentiate between a 10-bit value taking 2 bytes and two 8-bit values?
The AnalogBinLogger.ino says:

  The logger will use SdFat's buffer plus BUFFER_BLOCK_COUNT additional buffers.

BUFFER_BLOCK_COUNT is 1 for the Arduino Uno since it has 2KB of SRAM. Each buffer is 512-byte long. Is SdFat's internal buffer also in SRAM? If I am not wrong, the libraries the program uses and the program code reside in the Flash memory, can SdFat write into a buffer in Flash memory?


texts: arduino creates strange files in SD card

texts:
I'm new to Arduino and electronics. I want to make a project including SD data-logger, but I had a problem. I would appreciate if someone show me where I made a mistake.

Firstly, circuit  was set up as in picture:

I am using 8 Gb micro SDHC card with SD adapter. I formatted in FAT32. I can play audio files which are in appropriate format and read and the print contents of text files.

But when I want to create a new file, strange file is obtained in SD card as in pic:

So I reformat SD card. the code that is used while creating file is as this;

// open a new file and immediately close it:
Serial.println("Creating example.txt...");
myFile = SD.open("example.txt", FILE_WRITE);
myFile.close();

Somewhere I read SDHC card with more than 2 Gb capacity  is not supported in Arduino and I bought 2 Gb SD micro with SD adaptor.

But in this case aurduino does not detect SD card. please someone help me.


texts:
When I try to upload my code onto the Arduino it just gives me the error message: "avrdude: ser_open(): can't open device "/dev/cu.usbmodem14201": No such file or directory
Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions."

My Arduino used to function just fine. Now when a plug it in, the lights on the Arduino do not blink like they used to, and the only pins that do anything are the ones to power. It also said something like: Arduino is not optimized for mac os. It seems that the Arduino is taking in the power but not the code. here's the code:

int led = 13; // the pin the LED is connected to
void setup() {
  pinMode(led, OUTPUT); // Declare the LED as an output
}

void loop() {
  digitalWrite(led, HIGH); // Turn the LED on
}


texts: Serial communication and Arduino program in C

texts:
When I flash this simple code (using Arduino-Makefile):

#include <avr/io.h>
#include <util/delay.h>
#include <Arduino.h>

void init_io(void) {

    // open serial port
    Serial.begin(9600);
    while (!Serial);
    Serial.println("Comm-link online");

}//END: init_io

int main(void) {

    init_io();

    while (1) {

        // send data only when you receive data:
        if (Serial.available() > 0) {

            // read the incoming byte:
            int incomingByte = Serial.read();

            // say what you got:
            Serial.print("I received: ");
            Serial.println(incomingByte, DEC);

        } else {

            //  Serial.println("No serial ");

        }

    }//END: loop

    return 0;
}//END: main

I only see first two chars printed in the serial output:

  ~$> Co

The input also does not work as intended - tested on two independent microcontrolers, Mega and Uno. I'm not sure what's the cause of this behaviour. Here's the Makefile:

BOARD_TAG    = uno # megaADK uno
MONITOR_PORT  = /dev/ttyACM0
ARDUINO_LIBS =

include $(ARDMK_DIR)/Arduino.mk

It's definitely not a hardware problem, I've used serial i/o before in other projects.


texts: Issues with connecting to an Adafruit FLORA board

texts:
I just bought a new Adafruit Flora board, and I haven't been able to get it working successfully. When I plug it into a USB port, the board seems to be getting power (the green PWR LED is illuminated), but there is no other output from the board. The Arduino IDE also does not recognize the board (the "port" menu under "Tools" is grayed out), and I have tried to connect to it on both Windows and Linux (Ubuntu) systems with the appropriate drivers/packages installed (including the Windows drivers and the board manager add-on in both installations of the Arduino IDE). I've also verified that the USB cable I'm using can handle data.

Previously, I was able to at least get the board to be recognized in the IDE on my Linux machine, and the red LED did light up, but after disconnecting it doesn't light up anymore (unless I try to reset the board, which makes the red LED pulse a few times).

Anything that I can try to get it recognized in the IDE?

Edit: I'm able to see the board pop up under "ports" in the IDE immediately after I hit the reset button on the board. However, as soon as the red LED stops pulsing (I think this means that the board is finished rebooting), it disappears from the list of available ports. It's also mounting under /dev/ttyACM0, not the usual /dev/ttyUSB0.


texts:
The following code does what I need it to do (when a start switch is on and door switch is off - a warning light flashes. When the start switch and door switch are both on - a valve opens to allow water in for 2 seconds). I need the light to flash until the door is HIGH too at which point the valve program runs once.  The only way I have to get out of this is to use exit(0). Is there a better way to do this? Ideally, I would like to stay away from anything too Boolean! Thank you.

int start = 2;
int door = 3;
int light = 8;
int valve = 9;
int counter = 0;

void setup() {
  pinMode(start,INPUT);
  pinMode(door,INPUT);
  pinMode(light,OUTPUT);
  pinMode(valve,OUTPUT);
}

void loop() {
  if(digitalRead(start)==HIGH && digitalRead(door)==HIGH) {
    digitalWrite(valve, HIGH);
    delay(2000);
    digitalWrite(valve,LOW);
    exit(0);
    //breaks out of loop. Arduino then needs reset.
  }

  if (digitalRead(start)==HIGH && digitalRead(door)==LOW) {
    digitalWrite(light,HIGH);
    delay(500);
    digitalWrite(light,LOW);
    delay(500);
  }
}


texts: Arduino SD count files and open last, How to?

texts:
I am trying to count files. I have one hidden file from Windows10 so i am doing "-1" but I want to open the last file and can't work out how, any help? Please, Thanks

#include <SD.h>
int entryCount = 0;
File root;
int total = 0;
int Lfile = 0;
void setup()
{
  Serial.begin(9600);
  pinMode(10, OUTPUT);
  SD.begin(4);
  root = SD.open("/");
  printDirectory(root, 0);
  root.close();
  Serial.println();
  Serial.print(total-1);
  Lfile = total-1;

  File dataFile = SD.open(Lfile);
  // if the file is available, write to it:
  if (dataFile) {
    while (dataFile.available()) {
      Serial.write(dataFile.read());
    }
    dataFile.close();
  }
  // if the file isn't open, pop up an error:
  else {
    Serial.println();
    Serial.println("error opening last file");
  }
}

void loop()
{
  // nothing happens after setup finishes.
}

void printDirectory(File dir, int numTabs)
{
  while (true)
  {
    File entry = dir.openNextFile();
    if (! entry)
    {
      if (numTabs == 0)
      return;
    }
    for (uint8_t i = 0; i < numTabs; i++)
      Serial.print('\t');
    Serial.println(entry.name());
    total = entryCount;

    Serial.print(entryCount++);

    Serial.print('\t');

    entry.close();

  }
}


texts: How can I make a power button for my project powered by a USB powerbank?

texts:
I've solved the battery power supply issue for my Arduino project by simply connecting a USB powerbank. However, I just realised that I can't come up with a good way to add an on/off button! There doesn't seem to be a way to turn the Arduino off using software. My second solution would be to cut up the USB cable (or an extension chord) and solder a switch onto the 5V wire.

Is there a more convenient solution that I'm missing?


texts:
I'm using an Arduino Micro, a 12 V water pump and a print relay to water a plant.

A water level switch monitors the the water tank to make sure the water pump does not run dry.

I tried different watering times and figured that when using longer watering times 90,000 milliseconds and longer. The relay sometimes does not switch correctly and the pumps keeps running. I'm not sure if my code is optimal for that kind of purpose:

const int Power_Water = 3; // Pin to turn the Pump On and Off via relay
const int Watering_Time = 90000; // Time the water's supposed to run
const int Water_Tank = 10; // Water Level Switch

void setup() {
  Serial.begin(9600);
  pinMode(Power_Water,OUTPUT); // Pin that triggers the Relay as Output
  pinMode (Water_Tank,INPUT_PULLUP); // Pin of Water_Level Sensor as internal pullup
}

void loop (){
  unsigned long watering_Start = millis();

  while (millis() - watering_Start <= Watering_Time && (digitalRead (Water_Tank) == LOW)){
    digitalWrite(Power_Water,HIGH); // Water Pump goes ON
    Serial.println(millis() - watering_Start);
  }

  if (millis() - watering_Start > Watering_Time || (digitalRead (Water_Tank) == HIGH)){
    Serial.println("Pump OFF");
    digitalWrite(Power_Water,LOW);// Water Pump OFF
  }
  delay(100000000); // example "sleep" time the system is not supposed to water
}

Any suggestions are appreciated.

I changed

const int Power_Water = 3; // Pin to turn the Pump On and Off via relay
const long Watering_Time = 90000; // Time the water's supposed to run
const long Water_Tank = 10; // Water Level Switch

void setup() {
  Serial.begin(9600);
  pinMode(Power_Water,OUTPUT); // Pin that triggers the Relay as Output
  pinMode (Water_Tank,INPUT_PULLUP); // Pin of Water_Level Sensor as internal pullup
}

void loop (){
  unsigned long watering_Start = millis();
  digitalWrite(Power_Water,HIGH);
while (digitalRead(Power_Water) == HIGH){
Serial.println(millis() - watering_Start);
if (millis() - watering_Start > Watering_Time || (digitalRead (Water_Tank) == HIGH)){
    Serial.println("Pump OFF");
    digitalWrite(Power_Water,LOW);
}
}
delay(100000000); // example "sleep" time the system is not supposed to water
}


texts: Need little bit of help on testing I2C sketch

texts:
I have this code I got from YouTube for communicating between two Arduinos. By typing 'R' manually into the serial monitor of the 'master' Arduino, the 'slave' will print "Success". I'm trying all this for the basis of a project I'm starting.

After success with the code, I am now trying to make it automatic. I want the 'master' Arduino to print "R" itself and for the 'slave' to read this and print "Success". println doesn't work here, maybe it'll work if the slave code is changed? Both original codes are below, any ideas on how to do what I need?

Master:

#include <Wire.h>
char incomingByte;
int x = 0;

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

void loop()
{
  Wire.beginTransmission(9);
  if (Serial.available()) {
    while (Serial.available() > 0) {
      incomingByte = Serial.read();
      Wire.write(incomingByte);
      Serial.println(incomingByte);
      Wire.endTransmission();
  }
  }

}

Slave:

#include <Wire.h>

int x = 0;

void setup() {
  Wire.begin(9);
  Wire.onReceive(recieveEvent);
  Serial.begin(9600);
}

void recieveEvent(int bytes) {
  x = Wire.read();

}

void loop() {

  if (x == 'R'){
    Serial.println("Success");
    delay(100);
  }
}


texts: Sending digital signal from one arduino to another

texts:
I have one arduino with two proximity sensors that send two digitalWrite signals if an object is detected. I checked to make sure the output of these is working properly and only sending high signals when they should. I have a second arduino that is wired directly from those two outputs as two digitalReads and printing whether or not they are high or low.

The problem is that even though the first arduino is not sending a high signal, the second arduino's digitalReads are seeing high. I tried putting a 1k or 10k resistor in between and that just seemed to decrease the rate of this happening, but it also decreased the rate of seeing the high signal when there actually was one.

Anybody know what I'm doing wrong?

Connections:

Arduino 2 (sensors) code:

/* Two ultrasonic sensors for collision detection
Angled on front sides

Checks for object and sends digital high if distance is less than set threshold
(ran out of pwm pins on main arduino)
*/

#define LEFT_INPUT 5
#define RIGHT_INPUT 6
#define LEFT_OUTPUT 8
#define RIGHT_OUTPUT 9

// distance to stop
int stopThreshold = 24;  // ~10cm

// vars
long ultraLeft, inchesLeft, cmLeft;
long ultraRight, inchesRight, cmRight;
int objectDetectedLeft, objectDetectedRight;

void Poll_Ultrasonic()
{
  // left
  ultraLeft = pulseIn(LEFT_INPUT, HIGH);
  inchesLeft = ultraLeft / 147;
  cmLeft = inchesLeft * 2.54;
  if (cmLeft < stopThreshold)
    objectDetectedLeft = 1;
  else
    objectDetectedLeft = 0;

  // right
  ultraRight = pulseIn(RIGHT_INPUT, HIGH);
  inchesRight = ultraRight / 147;
  cmRight = inchesRight * 2.54;
  if (cmRight < stopThreshold)
    objectDetectedRight = 1;
  else
    objectDetectedRight = 0;
}

void setup()
{
    // Serial monitor
  Serial.begin(9600);
  // pins
  pinMode(LEFT_INPUT, INPUT);
  pinMode(RIGHT_INPUT, INPUT);
  pinMode(LEFT_OUTPUT, OUTPUT);
  pinMode(RIGHT_OUTPUT, OUTPUT);
}

void loop()
{
  // check distances, set flags
  Poll_Ultrasonic();

  // set output pins high on detection, print detection messages
  if (objectDetectedLeft) {
    digitalWrite(LEFT_OUTPUT, HIGH);
    Serial.println("\n  LEFT object detected!\n");
  }
  else
    digitalWrite(LEFT_OUTPUT, LOW);

  if (objectDetectedRight) {
    digitalWrite(RIGHT_OUTPUT, HIGH);
    Serial.println("\n  RIGHT object detected!\n");
  }
  else
    digitalWrite(RIGHT_OUTPUT, LOW);

  // print distances
  Serial.print("Left ultrasonic distance: ");
  Serial.print(cmLeft);
  Serial.println("cm");
  Serial.print("Right ultrasonic distance: ");
  Serial.print(cmRight);
  Serial.println("cm");
}

Arduino 1 (main) code snippet:

// Ultrasonic pins
#define ULTRA_LEFT 7
#define ULTRA_RIGHT 11

// Ultrasonics
pinMode(ULTRA_LEFT, INPUT);
pinMode(ULTRA_RIGHT, INPUT);

void Poll_Ultrasonic()
{
  if(digitalRead(ULTRA_LEFT) && digitalRead(ULTRA_RIGHT))
    leftOrRight = 2;
  else if (digitalRead(ULTRA_LEFT))
    leftOrRight = -1;
  else if (digitalRead(ULTRA_RIGHT))
    leftOrRight = 1;
  else
    leftOrRight = 0;

  if (leftOrRight)
    objectDetected = 1;
  else
    objectDetected = 0;
}

...

void StopCar()
{
  esc.write(90);
  if (leftOrRight == -1)
    Serial.println("Object detected on LEFT! Stopping.");
  else if (leftOrRight == 1)
    Serial.println("Object detected on RIGHT! Stopping.");
  else if (leftOrRight == 2)
    Serial.println("Object detected on BOTH! Stopping.");
  else // should never reach this
    Serial.println("Ultrasonic debug statement: bad condition");
}


texts:
I would like to be able to read the serial numbers of SD cards using the SD.h library. Only reading the values is enough, I am not looking to modify the CID.
This should be possible but I do not have the programming skills to get it running.

I am using an esp8266 and already have the SD card running and working correctly. Only the chipselect needed to be modified for the SD library to work.

So far I have found this in Sd2Card.h

      /**
   * Read a cards CID register. The CID contains card identification
   * information such as Manufacturer ID, Product name, Product serial
   * number and Manufacturing date. */
  uint8_t readCID(cid_t* cid) {
    return readRegister(CMD10, cid);
  }
  /**

And in Sd2Card.cpp there is this:

/** read CID or CSR register */
uint8_t Sd2Card::readRegister(uint8_t cmd, void* buf) {
  uint8_t* dst = reinterpret_cast<uint8_t*>(buf);
  if (cardCommand(cmd, 0)) {
    error(SD_CARD_ERROR_READ_REG);
    goto fail;
  }
  if (!waitStartBlock()) goto fail;
  // transfer data
  for (uint16_t i = 0; i < 16; i++) dst[i] = spiRec();
  spiRec();  // get first crc byte
  spiRec();  // get second crc byte
  chipSelectHigh();
  return true;

 fail:
  chipSelectHigh();
  return false;
}

So it seems that the underlying code has been prepared in the library already, my question is how would I include it into a sketch like CardInfo.ino?


texts: How do I communicate with a sensor via an Arduino's RX/TX ports?

texts:
I have a sensor that communicates via serial communication. CTi Sensors TILT-05. It transmits an ASCII string with data separated by commas. I want to be able to read the incoming ASCII data in the Arduino IDE's Serial Monitor in real time (the device is an accelerometer).

I am struggling to convey this in the code. Currently, I have the sensor's RX connected to an Arduino Uno's TX port (digital 1) and sensor TX-> Arduino RX (digital 0). The sensor is powered and grounded via the Arduino.

I have searched for serial communication methods but can't find any that seem to work. How can I receive and interpret the incoming data from the sensor?


texts: ESP 01 lost its firmware when it disconnected

texts:
Hi I am using Arduino uno & ESP-01

ESP-01 is working well when I put firmware to ESP, for example, wifi spreading or AT command is okay.

but when I disconnect arduino from PC(disconnect USB connection)

ESP-01 suddenly do not work anything. no spread wifi, no AT command reaction..

so I always have to re-input the firmware to ESP again, for make it work again.

How can I make maintain ESP-01 's firmware?

picture is my connection status. thank you


texts: Arduino digitalWrite 1 or 0 instead of HIGH or LOW

texts:
Is it ok to use

digitalWrite(pin, 1) instead of digitalWrite(pin, HIGH)

or

digitalWrite(pin, 0) instead of digitalWrite(pin, LOW)

I want it that way to make the coding lesser because I save values on EEPROM with 1's and 0's. So if I want to use EEPROM value, I can call it this way

digitalWrite(pin, EEPROM.read(1))


texts: Arduino raise the error "variable-sized object 'my2dArray' may not be initialized" while trying to change the elements of 2d array

texts:
I' m trying to change 1 to 0 in two-dimensional (5x5 matrix) for specific servo positions.First, i tried to program forward movement of my robot.  My code is like this:

#include <Servo.h>
#define x 5
#define y 5

Servo myServo;
Servo myServo2;

int pos = 0;

int counter1;
int counter2;
int integer;

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

void loop() {

  int my2dArray[x][y]= {
  {1,1,1,1,1},
  {1,1,1,1,1},
  {1,1,0,1,1},
  {1,1,1,1,1},
  {1,1,1,1,1},
  };

  int robot = my2dArray[2][2];

   if (counter1 > 0){
     for (integer = 0;  integer <2; integer +=1){
      int my2dArray[2 + integer][2] = robot * my2dArray[2 + integer][2];

     }
 }
}

  int moveForward(){
  for (pos = 0; pos <= 360; pos += 1) {
    myServo.write(pos);
    myServo2.write(pos);
    delay(15);
    if (pos == 360){
    counter1 += 1;
    }
    return counter1;
}
}

int moveBackward(){
  for (pos = 360; pos <=0; pos -= 1) {
    myServo.write(pos);
    myServo2.write(pos);
    delay(15);
    if (pos == 360){
    counter2 += 1;
    }
    return counter2;
}
}

But i can' t change the [3][2] and [4][2] elements from 1 to 0. I get an error:

 error: variable-sized object 'my2dArray' may not be initialized

Can you help me?
Thanks.


texts:
I am using the BasicOTA file and after uploading and rebooting the board everything works and I get a message in the serial monitor saying "Ready" and my board's IP address. However, the board doesn't show up in the Tools > Port menu.
Does anyone know how I can fix this?


texts: How to include a file from another (parent) directory

texts:
This is my structure
program/
  src/
    Makefile
    main.ino
    test.h
    ...
  lib/
    i2c.h

In main.ino I include test.h and in test.h I'm trying to include i2c.h but it is just not working, I keep getting:
make: *** No rule to make target 'i2c.h', needed by 'build-uno/main.ino.o'.  Stop.

I tried including like this
// test.h
#include "../lib/i2c.h"

I also tried making a symlink to my lib folder in arduino libraries and adding it as a library in Makefile
sudo ln -s /home/pi/program/lib /usr/share/arduino/libraries/GAVR
# Makefile
ARDUINO_DIR = /usr/share/arduino
BOARD_TAG = uno
ARDUINO_PORT = /dev/ttyAMA0
ARDUINO_LIBS = GAVR
include /usr/share/arduino/Arduino.mk

I also tried making a symlink to lib inside the src directory
ln -s /home/pi/program/lib /home/pi/program/src/lib
None of the above had any effect, the error message stays the same.
How can I include a file from another directory in my program?


texts: Possible error in CAN-Bus shield schematic?

texts: This is a part of SeeedStudio CAN-Bus shield schematic. The vertical green line on the left seems suspicious to me. Am I missing something?


texts: Connecting Arduino Due's DAC output to pc sound card with protection

texts:
I would like to connect the DAC outputs of my arduino board to my pc sound card input so that I can use my sounds card as an osciloscope.

I have two questions:

1- if I don't use an amplifier,  how can I protect the arduino from being damaged?

2- if I use an amplifier with dual rails,  do i still need to protect the arduino somehow?

Please note that I know little about analog circuitry so a direct solution would be most appreciated. In short how would I use components to make sure I don't end up nuking my dac outputs.

Thanks.


texts: Connecting CAT5 robustly between portable Arduino and more portable sensors

texts:
Newbie wiring question. I’m building a lightwand of some sort, involving an RGB LED and a few pushbuttons that I want to wave around (the “remote”), while staying connected over ~0.5 - 3m to an Uno (the “head”).

In a portable incarnation, the remote might be on your finger and the battery-operated head in your backpack. I’m hoping to use stranded CAT5 for the connection between them (“the bridge”) — it’s the right number of conductors, good flexibility, I have lots of it.

My question is: how should I best mate the CAT5 to both ends — pins on the Arduino at the head, and pins or bare wire off my LED and switches at the remote?

At the head, I like the idea of an RJ45 jack (“NOT ETHERNET”), both for modularity and as I’m a bit worried about strain on the cable pulling wires out of Arduino pins. (The jack basically gives me a good interface at the enclosure level.) I could get an RJ45-to-wiring-terminal-block, and then run solid jumpers from the block to the pins, but they’re expensive. I could try a keystone jack and just try using solid jumpers rather than more CAT5 going between the jack’s wire-breakout and the Arduino board — but I worry the jumpers won’t be the right “size” for the jack, and I’m worried about flimsiness. (If the entire head enclosure is in your backpack, it’s going to get jostled. I want something durable.)

I see some examples of an RJ45 jack soldered directly to a board. What sort of RJ45 is that, and could I do that and solder straight to the board pins on a cheap shield, with relatively novice soldering skills? Or is this at risk when people yank the cable inadvertently?

As I said: I’m a newbie, don’t know what’s reasonable, and keep coming up with overcomplicated architectures where the CAT5e connects to a jack to a block to jumpers to pins,  etc. etc.

At the remote, I think I’m better off. Things need to be as small/portable as possible, so I think I bring the bare stranded wire out of the CAT5e onto a tiny bit of board, and just solder the strands directly to the leads coming off my buttons and LED, and wrap some tape around it, then attach the whole thing to a glove or a bracelet to keep it relatively immobile at the end of the cable. Ok or terrible?

Thanks for suggestions, directions, and other help. I’ve looked around and don’t see questions at this level of ignorance. One of the answers to this mentions that “people wire a RJ45 sock directly to an Arduino” (my head problem) but doesn't say exactly how.  How can I attach sensors without a shield for a wearable project? is doing what I want, but also underspecified...


texts: ESP32 Pins won't fit in solderless breadboard

texts:
I bought an Adafrut Huzzah32 ESP32 for an IoT project. When the ESP32 arrived, I attempted to fit it into my existing breadboard, but I immediately noticed that no matter how hard I pushed, the pins wouldn't fit into the solderless breadboard.

I tried to find others with the same problem with no luck, so I went on amazon and purchased another breadboard (an Elegoo 830 tie-points Breadboard). It arrived today and I'm having the exact same problem. I don't want to use a soderable breadboard at this stage of the project as I'm just starting, but I don't know what else to do at this point.

I've Googled images of other peoples' setups and there pins are snug down in the board. What am I doing wrong? I've included photos below:

As you can see, the power module on the end fits fine but the ESP32 won't go down into the board. At this point, I've tried two different boards (one of those small Arduino ones and this one) with no luck.

Any suggestions?

You can see that the pins aren't even close to being down in the board.


texts:
I don't know what's wrong with the code I have activated all the bits I need. I want the code to slowly increase the brightness of the bulb and then reset and then the same thing goes on. Please help me find the error in the code.

#include<avr/io.h>
#include<avr/delay.h>
#include<avr/interrupt.h>

int duty_cycle;

int main()
{
 duty_cycle=50;
 DDRD=0b01000000;
 PORTD=0b01000000;

 TCCR0A=(1<<COM0A0)|(1<<WGM00)|(1<<WGM01);
 TIMSK0=(1<<TOIE0)|(1<<OCIE0A);
 OCR0A=duty_cycle;
 sei();
 TCCR0B=(1<WGM02)|(1<CS00);
 while(1)
 {}

 return 0;
 }
 ISR(TIMER0_COMPA_vect)
 {if(duty_cycle<250)
 {duty_cycle=duty_cycle+10;}
 else
 duty_cycle=50;
 }


texts: Is the Serial buffer going from Arduino to PC and from PC to Arduino different?

texts: I'm both sending and receiving strings to Arduino from my Python program on the PC and the opposite. I don't check by code if one is finished before doing the other. Are they seprate buffers, or is it just pure luck my program has been running fine until now and each program has been reading the right string ?


texts: Counter variable gets reset to 0 without resetting it(Mega)

texts:
(Arduino Mega2560) I'm trying to test placing a counter n in a for loop, the problem is, every time it gets out and goes back to the for loop, the n is reset again, so it prints "counter: 245" every time. However, when I comment out *b++=data; and data++; it does count properly. What exactly is going on ?!

Code:

uint8_t i=0;
uint8_t buf[245];
uint8_t *b=buf,*b2=buf;
uint8_t data=10;
int n=0;

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

void loop() {
for(i=0; i<245 ;i++){
  *b++=data;
  data++;
  delay(50);
  n++;
  Serial.println(buf[i]);
  }
  data=0;
  delay(5000);
  Serial.println("counter:");
  Serial.println(n);
  delay(5000);
}


texts: Which arduino should i use for a very simple one pin "blinking led" type project?

texts:
I want to simply switch a relay like Majenko describes it for my last question. (time based switching of a relay)

That's the code I came up with based on the documentation:

int relayPin = 2; // pin where relay is attached
long mins = 5L;

void setup() {
    pinMode(relayPin, OUTPUT);
}

void loop() {
    digitalWrite(relayPin, HIGH);
    delay(mins * 60L * 1000L);
    digitalWrite(relayPin, LOW);
    delay(mins * 60L * 1000L);
}

Now I want to use a real device and have been looking around, but there are tons of different boards, so some shopping advice would be really great. What I would like if possible:

Closed casing to reduce risk of people touching stuff. (also for a "professional" look)
Built in power supply from 220V AC.
Outputs strong enough to work without external logic, just connect the relay and go.
Small size and low cost, in case I start using these everywhere in the house i don't need to reevaluate. :)


texts: Lipo Battery level display using nodemcu

texts:
I'm designing a connected collar for pets for a project, for this I am using a nodemcu on ESP8266 powered by a Lipo battery I'm guessing around 1000mAh of capacity is enough for a respectable autonomy (? any advices).
Lipo model : https://www.lipolbattery.com/lithium%20polymer%20battery.html
In order to charge the battery I have found this USB LiPo charger (https://learn.sparkfun.com/tutorials/lipo-usb-charger-hookup-guide/all), my first question is: Is it still usable for higher capacity LiPo batteries (1400mA)?
Also I would like to display the battery level via and RGB LED (example: green is for battery FULL battery and RED for LOW battery level in need of charging) is there any way to do this? Thank you


texts:
I have come across the various blogs which talks about cloning RF remote using cheap 434 MHz Tx/Rx and RCSwitch library.

I tried using RF 434 MHz ASK (https://www.sparkfun.com/products/10532) module with arduino, but the range I get it very less , just around 5-6 centimeters. Seems these RF 434 MHz modules are not stable. So I am planning to use now another RF Module which uses NRF905.
Link -
http://www.ebay.com/itm/2pcs-NRF905-wireless-module-PTR8000-wireless-transmission-433-486-915MHz-/270963407796

My query is can I use NFR905 based RF modules which is also 434 Mhz to clone any existing remote working on 434 MHz. Please help


texts: Use Arduino Mega to program Arduino Duemilanove

texts:
I hava an Arduino Duemilanove but I think that its FTDI chip is crashed.

I have an Arduino Mega too, so can I use it to program my Duemilanove?


texts: Passing variable value in structure object

texts:
in this code i want to pass value of variable char array 'pass' in object "MyObject". But i am getting this error.

    Arduino: 1.6.11 (Windows 8.1), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\XXX\Desktop\EEPROM_put\EEPROM_put.ino: In function 'void setup()':

EEPROM_put:17: error: array must be initialized with a brace-enclosed initializer

};

^

exit status 1
array must be initialized with a brace-enclosed initializer

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

when i change pass to *pass, result of EEPROM.get() is 1 and 6, instead of 1, 62345, 7539514682.

#include <EEPROM.h>
struct MyObject {
boolean stat;
char password[6];
char mobile[11];
};

char pass[6]="62345";
void setup() {
Serial.begin(9600);
while (!Serial);
MyObject customVar = {
  1,
  pass,
  "7539514682"
 };
EEPROM.put(1, customVar);
Serial.print("Written custom data type!");
}

void loop() {

}


texts: Arduino digital pin input used to power device?

texts:
I am attempting to debug a W65C02 and I am using an Arduino Mega to look at the inputs and outputs of the device, which is behaving weird.

I have Pin 22 to 52 connected as INPUT on the MEGA and they are all connected to A0-A15 and D0-D7 on the 6502. However when I unplug my Arduino and keep the 6502 powered on it seems to stay on in that the power light is on. Is something fried or is this normal behavior?

Nothing else is plugged in to the Arduino except GND and the digital inputs.


texts: I know this that when you try to program a pro mini without a DTR pin it will give you a error as the atmega needs to be reset during programming. So I had a doubt why does the microcontroller needs to be reset and clearly at which time you know at which moment does it reset ?


texts: Do you need an ESC to run this brushless DC motor with Arduino Uno?

texts:
This is the motor:

https://www.aliexpress.com/item/Wholesale-JGA25-2418-8-5-1977-rpm-Electric-Motors-Brushless-Motor-High-Torque-Speed-Controlled-DC/32360228129.html

I'm hooking it up to the arduino as described and giving the PWM outputpin analogWrite functions, but it's not working.


texts: Motor on transistor causes arduino to reset

texts:
I have a motor hooked up to the emitter of a NTE24 transistor and ground, the collector is hooked up to 3.7V, and the base is connected through a 10ohm resistor to a PWM pin on an arduino mega, which is powered by 3.7V through Vin. I use analogwrite on the pin to control the motor speed.

When i turn it on, the arduino just resets. I think it’s because the base is drawing too much current from the arduino pwm pin, but if I replace the 10ohm resistor with 330ohms, it is far too slow. Any ideas? I have tried a TIP3C transistor as well to no avail.

Edit: I suppose my question now is I’m losing too much power in the transistor. Would a mosfet help with that? In addition, what’s a good small board that uses 3.3V that also has some sort of usb connection?

Edit 2: Read latest comment, tried MOSFET and fly back diode, now it just clicks and restarts :/


texts: I have an arduino mega that i am using as a clock. I would like it to detect if it is connected to a USB or external power supply (e.g. a battery). I then want to set a variable to different values depending on the result, so i can display it on an OLED.


texts: Why the serial connection only work when Tx and Rx are shorted?

texts:
I have a Arduino Pro Mini 3.3V connected to a sim800l chip using a serial connection of 9600bps. When I connect the Arduino to the device, it seems I don't receive anything on the Arduino Rx pin.

I then connected a FTDI that listen the sim800l Tx pin:

The FTDI is able to receive data so this means the sim800l is working well by receiving data from the Arduino and responding accordingly.

So normal logic would say that the Arduino Rx pin is not working but when I connect the Arduino Rx and Tx pin together:

I'm able to receive what I send on Tx on the Rx pin.
Why would that be?

I tried with AltSoftSerial and SoftwareSerial. The Arduino is powered by a FTDI connected to my computer via USB. The sim800l is powered by a second FTDI that is also powered by my computer USB. So all component uses the same ground and I verified that with my multi-meter.

Here is the code I use:

AltSoftSerial sim800Serial(8,9); // RX, TX

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

while(1)
{
  if(sim800Serial.available())
  {
    Serial.write(sim800Serial.read());
  }

  if(Serial.available())
  {
    sim800Serial.write(Serial.read());
  }
}


texts:
I need to do some simple line control of audio out from a phone, 3.5mm TRS. I would have preferred to use transistors, but the voltage drop on an already fairly weak signal makes it unusable. Also not sure about negative voltage from collector to emitter. Essentially I need to switch the line on/off. How can I do this while not introducing noise or signal loss (K.I.S.S.) - I haven't checked if optocouplers are without voltage drop, but in any case they're probably overkill.
Ask for clarification if needed.


texts: Unable to connect Arduino Uno to Ubuntu 16.04

texts:
I've received an Arduino Uno today only. I have zero experience prior to Arduino boards or any other micro controller. I followed every step very carefully from the setting up guide for Linux based OS, but I still can't connect the board with my Ubuntu 16.04 PC. After googling the problem I found that the device must show up as ttyACM* but I don't see any such device in /dev. Its also not listed under the command lsusb but the LED's on the board are working properly. The ON LED is turned on when I connect it with my PC and the inbuilt LED starts to blink.

This is what the IDE displays:


texts:
I am using MightyCore and platformio. My config file looks like this
My fuses are set as:
E:FD
H:D6
L:8F

I have controller running at 16 MHz and SCK frequency is 8 MHz.
My display is showing white color and that is it. I know to make it function properly I have to use 1 MHz SPI clocking.
If I program CKDIV8 fuse my controller doesn't start. I dunno why, kind of black magic going on there for me. My lack of knowledge is not helpful there.
I tried to use the following tricks:
Setting SPI speed using TFT library
// earlier in main.cpp
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
// later in setup()
tft.setSPISpeed(1000000); // has no effect on SCK

Trying to set it directly via SPI class instance:
// in setup()
SPI.setClockDivider(SPI_CLOCK_DIV128); // no effect

Or statically:
// in setup()
SPIClass::setClockDivider(SPI_CLOCK_DIV128); // still no effect

Also I tried to pass DEFAULT_SPI_FREQ build flag with frequency preset.
I ran out of ideas.
Schematic is here:


texts: Send/receive data from/to Raspberry Pi to/from Arduino with HM-10 (Bluetooth LE module)

texts:
My goal is to send a string from an Arduino via an HM-10 bluetooth module to a Rasperry Pi. I do this today by connecting the HM-10 on the Arduino to another HM-10 module (master/slave) and then from that module to the Raspberry Pi via USB Serial adapter which gives me a /dev/ttyUSB0 that I can read. I would like to just have the Arduino's HM-10 connect up directly to the Bluetooth of the Raspberry Pi without any extra modules at all.

I found the app "Arduino Bluetooth Controller" (Android) that can connect to the module and serial communication is working.

I also have the HC-05 module and there I can solve it by using rfcomm bind 2 , but that doesn't work on the HM-10.

I'm open to any solution that can do this. Either bind the serial communication using rfcomm (or alternative) like on the HC-05, or try to build an app that is doing the same thing the Android app does, only on the Raspberry Pi.


texts: ARduino dfplayer and LCD interfacing simultaneously

texts:
I have separate codes.

1) for displaying data on 16*2 LCD which is shifting at 0.5 seconds

2) another code for playing songs on DFplayer (2 minutes song whic plays when I press a button)

I want to play the song and the text on the LCD to be shifting at the same time.

How do I do that. bec the code waits till the song is being played by the dfplayer.


texts:
I am wondering if it's possible to transmit on all frequencies at once using this module.

I know it's illegal to take over regular stations when others are trying to listen but I'm only planning to use it for short range (less than the length of my house).


texts: Photoresistor is not working, is there something wrong in the code?

texts:
I am trying to make the photoresistor work in a simple project.

The project is as follows:
The LED light should light up brighter and brighter as the photoresistor reads less light in the room.

The problem:
The reading is fixed on 1023. Therefore the LED never lights up. I cannot understand why.. Sometimes if I cover the sensor the readings go down to 900- 950 but never less even though it is completely dark around the sensor. Is there something wrong in the code? What could have gone wrong?
Please note that the resistor connected to the sensor is 10k Ohm as is the one connected to the LED.

Here is the code

int photoPin = 0;
int pReading; // analog readings

int LED = 11; // red LED connected to pin 11
int LEDbrightness; //

void setup()
{
  //set up the serial connection
  Serial.begin(9600);
}

void loop()
{
  pReading = analogRead(photoPin);
  Serial.print("Photocell reading = ");
  Serial.println(pReading); // Analog reading

  pReading = 1023 - pReading;
  //map 0-1023 to 0-255
  LEDbrightness = map(pReading, 0, 1023, 0, 255);

  analogWrite(LED, LEDbrightness);
  delay(50);
}

Here are the connections

thank you!


texts: Serial communication between Computer & Arduino via XBee

texts:
I configured two XBees using XCTU, connected them to the computer and sent Bytes back and forth. Works.

This is the current, non-working setup:

1 XBee, connected to the Computer using a SparkFun XBee Explorer USB.
1 XBee, connected to an Arduino Mega using SparkFun XBee Explorer Regulated

GND to GND
5V to 5V on the Arduino
DOUT to TX1 on the Arduino
DIN to RX1 on the Arduino

void setup() {
  Serial1.begin(9600);
  pinMode(13, OUTPUT);
  //After 3 seconds the XBee should send out a couple of "A"s coming from the serial port
  delay(3000);
  int i = 0;
  while (i < 10) {
    Serial1.print("A");
    delay(100);
    i++;
  }
}
void loop() {
  //If anything is sent to the XBee it should appear in the Arduino's serial buffer
  //making the LED on pin 13 turn on
  if (Serial1.available() > 0) {
    digitalWrite(13, HIGH);
  }
}

The DOUT LED on the Explorer Regulated flashes as supposed to but nothing is received on the computer where my Terminal application is listening.

Same when I send something from the Terminal, the LED on pin 13 of the Arduino does not indicate any bytes in the buffer, meaning that the XBee probably never received anything.

I already tried swapping TX & RX, resulting in the DIN LED blinking instead of DOUT. Transmission still not working.


texts: Why does the standard Arduino IDE not include the CH341G USB Drivers?

texts:
Can anyone explain why the standard Arduino IDE 1.6 distribution does not include support for the popular CH341G USB/serial drivers?

I am using these USB/serial chips in several teaching projects for CoderDojo and it is somewhat difficult to have each student download the drivers and reboot their PCs for each class. It seems like both Mac and PC users would benefit from having these drivers loaded directly into the standard Arduino IDE.

Is there possibly some security concern? I know that the latest Mac requires that the drivers are digitally signed. In fact for many modern Macs to use the drivers we have to disable the digital signature checks.

Here is the link to the official drivers.

Here is a good article on how to download the drivers.

BTW, the command to disable the digital signature check on the mac we need to do the following:

In the Mac "Terminal" application enter:

sudo nvram boot-args="kext-dev-mode=1"

Then we must reboot the mac. Then when we want to re-enable the checks change the 1 to 0:

sudo nvram boot-args="kext-dev-mode=0"

If we don't do this command, the Arduino App will not show the serial ports. Do to this go to Tools -> Port Menu within the Arduino application.

/dev/tty.SerialPort
/dev/cu.SerialPort

I should mention that the CH340G are also used in many "Arduino Nano" clones from China. Perhaps that is why the drivers are not included?

Tags: Driver CH340 Setup Installation


texts: Circuit requirement for Arduino Due custom circuit without the ATMEGA16U2

texts:
I would like to create a custom Arduino board based on the Arduino Due. Upon looking at the Due's schematics under the documentation tab there are some stuff that i do not need and removed them. the last thing that i want removed is the ATMEGA16U2. This part just takes so many components that i want it removed.

I would like to build my code using the arduino IDE and with the 16u2 gone i do not know a way how to upload my codes.

This seems to be possible since under the documentations there is a native usb port of the due that is directly connected to the SAM3X8E,

from here on out im lost what how do i upload my code to the same sam3x8E

Special tools that i have that might be usefull:

J-link EDU Mini
USB to UART

My Current draft schematics:


texts:
All welcome.

I'm trying to connect nodemcu to the phone's wifi.

And nodemcu can't do it. But sometimes after several reboots she does it. Also if i use my old phone - nodemcu connects perfectly! Why?

My "new" phone: Fly FS504 Cirrus 2

My old phone: Fly IQ4504 Quad.

My code:

#include <ESP8266WiFi.h>

const char *ssid =  "Just my SSID";

const char *pass =  "Some password";

WiFiClient client;

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

       Serial.println("Connecting to ");
       Serial.println(ssid);

       WiFi.begin(ssid, pass);
       while (WiFi.status() != WL_CONNECTED)
          {
            // stack here (only with new phone)
            delay(500);
            Serial.print(".");
          }
      Serial.println("");
      Serial.println("WiFi connected");
}

void loop()
{

}


texts: Interrupt variable not getting called while executing another part

texts:
volatile byte _incomingFlag = 0;

void onIncoming () {
    _incomingFlag = 1;
    Serial.println(F("You got an interrupt"));
    mySerial.println("ATH0");
}

void setup () {
    /* First Start the module */
    Serial.begin(9600);
    Serial.println(F("Initializing module..."));

    powerOn();

    mySerial.begin(9600);

    sendcommand(F("AT"), F("OK"), 1000);
    sendcommand(F("AT+CLIP=1"), F("OK"), 1000);
    sendcommand(F("AT+CMGF=1"), F("OK"), 1000);

    /* We need to attach ringing Interrupt */
    attachInterrupt(M_RING_INTERRUPT, onIncoming, FALLING);

    delay(100);
}

void loop() {
    if (_incomingFlag == 1) {
        manageIncoming();
        Serial.print(F("_incomingFlag: "));
        Serial.println(_incomingFlag);
    } else  {
        Serial.println(_incomingFlag);
        Serial.println(F("not getting value"));
    }
    get_currentLocation();
    send_Location();
}

I am trying to check the value of incomingFlag from the loop() . When I get a call or an SMS the interrupt function is getting executed and incomingFlag is set to 1 but I am not getting that value from the loop(). Everytime it's getting 0 if I check the value while the send_Location function is executing (data uploading part). How can I access the value of incomingFlag from the main loop().


texts:
I'm just learning how to use the Arduino Uno and I'm trying to control the speed of an AC fan. I made a sketch of this project on proteus but the triac seems not to be responding. I guess there's a problem with the attachInterrupt part of the code. Here's the code:

#define triacPulse 5
#define interruptPin 2

//button event
#define button1 6

void setup() {
  // put your setup code here, to run once:
  pinMode(button1, INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  if(button1==HIGH){
    attachInterrupt(0, triacControl, FALLING);
  }
}

void triacControl()
{
  delay(5);   //delay for 5 milliseconds
  digitalWrite(triacPulse, HIGH);
  delay(5);

  digitalWrite(triacPulse, LOW);
}

Thanks for the answer in advance


texts:
I have a prototyping shield with mini breadboard similar to Adafruit Proto Shield for Arduino Kit - Stackable Version R3.

Is there a Fritzing file for this.


texts: How can I increase the responsiveness/speed of my stepper motor?

texts:
I'm trying to control the positioning of a NEMA17 bipolar stepper motor by turning the knob of a potentiometer, using an EasyDriver board.  The control part is solved.  My problem is that if I quickly turn the knob to one end of its range and then back, the stepper motor lags behind by about 1/5 of a second.

All the spec sheets for the motor says I should be able to expect a lot more responsiveness (based on max RPM, acceleration, etc...). I'd like to speed up the responsiveness of the motor to shorten the lag. My code is as follows:

//Declare pin functions on Arduino
#define stp 2
#define dir 3  //LOW => forward, HIGH => backward
#define MS1 4
#define MS2 5
#define EN  6

//Declare variables for functions
int x;
int const potPin = A0;
long potval; // current analog read of A0 voltage
int potrotsteps = 166; //num of stepper motor steps for 300-degree rotation
int cur_step_pos = 0; //current position in terms of stepper steps
long cmd_step_pos = 0; //step-position to command stepper motor to go to
int tomove; //num steps to move

void setup() {
  //stepper motor setup
  pinMode(stp, OUTPUT);
  pinMode(dir, OUTPUT);
  pinMode(MS1, OUTPUT);
  pinMode(MS2, OUTPUT);
  pinMode(EN, OUTPUT);
  resetEDPins(); //Set step, direction, microstep and enable pins to default states
  Serial.begin(9600); // initialize serial communication at 9600 bits per second
  Serial.println("\n\n\n#################    setup completed     #################");
}

void loop() {

  //map analog voltage read from pot to a step-position (0-166) of the stepper motor
  potval = analogRead(potPin);
  cmd_step_pos = potval * potrotsteps / 1023; // find where stepper motor should be in terms of step-position
  tomove = abs(cur_step_pos - cmd_step_pos);

  if (cmd_step_pos > cur_step_pos) { //if should-be position greater than current position
    digitalWrite(dir, LOW); // move forward
    CommandStepperMotor(tomove); //move forward by the diff in position
  } else { //if should-be position is lower
    digitalWrite(dir, HIGH); //move backward
    CommandStepperMotor(tomove); //move backward by diff in position
  }
  cur_step_pos = cmd_step_pos; //current position is now former should-be position

}

//GLOBAL FUNCTIONS

//Reset Easy Driver pins to default states
void resetEDPins() {
  digitalWrite(stp, LOW);
  digitalWrite(dir, LOW);  //default "forward" movement
  digitalWrite(MS1, LOW); // L-L => full steps, H-L => 1/2 step
  digitalWrite(MS2, LOW); // L-H => 1/4 steps, H-H => 1/8 step
  digitalWrite(EN, LOW); //Enable motor control
}

void CommandStepperMotor(int numsteps) {
  for (x = 0; x < numsteps; x++) {
    digitalWrite(stp, HIGH); //Trigger one step forward
    delay(1);
    digitalWrite(stp, LOW); //Pull step pin low so it can be triggered again
    delay(1);
  }
}

I understand that changing delay(1) to delayMicroseconds(100) in the CommandStepperMotor function should help, but as it turns out, anything smaller than a delay of 1 millisecond stalls the motor.  I've tried to Google other's solutions to the problem, but it seems they had no problem at all lowering the delay in sending the HIGH/LOW signals to the stepper pin to <1 ms.

Any ideas?  Thanks in advance!


texts:
Please help with this error.
Arduino: 1.8.10 (Windows 10), Board: "Arduino Uno"

Sketch uses 882 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
avrdude: ser_open(): can't open device "\.\COM4": Access is denied.

Windows 10 Pro
Arduino UNO ATmeg 328P-PU
Have never been able to Upload a sketch.
Pin 13 and Orange LED blink at 1 second


texts: What exactly does the Arduino preprocessor do?

texts:
Arduino claims to be a "language," not just an "application framework," and Arduino files have their own extension, .ino.  The language is obviously C++, but not quite.  My understanding is that Arduino has some sort of special preprocessor which converts .ino files into C++ files before compiling them.

My question is: What exactly does this preprocessor do?  What exactly are the differences between "Arduino language" and real C++?  The Arduino documentation seems to gloss over this.

In particular, I've had weird things happen when I try to define my own classes in my sketch.  It's hard to figure out what I'm doing wrong when the language doesn't seem to be specified anywhere.


texts:
The program I'm trying to build is:

Type in 1st name, hit enter, type in 2nd name and then hit enter again.
Register those names from string input to char naming in student struct.
Print out the names in serial monitor.
Use those names in the main program.

The problem is I got randomize results whenever I typed in the names.

My target output:

Program Starts
Insert 2 students name:

First student: Adam     //When input -> Adam
Second student: Eve     //When input -> Eve
First student: John    //When input -> John
Second student: Amy    //When input -> Amy
//the sequences should repeat

...but what happened is the sequences of the names randomized. For example:

Program Starts
Insert 2 students name:

First student: Adam
First student: Eve
Second student: John
First student: Amy
//the sequences will keep randomizing

Can anyone point out what I've missed out?

The program:

typedef struct
    {
        char naming[20];
    }student;

    student record[]{
      {""},
      {""},
    };

    String readString;
    String str="";

    // the setup routine runs once when you press reset:
    void setup() {
      Serial.begin(9600);    // initialize serial communication at 9600 bits per second
      while (!Serial);              // wait for Serial Monitor to open
      SerialUSB.println("Program Starts \n Insert 2 students name:");  // Title of sketch
    }

    void loop() {
        namedata();
        mainprg();
    }

    void namedata()
    {
    for(uint8_t i = 0; i < sizeof(record)/sizeof(student); i++){
          while (Serial.available()) {
            char c = Serial.read();
            readString += c;
            readString.trim();
          }

          if (readString.length() >0) {
            str = readString;
            str.toCharArray(record[i].naming,20);
            if(i==0){
               Serial.print("First student: ");
            }else if(i==1){
               Serial.print("Second student: ");
            }
            Serial.println(record[i].naming);
          }
            readString="";
        }
    }

    void mainprg()
    {
      //main program using student`s name
    }

Additional infos:

1.Why use struct? Because I've more data to process/store for one "student" in my main program.
2.Currently using Arduino Yun Mini, Arduino 1.8.7

Thanks in advance!


texts:
I know that this is to initialize something:

Serial.begin(9600);

But I want to know what it really means?


texts: to measure the time between the ON signal and OFF signal

texts:
int pin_state = LOW;
struct Channel {
    byte pin;
    byte state;
    byte count;
    unsigned long fell, rose;
};

const int CHANNEL_COUNT = 3;
Channel channels[CHANNEL_COUNT] = {
    { 2, LOW, 0, 0 },
    { 3, LOW, 0, 0 },
    //{ 4, LOW, 0, 0 },
    //{ 5, LOW, 0, 0 },
    //{ 6, LOW, 0, 0 }
};

void setup()
{
    for (int i = 2; i <= CHANNEL_COUNT; ++i) {
        pinMode(channels[i].pin, INPUT);
    }
    Serial.begin(9600);
    //Serial.println("pin,fell,rose,low time");
    Serial.println("Minutes, Seconds, Count");
}

void loop()
{
    for (int i = 0; i < CHANNEL_COUNT; ++i)
    {
        Channel &c = channels[i];
        byte new_state = digitalRead(c.pin);
        if (c.state == LOW && new_state == HIGH)
        {
            c.rose = millis();
            c.count = c.count + 1;
        }
        else if (c.state == HIGH && new_state == LOW)
        {
            c.fell = millis();
            display_channel(c);
        }
        c.state = new_state;
    }
}

void display_channel(const Channel &c)
{
  int minutes, seconds;
  unsigned long difference;
  difference = c.fell - c.rose;
  seconds = int(difference/1000);
  if (seconds >= 60)
  {
       minutes = seconds / 60;
       seconds = seconds % 60;
  }
    //Serial.print(difference/1000);
    //Serial.print(",");
    Serial.print(minutes);
    Serial.print(",");
    Serial.print(seconds/1000);
    Serial.print(",");
    Serial.println(c.count-1);
    //Serial.print(",");
  }

When I try to run the program, I don't get any output.
Is there anything wrong with the code, that must be solved before any output can get displayed?


texts: Can't open "COM1" on Linux with Trinket Pro

texts:
At work, on a Ubuntu 14.04 system, I can access my Trinket Pro without any difficulty whatsoever.

At home, using either Linux Mint or Ubuntu across two laptops, I can not communicate with the device no matter what I try.

I have the correct board selected, the correct processor, and trying to use USBTiny ISP.

Currently, I'm getting:

avrdude: ser_open(): can't open device "COM1": No such file or directory
An error occurred while uploading the sketch

It's really getting frustrating having to take my devices to work just to upload a sketch, and I've been banging my head for over a week and a half. My UNO R3 boards work without issue on the same laptops.

Here's what dmesg says:

[  863.471315] usb 1-1.1: Product: USBtiny
[  863.471316] usb 1-1.1: Manufacturer: Adafruit
[  876.438778] usb 1-1.1: USB disconnect, device number 12
[  880.921492] usb 2-1: new low-speed USB device number 5 using xhci_hcd
[  881.092152] usb 2-1: New USB device found, idVendor=1781, idProduct=0c9f
[  881.092157] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  881.092161] usb 2-1: Product: USBtiny
[  881.092163] usb 2-1: Manufacturer: Adafruit
[ 1004.305143] usb 2-1: USB disconnect, device number 5
[ 1019.935505] usb 2-1: new low-speed USB device number 6 using xhci_hcd
[ 1020.106524] usb 2-1: New USB device found, idVendor=1781, idProduct=0c9f
[ 1020.106530] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 1020.106533] usb 2-1: Product: USBtiny
[ 1020.106536] usb 2-1: Manufacturer: Adafruit

I am running IDE version 1.8.3, with sudo, the exact same way I'm doing at the office.

Can someone please advise on what I'm missing here? Windows is not an option; I haven't used it in many years. I'd just like to figure out what's wrong.

I do have an FTDI connector, but didn't have much luck with it either, and to be honest, don't want to use it as I just want to plug the Trinket in, and upload.

Update: I've tried both USB2 and USB3 ports repeatedly with the same results.


texts: Resolved: ESP8266 works when arduino UNO reset pin is grounded

texts:
I'm setting up PIR and esp8266 with arduino UNO.
First my esp8266 doesn't work after alot of research my esp8266 start working when I put arduino UNO reset pin to ground.
But now my arduino UNO does not run any program and I'm not able to use PIR with this wifi module.
Any help will be appreciated

Only one extra thing is that reset pin is set to GND pin.


texts: Cheap medium range wireless communication with a linux PC

texts:
I have a project that's currently using Arduino Uno with a cheap class-2 bluetooth serial adapter from ebay to send and receive data and control a LED light strip.

However, it struggles to establish connection at distances more than couple meters. I'd like to expand that range a bit - 15 meters with two load-bearing walls in the way. Bandwidth requirements are next to none - it should just move couple integers around.

Any suggestions how to do that on the cheap? From what I've seen, class-1 bluetooth adapters go for ~60$, two xbee modules + usb adapter end up costing even more, and wifi solutions seem to reside in the same price range. At that price point, it seems better to get a raspberry pi, wifi dongle and a couple beers for the software re-write. Am I overlooking some solution?


texts: How to program Fio v3 without MicroUSB port

texts:
I got given a Fio V3 but unfortunately the MicroUSB port is missing, not sure why.  Is there any other way to program it?  I'm thinking perhaps those 6 pins under the microcontroller?

Also can I still power the board?  I notice it doesn't have a VCC or RAW pin like the Pro Micro version.  I'm not to worried about using a battery, can I plug any matching voltage into the battery plug?

I tried looking through the schematics and tutorials on Sparkfun but don't really know what I'm looking at.  Here are some relevant links anyhow:

Product page
Schematics
Datasheet


texts: Updating MAX7456 library to work with Arduino 1.6.6

texts:
I've got this library for communicating with the MAX7456 chip.

The library is abandoned and the only one I found that actually works, so I'd really like to use it.

It compiles fine with Arduino IDE 1.0.5, but not with Arduino IDE 1.6.6 .

This happens with 1.6.6, I tried to fix it but I only made it worse.

Arduino: 1.6.6 Hourly Build 2015/07/03 10:26 (Linux), Board: "Arduino Nano, ATmega328"

Using library SPI at version 1.0.0 in folder: /home/t/Dropbox/Arduino-IDE/hardware/arduino/avr/libraries/SPI
Using library max7456 in folder: /home/t/Dropbox/Arduino/libraries/max7456 (legacy)

/home/t/Dropbox/Arduino-IDE/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10606 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -I/home/t/Dropbox/Arduino-IDE/hardware/arduino/avr/cores/arduino -I/home/t/Dropbox/Arduino-IDE/hardware/arduino/avr/variants/eightanaloginputs -I/home/t/Dropbox/Arduino-IDE/hardware/arduino/avr/libraries/SPI -I/home/t/Dropbox/Arduino/libraries/max7456 /tmp/build4912026784583215357.tmp/sketch/HelloWorld.cpp -o /tmp/build4912026784583215357.tmp/sketch/HelloWorld.cpp.o
In file included from HelloWorld.ino:2:0:
/home/t/Dropbox/Arduino/libraries/max7456/max7456.h:228:40: error: 'prog_uchar' does not name a type
static void getCARACFromProgMem(const prog_uchar *table, byte i,charact c);
                                    ^
/home/t/Dropbox/Arduino/libraries/max7456/max7456.h:228:52: error: ISO C++ forbids declaration of 'table' with no type [-fpermissive]
static void getCARACFromProgMem(const prog_uchar *table, byte i,charact c);
                                                ^
Error compiling.

How would one make the library compatible with 1.6.6?


texts: What does the term "9g" in servo's rating mean?

texts: I frequently see 9g mentioned in servos. I searched the web but couldn't find any worthwhile answers. At first I thought it meant 9grams but the weight of the servo isn't 9 grams, so have to be something else.


texts: Limited to 1MP still captures with OV5642 ArduCam Mini + Arduino Uno

texts:
I have an Arducam-Mini-5MP with Arduino UNO R3. I am running the unaltered example ArduCAM_Mini_OV5642_Video_Streaming to the arduino and am running ArduCAM_host_v1.0.exe on my PC with huge successes.

In this state, I can reliably take photos at low resolution (up to 1280x720) in all tested settings. However, when I go to higher resolutions (2592x1944, 2048x1563, and 1920x1080), certain situations result in consistently corrupt images all with the exact size of 524288 bytes.

The images are corrupted whenever I point the camera outside my window, and images are fine when taking photos inside my house. At 1280x720, a typical photo inside my house is 80kb and a typical photo out the window is 190kb (more than double in size). I suppose some content of the photo is impacting the jpg compression?

Unfortunately, images are corrupt 100% of the time for the actual subject I want to take; but the camera works perfectly when I'm testing it indoors. In my scenario I can only capture 0.8MP before images become corrupt.

The frame buffer limit for Arducam is 512kb, so am I just running up against the constraints of the hardware? I feel a bit fooled because I bought a 5MP camera and can only take 0.8MP photos with it.

Is my understanding of this failure correct -- is this the frame buffer size being hit by conditions impacting jpg compression? Are there Arducam shields available with higher frame buffers? Can I avoid this situation somehow?


texts:
My Arduino Uno R3 is not detected by any laptop (I tried 3 laptops). Under devices there is no Arduino port or other devices option. It does not make sound on inserting USB cable. On plugging the USB LED 13 doesn't blink. I is just continuously on. Reset also didn't blink LED 13. Even on external power also it's not resetting.

I checked the USB cable but it's working for my friend's Arduino in my laptop too.

5V Pin giving voltage around 4.96 v, and 3.3 also giving voltage around 3.27 v.

Now I don't have access to any other Arduino for testing. Is there any way to figure out whether the ATmega chip is fried or whether it's a bootloader problem? And how to fix them? Thanks in advance.


texts: What happens when I call exit() from my program?

texts:
In either of setup or loop, if I were to add an exit(0) call, where would control be passed to? What would the next state of the microcontroller be? Would it stop execution and power down?

I am using a revision 2 Arduino Uno.


texts: How to move from arduino to physical prototype

texts:
I've been reading a bit about moving from Arduino to PCB and it seems a bit daunting. For now, all I really want to do is take something I've built, and make a few changes so that I can actually create a casing for it and make sure everything stays connected.

I've attached a photo of my project. What I am trying to do is create a box, where 4 pushbuttons sit in a box, with LEDs next to them. I will probably create foamboard cutouts for the spaces where the pushbuttons and leds sit. The wiring for the push buttons and the LEDs need to be hidden below the foam board, along with the arduino itself and the servo motor - which is where I get stuck.

What do I need to do to essentially "lengthen" the wires for the pushbuttons and LEDs, and make sure all the components stay secure in the breadboard (the push buttons in particular like to pop out)? Is there a way to do this without making a PCB? I understand the concept of soldering components into protoboard, but as far as cutting / printing the circuits or whatever, it is really confusing to me.

I'd appreciate any guidance. If you see anything wrong with my wiring setup too, I'd love a learning experience on that as well. Thanks!


texts: Explanation of the formula of the map funtion

texts:
Can someone please explain (mathematically) how the formula for the map function actually came to light?
I have given the code of the map function below. You can see that it uses a formula to "map" values in a given range from a certain range. I don't quite understand how it came (not good at maths) :| So, I would like an explanation to how this formula came to light.

long map(long x, long in_min, long in_max, long out_min, long out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}


texts: HX711 Load Cell application strange behaviour

texts:
I have an application where an HX711 ADC is used with 4 load cells. (in wheatstone bridge configuration, rated at 50kg each).

The thing is that I am trying to sense 30~ish gram changes with it accurately, while the cells will be loaded with 10 to 40 kilograms.

I have built up the circuitry and placements properly, calibrated and tested etc. but I have 2 questions that I couldn't come up with a solution.

1st question:
When powering arduino from USB cable the readings are much more stable (they are fluctuating like +-5 grams only) but when I connect a 12V power source (with 5A output) to the arduino, the readings start to fluctuate much more. (+-30 grams or so). The HX711 is powered from arduino 5v out pin but even though i tried to power it from a 5v adapter the fluctuations seemed to happen.

I should also note that the HX711 is connected to the analog pins A0 and A1, and there are 8 other sensors connected to the pwm pins of the arduino.

Now any ideas why does that happen? Any way to prevent this fluctuation?

2nd question:
If I calibrate with a load close to the max. weight (as suggested in many papers) the small changes seems to be very unreliable. If I calibrate it with a small weight (like around 200g) I can sense small weights properly but this time when a 2 kg weight is put it is read like 2.3kg or something. Is this normal?

I know that my load cells are not the proper ones for the application but I would like to push them as much as i can.

Thanks for your time


texts: How to send Serial data from an Arduino Uno into the Serial of an ESP-01?

texts:
So, i need to send sound sensor data from an Arduino Uno to the ESP8266 (ESP-01), so it can output a push notification to my phone whenever there's a loud noise. I have the sensor just powered and hooked up to the Analog 0 pin, and the ESP powered and hooked up to the Arduino Serial pins in reverse (RX to TX, TX to RX)
This is the code i have on the Arduino:
void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.write(analogRead(A0) + "\r\n");
  delay(100);
}

And this is the code i have on the ESP:
(i'm omitting the notification part for clarity, it doesn't even use Serial, so i don't think it should interfere)
void setup() {
  Serial.begin(115200);
}
void loop() {
  String val;
  val = Serial.readString();
  if( val.toInt() < 50 ){ sendNotification("Hello!"); delay(10000);}
}

I have tested the Sensor output and it seems fine, whenever i snap or clap the readings show a peak (although reversed, it stays on 1023 constantly then peaks to around 0~50), and the ESP can also send notifications normally. But the trigger on the notification never seems to fire, so i guess the ESP is not receiving the data properly.
I'm new-ish to Arduino, so i don't know if i'm doing something wrong here,
Thanks in advance!


texts: Reading updated serial data from ESP8266

texts:
I have connected my ESP8266 to my Arduino Uno on pin 2 & pin 3 as RX & TX. I adjusted the baud rates and I have no issue receiving the data from the ESP8266.

The ESP8266 gets connected as a client to a server and grabs the likes count of a Facebook page. The data on the ESP8266 serial port is updated correctly every time the ESP sends a get request to the server to get the updated likes count of a particular Facebook page.

Unfortunately I'm not receiving this updated likes count on my Arduino serial port. I'm always receiving the same likes count. I have to close the serial window and open it again to receive the new count. Or reset the Arduino itself to receive the new likes count.

So why isn't it posting the latest likes count sent from the ESP to the Arduino instantly without having to reset the Arduino? Maybe I have an issue in the void loop().

Because I display this data on an external display and I need it to be updated without me needing to reset the Arduino every time to receive the latest count.

void loop() {
  char c;
  while (esp8266.available() && c != '\n') {
    c = esp8266.read();
    response += c;
  }
  //If end of line
  if (c == '\n') {
    //Getting the likes string only
    if(likes = response.substring(response.indexOf("Likes:")+6, response.indexOf("::"))) {
      //Filtering some unneeded strings
      if((strstr(likes.c_str(), "URL")) == NULL) {
        currentLikes = atol(likes.c_str());
        Serial.print(currentLikes);
        //Printing likes count on serial port
      }
      Serial.println();
    }
  }
}


texts: How to precisely control servo motor by changing duty cycle?

texts:
I developed a PWM using timer1,using arduino uno and digital output, and identified that when I send a wave with duration of 0.6ms in High level, the motor goes to 0º. If I send 2.1ms, it goes to 180º. I tried to make a relationship between these scales to send the angle and change the time period in order to achieve that angle and it did not work.

I would like to move with a precision of 1 degree, is that possible? Just adjusting the time period.

The model of the motor is mg996r.
Maybe I am missing something.

My code just generates an interrupt over 50 microsencods and I use this to set the frequency of 50Hz and the duty cycle in ms using digitalWrite associated with pin 9.

#include <TimerOne.h>

double t = 0.0;

double period = 0;

void setup()
{
  t = 0;
  Serial.begin(9600);

  pinMode(9, OUTPUT);
  Timer1.initialize(50);
  Timer1.attachInterrupt( timerIsr ); // attach the service routine here
}

void loop()
{
  // Main code loop
  // TODO: Put your regular (non-ISR) logic here
  if (Serial.available() > 0) {
    float grau = Serial.parseFloat();

    // receive data as angle
    if (grau > 180) grau = 180;
    if (grau < 0) grau = 0;

    // set period for that angle
    // relationship developed between angle and period in ms
    //set it to period
    period = (0.00833*grau + 0.6)*1E-3;
  }

}

/// --------------------------
/// Custom ISR Timer Routine
/// --------------------------
void timerIsr()
{
    t += 50E-6;
    if (t <= period) {
      digitalWrite(9, HIGH);
    }
    else if (t < 20E-3) { // periodo max de 20ms -> 50Hz
      digitalWrite(9, LOW);
    }
    else {
      t = 0;
    }
}

UPDATE:

I just got it working by creating a timer1 interrupt on CTC mode with a frequency of 100kHz and counting the necessary time to get increments (~ 10us each) of around 1 degree on my servo motor.

More info here.


texts: How to run my servo until an input is recieved?

texts:
I am VERY new to this so please excuse any silly questions.

I am trying to run an FS90 micro servo in a sweeping motion until I receive a certain value from my Adafruit TCS34725 colour sensor. I currently have my loop set that it checks the colour sensor red value using an if statement and then performs a single sweep and then checks again. Rinse Repeat. Is there a way I can get it to check the sensor and stop mid sweep if there is a red colour change?


texts:
I am having trouble trying to make servomotor and button work together. The button code here below works fine when alone in a separate code but when it is transferred to the code with the servomotor function in it, it doesn't work.

Is there anything I need to be wary of when integrating the button code here to the preexisting code?

#include <Servo.h> // Library required for the servomotor (Make sure to download)
#include <Button.h> // Library required for the microswitch (Make sure to download)

// Parameters for the experiment
// Note: 1000 is one second
char Experiment = 'Acclimatization';
char Bird_Name = 'birdname here';
int Frequency = 30 * 1000; // The motor moves every x seconds
int Frequency_Deviation = 5 * 1000; // There are x second deviations plus and minus from the frequency set above
int Duration = 3 * 1000;  // The food is uncovered for x seconds

int servoPin = 9; // Declare the servomotor pin (Can be varied from setup to setup)
Button button(7); // Declare the microswitch pin (Can be varied from setup to setup)

Servo Servo1;

void setup() {
   Servo1.attach(servoPin);
   //analogWrite(servoPin, 0);
   Serial.begin(9600);
   button.setDebounceTime(100); // set debounce time to 100 milliseconds
}

void loop(){
   // Get onset and offset times of when the bird arrives and leaves the perch
   button.loop();
   if(button.isPressed())
    Serial.println("OnsetTime");
   if(button.isReleased())
    Serial.println("OffsetTime");

   // Calculate the acclimatization parameters below
   delay(random(Frequency-Frequency_Deviation,Frequency+Frequency_Deviation)); // Calculates frequency (See paramaters above)
   Servo1.write(0); // Starts from 0 degrees
   delay(Duration); // Duration that the food is uncovered (See parameters above)
   Servo1.write(75); // Goes to the x degrees
}


texts: How can I easily see which COM port is used by Arduino?

texts:
I'm rather disappointed because I just bought arduino and I am unable to upload any projects. The error I get is:

avrdude: ser_open(): can't open device "\\.\COM3": Časový limit semaforu vypršel.

Can be translated as:

avrdude: ser_open(): can't open device "\\.\COM3": Semaphore time out

Am I expected to brute-force all available ports to see which one is reserved for arduino? How can I, on Windows 7, quickly determine which port to use given that the IDE for some reason can't do that for me.


texts:
I have a HC-06 bluetooth module. The module has an RX and TX pin (the RX pin receives data and TX transmits data) which connect to the TX and RX pin of an Arduino respectively (in my case an Arduino pro mini).

My question is in what scenario would someone use the RX pin of the module(basically for what purpose would the bluetooth module receive a signal from the Arduino)?

For example let's say i have a simple LED that i turn off and on. I just sent the signal from my phone to the module and the module sends the signal to the Arduino. So basically i've connected the TX pin of the module (which transmits the data) with the RX pin of the Arduino (which receives the data).

In order to connect the RX pin of the module with the TX pin of the Arduino i have to use a voltage divider as the module only accepts 3.3 volts of signal while the Arduino transmits 5 volts of signal. I want to avoid that because in my project i need the PCB to be quite small.

So if someone only wants to transmit data from the module to the Arduino, is there a reason on why would he connect the other two pins?


texts:
I am very new to Arduino. I want to add about 50 sensors to Arduino R3. I get good readings from 3 sensors, but when I connect 4th one, I get 'No devices found'.

Here is a diagram:

and here is the code I use:

#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
#define TEMPERATURE_PRECISION 8
#define BAUD_RATE 9600

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// arrays to hold device addresses
DeviceAddress devices[10];
int devicesFound = 0;

void setup(void)
{
  // start serial port
  Serial.begin(BAUD_RATE);

  sensors.begin();

  devicesFound = sensors.getDeviceCount();

  // locate devices on the bus
  Serial.print("Locating devices...");
  Serial.print("Found ");
  Serial.print(devicesFound, DEC);
  Serial.println(" devices.");

  // report parasite power requirements
  Serial.print("Parasite power is: ");
  if (sensors.isParasitePowerMode()) Serial.println("ON");
  else Serial.println("OFF");

  for (int i = 0; i < devicesFound; i++)
    if (!sensors.getAddress(devices[i], i))
      Serial.println("Unable to find address for Device" + i);

  // show the addresses we found on the bus
  for (int i = 0; i < devicesFound; i++)
  {
    Serial.print("Device " + (String)i + " Address: ");
    printAddress(devices[i]);
    Serial.println();
  }

  for (int i = 0; i < devicesFound; i++)
    sensors.setResolution(devices[i], TEMPERATURE_PRECISION);
}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    // zero pad the address if necessary
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}

// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC < 10)
    Serial.print("0");

  Serial.print(tempC);
}

// function to print a device's resolution
void printResolution(DeviceAddress deviceAddress)
{
  Serial.print("Resolution: ");
  Serial.print(sensors.getResolution(deviceAddress));
  Serial.println();
}

// main function to print information about a device
void printData(DeviceAddress deviceAddress)
{
  Serial.print("Device Address: ");
  printAddress(deviceAddress);
  Serial.print(" ");
  printTemperature(deviceAddress);
  Serial.println();
}

void loop(void)
{
  if (devicesFound == 0)
  {
     Serial.println("No devices found.");
     return;
  }

  int start=millis();
  sensors.requestTemperatures();

  // print the device information
  for (int i = 0; i < devicesFound; i++)
  {
    printTemperature(devices[i]);
    if (i != devicesFound - 1)
      Serial.print(" ");
  }

  Serial.println();

  Serial.print(millis() - start);
  Serial.println(" ms passed.");
}

The resistor I use is 4.7 kΩ. What should I change to get good readings? And is it a problem to get reading from about 50 sensors?

UPDATE

So after a few trials, I managed to get readings for 18 sensors. I managed to have a mixed topology. What I did is I added close to sensors I didn't get reading a resistor (mainly 4.7k, but also few 100, 1k). At the moment I get occasionally -127 reading from some sensors, but I think I will fix that with CRC check in the program. Thanks for your help! –


texts:
In .ino file I have a class defined (called IPmonitoring).Also, inside the same .ino file, I call a .h file ( which is located "above" class IPmonotoring).
When I try to call members of IPmonitoring inside .h file - I get an error, which usually I solve using extern, but seemingly it is not the same for classes.
What should be done ?
Guy


texts: "avrdude: stk500_getsync(): not in sync: resp=0x00," aka Some Dude Named Avr Won't Let Me Upload My Program

texts:
I made an awesome program the other day, and I wanted to upload it to my Arduino. After clicking the upload button, some mean dude named avr came along and stopped me, saying:

  avrdude: stk500_getsync(): not in sync: resp=0x00

All I want to do is just upload my program, but avr won't let me. He's even unintelligible, so can someone tell me what the heck he's trying to say and how to get rid of him?

i.e.:

Whenever I try to upload a program to my Arduino, I get this error message:

  avrdude: stk500_getsync(): not in sync: resp=0x00

What does this mean, and how can I fix it?


texts: Arduino Geeetech Voice Module - CoolTerm not responding to commands

texts:
I am trying to use a Geeetech Voice Recognition Module to connect with the computer, along with a CP2102 USB to TTL module; but unfortunately, when I send any string, CoolTerm does not respond to it at all (No return messages on the terminal). I am using usbmodem1411 (normally for Arduino Uno) serial port to control and record my commands.

(Geeetech Voice module has four outlets: GND, RXD, TXD, VCC)
[USB module has five different outlets: 3V3, TXD, RXD, GND, +5V]2


texts:
I was testing my RGB (common anode) on its own playing with colours and got the red, green to work as desired.

However, when I connected my LCD board to my Arduino Uno as well as the RGB (using the same code prior and same output pins so I know the code isn't the issue) the RGB no longer displays red.

I assume it has something to do with the fluctuating voltage/current after I've put in the LCD but I cant work out how to resolve it. When its meant to be red it's just nothing, doesn't light up, green however still works.

#include <LiquidCrystal.h>
#define COMMON_ANODE
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int SelectCounter = 0;
int hours = 0; // start hours
int minutes = 0; //start min
int seconds = 5; //start seconds
int redPin = A1;
int greenPin = 2;
int bluePin = 3;
int digitposition = 0;
int readkey;
int speaker = A5;
int buttonPin = A4;
int buttonPushCounter = 0;   // counter for the number of button presses
int buttonState = 0;         // current state of the button
int lastButtonState = 0;

void setup() {
pinMode(speaker, OUTPUT);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(buttonPin, INPUT);
Serial.begin(9600);
}

void loop() {
noTone(speaker);
setColor(0, 0, 255); // red

....... }

void trigger() {
  lcd.clear(); // clears the screen and buffer
 lcd.setCursor(6,0);
 lcd.println("MUM:      ");
 lcd.setCursor(4, 1); // set timer position on lcd for end.
 lcd.println("WAKE UP!    ");
 tone(speaker, 10);
 setColor(0, 255, 0);  // green
 delay(500);
 digitalWrite(A1, HIGH);
 digitalWrite(2, HIGH);
 digitalWrite(3, HIGH);
 noTone(speaker);
 delay(500);
 lcd.display();
 }

void setColor(int red, int green, int blue)
{
  #ifdef COMMON_ANODE
   red = 255 - red;
   green = 255 - green;
   blue = 255 - blue;
 #endif
  analogWrite(redPin, red);
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue);
}