texts: Arduino is detected by the software, but uploading is impossible

texts:
I'm using a Geekcreit UNO arduino clone which worked fine for a long time and now suddenly, it stopped working. The builtin LED and the power LED are on, all pins provide 5V and wenn I try to upload a sketch, the "Uploading..." message displayed for very long until I got this error message:

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xc7
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xc7
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xc7
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xc7
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xc7
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xc7
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xc7
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xc7
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xc7
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xc7
Problem uploading to board.  See
http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

I think it broke while it was inside the project. I'm pretty sure it's a hardware problem because my other Arduino still works

EDIT: The same happened to another of my arduinos, it was a Genuine UNO.
It has to be a problem with the board itself because I can still upload sketches to other arduinos fine.


texts:
I am a beginner in Arduino.I want to connect 2 motors to Arduino.
Do I require a motor shield?And if yes please tell why?
Also can i use an amplifier to increase the voltage for the motors?

And one last important question, I have just seen the motor shield's pic. Does it restrict arduino's pin usage? I mean we can't use the arduino pins if we use the motor shield right?

PS: I am talking about this model: SLAEX039 L293D Motor Shield

Thank a lot


texts:
I have a buffer which contains 16000 PCM samples of 8Khz 8-bit mono. I am trying to play it using 12 bit MCP4725 DAC. I have tried using micros() to control the write interval for the DAC. Here's my code:

uint8_t soundData[16000] = { 234,206,79,255,249,....,210,222 }; // 8Khz 8-bit mono
long previousMicros = 0; // Sorry for missing this out!!

void setup() {

Serial.begin(115200);
Wire.begin(D2, D1);
delay(100); // delay 100 ms
Serial.flush();
delay(1000);

}

void value_write(uint16_t temp){

  Wire.beginTransmission(0x62);
  Wire.write(64);
  Wire.write(temp >> 4);        // the 8 most significant bits...
  Wire.write((temp & 15) << 4); // the 4 least significant bits...
  Wire.endTransmission();

}

void loop() {

  unsigned long currentMicros = micros();

// 125 uS sampling for 8KHz signal
if(currentMicros - previousMicros > 125) {
  Serial.print("Index: ");
  Serial.println(indx);
  uint16_t temp = map(soundData[indx++], 0, 255, 0, 4095);

  value_write(temp);
}

}

The write should logically be completed within 2 seconds but takes way more time. Any help regarding successfully writing the PCM values to the DAC at 8000Hz is greatly appreciated.


texts: Releasing gas from a bottle via Arduino - opening a valve?

texts:
I'm looking for a mechanical component that enables me to do two things:

contain a gas in a bottle and if opened, the gas should smoothly flow out (with the same pressure as a child blowing out candles on his birthday cake)
a valve for the bottle that can be opened by an Arduino when powered via USB

I already figured out that there are outlets for CO2 capsules. This could work, but then I'd need to figure out a way to decrease the pressure in order to receive a gentle gas flow.

Do you know any better approaches? Thanks in advance!


texts: Getting Trouble in multiple ST7789 SPI LCDs (without CS) with ESP32

texts:
I am developing a product in which i have to use 5 LCDs. The LCD i am using does not contain CS pin. SO i had to use MUX for muxing of complete SPI bus from one LCD to other.
But the issue i am facing is, LCD turn off display when i change the select lines of MUX to switch the SPI bus to other LCD. sometimes it just show white screen. basically switching the MUX put the LCD in trouble.
what i am thinking is that when i switch the BUS from one LCD to other then MUX may generate some random data during switching or something like that.
so there is any way the before switching, i should put lcd in a mode that it should not update display until i send any special command again ?
All pins except RST are going through mux, i used separate GPIO for RST of every LCD so that RST should not have issues during switching.
Library i am using is TFT_eSPI.h
Basically library do not support mulitple LCDs, so i customized it by just making global variable for reset pin, when i switch the mux to specific LCD then i change the values of RST to corresponding LCD.
My LCD link is
https://megaeshop.pk/1-3-inch-ips-hd-tft-st7789-ic-unit-240-240-spi-communication-3-3v-voltage-spi-interface-full-color-lcd-oled-display.html
Controller is ESP32
MUX 74HC4051
purpose of using LCD without CS is related to pricing issues. LCDs with CS are too expensive.
I am sorry if my Question formating is not correct or i missed any information. pleas feel free to ask.
I think on all the forums and articles, this is first time i am using multiple LCDs without CS :)


texts:
I am working with an Arduino Due and the Analog ADXL345 through a module following this tutorial, with the wire.h library at Fast Speed (400kHz), the Accelerometer Sampling at 800Hz (for the Maximum Reccomended Limit), and the Serial Monitor at 115200 bps.

The cable is 24AWG solid wire, 6in length, two pairs, for 3.3V, GND, SCL and SDA pins.

When the accelerometer is starting up, it generates a high pitched noise is generated!. Possibly by the 5V-3.3V regulator or by the accelerometer itself.

Under 400kHz|800Hz, the readings are unstable: by simply touching some open terminals in the Due, the Accelerometers readings toggle between strong oscillations and the correct ones (Figure 1).

After some "taps", the oscillations stops and the proper measures can be captured at the expected sampling rate (Figure 2). Note the mean values are modified for plotting only.

What should I do to prevent such behavior?, and what is causing that, considering the device is indeed working at the expected speed?


texts: Send multiple int values from Python to Arduino using pySerial

texts:
I'm trying to send 3 ints in the range of 0-180 from Python to the Arduino Uno device using pySerial (py3K). I have managed to send 1 int by using python's struct lib (not sure if it's the best or fastest way but it works).

However I'm failing to send more than 1 and every example online seems to stop at 1.

Here's the simplified code. The task is to send servo0-servo4 to the Arduino and apply those values to the corresponding servos.

Python Code

import serial
import struct
import time

bge.arduino = serial.Serial('/dev/ttyACM0', 9600)

# let it initialize
time.sleep(2)

# send the first int in binary format
bge.arduino.write(struct.pack('>B', 45))

Arduino code

#include <Servo.h>
Servo servo0;
Servo servo1;
Servo servo2;

void setup(){
  Serial.begin(9600);
  servo0.attach(3);
  servo1.attach(5);
  servo2.attach(6);
}

void loop(){
  if(Serial.available()){
    int message = Serial.read();
    // control the servo
    servo0.write(message);
  }
}


texts:
I'm trying to build this Midi2CV (control voltage for analog synths) using a Arduino Nano:

https://photos.app.goo.gl/3IhhFL3PrLELLODB3

I was hoping to use this Nokia screen too for settings and debugging purposes, but I just realized there's only one hardware serial port on 328p and software serial seemed to be doomed for MIDI:

SoftwareSerial too slow for MIDI?

So I have three peripherals:

DAC (MCP4822)
Nokia 5110 screen
MIDI

I've gotten both the DAC and screen to work fine on normal pins so I'm thinking I'm good with just using the hardware serial for MIDI and the DAC and screen can use software. Or am I in for a world of pain without getting a more powerful chip with more hardware serial ports? And if so, what's the recommendation? (shoestring budget)


texts:
I'm trying to add some additional example files to the Arduino IDE in Ubuntu 14.04. However, I can't for the life of me find where the examples are stored in my system. I checked the Arduino website, but can't find any information there. Does anyone know where I need to put my additional files?

EDIT: I found the location at /usr/share/arduino/examples


texts: Serial: What is different between Gammon's RS485 (blocking) and RS485 "non blocking" libraries?

texts:
The RS485 master-slave communication library on Nick Gammon's page http://www.gammon.com.au/Arduino/RS485_protocol.zip is working for me OK, but on the same hardware wiring is not working for the non-blocking library http://www.gammon.com.au/Arduino/RS485_non_blocking.zip.

I can not find information about the connection of MAX485 on Arduino for non-block version. Is MAX485/RS485 from HW serial (ie Rx=0 and Tx=1)?

If so, how can a slave on the same line at the same time receive from master the message "hello world" and print it to the serial monitor?
Thank you for the explanation.

When I added the SoftwareSerial library into Nick's example for non-blocking, so it works, but is it still a non-blocking?

//Master:
#include <RS485_non_blocking.h>
#include <SoftwareSerial.h>
const byte ENABLE_PIN = 4;
SoftwareSerial mySerial(2,3); //RX = 2 TX = 3

size_t fWrite (const byte what) {
  return mySerial.write (what);
}

RS485 myChannel (NULL, NULL, fWrite, 0);

void setup () {
  Serial.begin (9600);
  mySerial.begin (28800);
  myChannel.begin ();

  pinMode (ENABLE_PIN, OUTPUT);  // driver output enable
}  // end of setup

const byte msg [] = "Hello world";

void loop () {
  digitalWrite (ENABLE_PIN, HIGH);  // enable sending
  myChannel.sendMsg (msg, sizeof (msg));
  digitalWrite (ENABLE_PIN, LOW);  // disable sending
  delay (1000);
}  // end of loop

//Slave:
#include <RS485_non_blocking.h>
#include <SoftwareSerial.h>
const byte ENABLE_PIN = 4;
SoftwareSerial mySerial(2,3); //RX = 2 TX = 3

int fAvailable () {
  return mySerial.available ();
}

int fRead() {
  return mySerial.read ();
}

RS485 myChannel (fRead, fAvailable, NULL, 20);

void setup() {
  Serial.begin(9600);
  mySerial.begin(28800);
  myChannel.begin();
  pinMode (ENABLE_PIN, OUTPUT);  // driver output enable
}  // end of setup

void loop() {
  if (myChannel.update()) {
    Serial.write (myChannel.getData(), myChannel.getLength());
    Serial.println();
  }
}  // end of loop

Regards, Vava
(Sorry for my English... :-)


texts:
I need some help. I use function rx_setup()  оf library VirtualWire.h which is used to transmit information wirelessly. The function use timer аnd there is  conflict with any of the other libraries. Does anyone know how I can change the timer, which uses function?

This is the function:

void vw_setup(uint16_t speed)
{
    uint16_t nticks; // number of prescaled ticks needed
    uint8_t prescaler; // Bit values for CS0[2:0]

#ifdef __AVR_ATtiny85__
    // figure out prescaler value and counter match value
    prescaler = _timer_calc(speed, (uint8_t)-1, &nticks);
    if (!prescaler)
    {
        return; // fault
    }

    TCCR0A = 0;
    TCCR0A = _BV(WGM01); // Turn on CTC mode / Output Compare pins disconnected

    // convert prescaler index to TCCRnB prescaler bits CS00, CS01, CS02
    TCCR0B = 0;
    TCCR0B = prescaler; // set CS00, CS01, CS02 (other bits not needed)

    // Number of ticks to count before firing interrupt
    OCR0A = uint8_t(nticks);

    // Set mask to fire interrupt when OCF0A bit is set in TIFR0
    TIMSK |= _BV(OCIE0A);

#elif defined(__arm__) && defined(CORE_TEENSY)
    // on Teensy 3.0 (32 bit ARM), use an interval timer
    IntervalTimer *t = new IntervalTimer();
    t->begin(TIMER1_COMPA_vect, 125000.0 / (float)(speed));

#else // ARDUINO
    // This is the path for most Arduinos
    // figure out prescaler value and counter match value
    prescaler = _timer_calc(speed, (uint16_t)-1, &nticks);
    if (!prescaler)
    {
        return; // fault
    }

    TCCR1A = 0; // Output Compare pins disconnected
    TCCR1B = _BV(WGM12); // Turn on CTC mode

    // convert prescaler index to TCCRnB prescaler bits CS10, CS11, CS12
    TCCR1B |= prescaler;

    // Caution: special procedures for setting 16 bit regs
    // is handled by the compiler
    OCR1A = nticks;
    // Enable interrupt
#ifdef TIMSK1
    // atmega168
    TIMSK1 |= _BV(OCIE1A);
#else
    // others
    TIMSK |= _BV(OCIE1A);
#endif // TIMSK1

#endif // __AVR_ATtiny85__

    // Set up digital IO pins
    pinMode(vw_tx_pin, OUTPUT);
    pinMode(vw_rx_pin, INPUT);
    pinMode(vw_ptt_pin, OUTPUT);
    digitalWrite(vw_ptt_pin, vw_ptt_inverted);
}

#endif // ARDUINO

// Start the transmitter, call when the tx buffer is ready to go and vw_tx_len is
// set to the total number of symbols to send


texts:
For my project I have to measure a  signal of the order of few microvolts.
As we know the least an Arduino can measure is ~5mV, due to its 10bit ADC and 5V reference voltage.

A solution to this problem can be to use an external ADC (16bit, I think will do).

Can you please guide me on this problem.Is it possible to use a external ADC,if yes how should I.Any other simple solution ?
Thank You

Anupam


texts: Reading Multiple RFID tags / Reading and ignoring/holding the tag

texts:
I'm currently doing a project where ideally I will have multiple objects with RFID tags on them that are placed on top of a Adafruit PN532 RFID Shield connected to a Arduino Uno Wifi Rev 2. The idea is that once a button is pressed the RFID reader will read a Mifare tag then "ignore" it then reads the next tag until all are read. How can I acheive this?

I have read some about Anti-collision protocols and the limitations of RFID but was also wondering if it might be possible to read a tag then hold or ignore that tag until it leaves the range of the RFID shield?

I've also read a user on the Adafruit forums had some luck by altering the library that is used, I'll link it for reference, but I've tried the same method but had no luck myself. Adafruit-PN532 Library

I'm new to Arduino so I apologise if I've messed anything out.

Thanks for any help!


texts:
I have two Arduino Yuns that are not accessible at all on the network. I can't go to the arduinoname.local, ssh arduinoname.local, as I previously could. I know at least one it working because it sends emails as I programmed it, yet it seems there is no longer a way to ssh into it. Any ideas?

Yes, I have unplugged, plugged in the router,  and the yuns.


texts: How to use AT+CFTRANTX command in SIM7100

texts:
I am working on a project using pro mini 8MHz/3.3v and SIM7100, I want to know how can I used AT+CFTRANTX command. I am try to read file from EFS and write to SD card via Serial port. I have get some data in SD but is junk.

My board is Arduino Pro Mini (ATMega 328) 8MHz/3.3 V datasheet (DEV-11114) and Modem is home-made board with SIM7100 module, already test board and module work with all functions without any problem. I’ve added a schematic of the board to the question.

Here is SIM7100 Schematic

Here is SD Module, Pro Mini and SIM7100 pin layout

c:\data2.txt is: A1 to F0

A1A2A3A4A5A6A7A8A9A0B1B2B3B4B5B6B7B8B9B0C1C2C3C4C5C6C7C8C9C0D1D2D3D4D5D6D7D8D9D0E1E2E3E4E5E6E7E8E9E0F1F2F3F4F5F6F7F8F9F0

Any help would be appropriated.

The code that I am using, I tried it with every possible baud rate:

#include <SPI.h>
#include <SD.h>
#include <SoftwareSerial.h>
SoftwareSerial simSerial(7, 6);
File myFile;

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

  simSerial.begin(9600);
  Serial.print("\nInitializing SD card...");

  if (!SD.begin(10)) {
    Serial.println("\nInitialization failed!");
    while (1);
  }
  Serial.println("\nInitialization done.");
  delay(8000); //For booting SIM7100
  if (SD.exists("1.TXT")) SD.remove("1.TXT");

  myFile = SD.open("1.txt", FILE_WRITE);
  if (myFile) {
    simSerial.println("AT+CFTRANTX=\"c:/data.txt\"");
    while (simSerial.available() > 0) {
      byte voc = simSerial.read();
      myFile.write(voc);
    }
    myFile.close();
    // Serial.println("\nClose done.");
  } else {
    // Serial.println("Error opening 1.txt");
  }

  // re-open the file for reading:
  myFile = SD.open("1.txt");
  if (myFile) {
    Serial.println("1.txt:");
    while (myFile.available()) {
      Serial.print(myFile.read());
    }
    myFile.close();
    Serial.println("\nReading SD Card done.");
  } else {
    Serial.println("Error opening 1.txt");
  }

}

void loop() {

}

Here is test sketch for software & hardware serial.

SoftwareSerial mySerial(7,6); // RX, TX

void setup()
{
  Serial.begin(9600);
  while (!Serial) {
    ;
  }
  Serial.println("Hardware Serial port!");
  mySerial.begin(9600);
  mySerial.println("AT+CFTRANTX=\"c:/data.txt\"");
}

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


texts: Will a transistor always reduce the voltage?

texts:
I have an NPN transistor that's connected over a 12V adapter. I have tried using a potentiometer to change the resistance of the incomming current. Even if i take the resistance down to 0, I end up with at most 11 Volts when measuring over the magnet.

I have measure the energy without the transistor, in that case it's 12V. Is this expected behaviour of a transistor or is something wrong?


texts: How to power Arduino Uno from L298N motor driver's 5v terminal?

texts:
I am trying to setup L298N motor driver controller with my Arduino. Different online schematics about how to connect them are mostly similar - but they differ in powering the Arduino from the drive controller's 5v pin.
I am connecting 7.5v to the Vin and Gnd to the motor driver controller screw terminal , and I wish the power the Arduino from the 5v screw terminal. Since I am planning to use the 5v screw terminal as output I am choosing to leave the 5v jumper on.
Here are 3 of the schematics I've found online,

Source Homemade-circuits:

This is what I was expecting to see. But from Arduino Uno Rev3 Faq,
Vin -- The input voltage to the Arduino board when it's using an external power source (as opposed to 5
volts from the USB connection or other regulated power source). You can supply voltage through this pin,
or, if supplying voltage via the power jack, access it through this pin.

5V -- This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power
either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the board (7-12V).
Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don't advise it.

This one looks wrong to me. I am under the assumption that Vin pin is expecting 7-12V because it's connected to voltage regulator which will cause a 2v drop. Which mean I should not connect 5v from the motor controller to Vin - making this schematic incorrect. Is my analysis correct? Here is an answer that says I can not use the 5v pin to power an Arduino since it an input pin and not an output pin.

Source teachmemicro:

This one looks ok to me since the 5v source at motor controller is a regulated source and that's what exactly Arduino is expecting on 5v pin based on aforementioned FAQ. Can I implement is safely?

Source Instructables:

I do not know if it's correct or not. Notice that the 5v screw terminal is not connected to Arduino in any way. Is it setup going to work? I am wondering where the Arduino is getting its power from?
I am wondering which schematic should I follow. I am hesitant to hook up my L298N motor driver and Arduino without without understanding why each schematic is choosing to power the Arduino differently.


texts:
I'm working on Python and nodeMCU with websocket connection.
So, I send a string from Python to nodeMCU and nodeMCU collects the string and decodes to set values to a stepper motor. Initial code worked fine before updating with stepper motor code. Now it triggers watchdog resets.
Here's my full code:-
#include <ESP8266WiFi.h>
#include <ESPAsyncWebServer.h>
#include <AccelStepper.h>

// Define stepper motor connections and motor interface type. Motor interface type must be set to 1 when using a driver:
#define dirPin 8  // clk+
#define stepPin 9  // cw+
#define motorInterfaceType 1

AccelStepper stepper = AccelStepper(motorInterfaceType, stepPin, dirPin);

const char ssid[] PROGMEM ="PencoNetwork2";    //change it to your wifi SSID
const char password[] PROGMEM ="Penco1234567890";    //change it to your wifi password

AsyncWebServer server(80);
AsyncWebSocket ws("/test");

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

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi..");
  }

  Serial.println(WiFi.localIP());

  ws.onEvent(onWsEvent);
  server.addHandler(&ws);

  server.begin();

}

void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len){

  if(type == WS_EVT_CONNECT){

    Serial.println("Websocket client connection received");

  } else if(type == WS_EVT_DISCONNECT){
    Serial.println("Client disconnected");

  } else if(type == WS_EVT_DATA){

    Serial.println("Data received: ");

    for(int i=0; i < len; i++) {
//          Serial.print((char) data[i]);
           String data_String = (String) data[i];

          int commaIndex = data_String.indexOf(',');
          int secondCommaIndex = data_String.indexOf(',', commaIndex+1);
          String firstValue = data_String.substring(0, commaIndex);
          String secondValue = data_String.substring(commaIndex+1, secondCommaIndex);
          String thirdValue = data_String.substring(secondCommaIndex+1); //To the end of the string

          int mDist = firstValue.toInt();
          int mspeed = secondValue.toInt();
          int mAccel = thirdValue.toInt();

          stepper.setMaxSpeed(mspeed);
          stepper.setAcceleration(mAccel);

          stepper.moveTo(mDist);
          stepper.runToPosition();
          delay(1000);
          stepper.moveTo(0);
          stepper.runToPosition();
          delay(1000);

    }

//    Serial.println();
  }
}

void loop(){

  }

It would be a great help pointing out my mistakes.


texts: If else statement not mutually exclusive?

texts:
When I'm running some test on my encoder motors using the following provided code by Makeblock, it appears that the if..else.. statement is not mutually exclusive ie. I can control Encoder_1 and Encoder_2 at the same time. How come?

case ENCODER_BOARD:
      if(port == 0)
      {
        uint8_t slot = readBuffer(7);
        int16_t speed_value = readShort(8);
        speed_value = -speed_value;`

        if(slot == SLOT_1)
        {
          Encoder_1.setTarPWM(speed_value);
        }
        else if(slot == SLOT_2)
        {
          Encoder_2.setTarPWM(speed_value);
        }
        else if(slot == SLOT_3)
        {
          Encoder_3.setTarPWM(speed_value);
        }
        else if(slot == SLOT_4)
        {
          Encoder_4.setTarPWM(speed_value);
        }
      }

int16_t readShort(int16_t idx)
{
  valShort.byteVal[0] = readBuffer(idx);
  valShort.byteVal[1] = readBuffer(idx+1);
  return valShort.shortVal;
}

uint8_t readBuffer(int16_t index)
{
  if(BluetoothSource == DATA_SERIAL)
  {
    return buffer[index];
  }
  else if(BluetoothSource == DATA_SERIAL2)
  {
    return bufferBt1[index];
  }
  else if(BluetoothSource == DATA_SERIAL3)
  {
    return bufferBt2[index];
  }
}

All the code are taken from here and I am not the owner. I myself still studying how these whole code works. I am hoping someone out there who have experience with these kind of implementations be able to help me out.


texts:
I am new to electronics and I'm having a problem when creating my project. I have created a Bluetooth controlled rover using HC-06, Dual H-bridge motor driver and 4 DC motors.
However, only two of the DC Motors are moving and the other two remain still.

Could you please suggest what happened?

Attached is the wiring of the motors and code.

char t;

void setup() {
  pinMode(9,OUTPUT);
  pinMode(10,OUTPUT);
  pinMode(11,OUTPUT);
  pinMode(12,OUTPUT);
  Serial.begin(9600);
}

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

  if(t == '1') {
    digitalWrite(9,HIGH);
    digitalWrite(10,LOW);
    digitalWrite(11,HIGH);
    digitalWrite(12,LOW);
  }

  else if(t == '2') {
    digitalWrite(9,LOW);
    digitalWrite(10,HIGH);
    digitalWrite(11,LOW);
    digitalWrite(12,HIGH);
  }

  else if(t == '3') {
    digitalWrite(9,LOW);
    digitalWrite(10,LOW);
    digitalWrite(11,HIGH);
    digitalWrite(12,LOW);
  }

  else if(t == '4'){
    digitalWrite(9,HIGH);
    digitalWrite(10,LOW);
    digitalWrite(11,LOW);
    digitalWrite(12,LOW);
  }

  else if(t == '5') {
    digitalWrite(9,LOW);
    digitalWrite(10,LOW);
    digitalWrite(11,LOW);
    digitalWrite(12,LOW);
  }

  delay(100);
}


texts: Could I use an Arduino to power run the following lights? Here I have a project in mind, and although I am new to electronics, I am a computer programmer (C, C++, C#, Java) by profession so the coding side doesn't worry me, what I am confused about is what power supply I need etc.


texts:
I want to assign -1 to count variable again when count == 16 but when I have assigned -1 inside the if condition I have marked below in the code, the Arduino restarts.

Can anyone guess what is wrong here?

#include <LiquidCrystal.h>
#include <avr/pgmspace.h>
#include <hid.h>
#include <hiduniversal.h>
#include <usbhub.h>
#include <Usb.h>
#include <usbhub.h>
#include <avr/pgmspace.h>
#include <hidboot.h>
#include <SPI.h>
#define DISPLAY_WIDTH 16

// initialize the LCD library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

USB     Usb;
USBHub     Hub(&Usb);
HIDUniversal Hid(&Usb);
HIDBoot<HID_PROTOCOL_KEYBOARD>    Keyboard(&Usb);

int count = -1;
char drawNo[4];
int m = 0;
int turn;
class KbdRptParser : public KeyboardReportParser {
    void PrintKey(uint8_t mod, uint8_t key);
protected:
    virtual void OnKeyDown(uint8_t mod, uint8_t key);
    virtual void OnKeyPressed(uint8_t key);
};

void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key) {
    uint8_t c = OemToAscii(mod, key);
    count++;

    if (c)
    { OnKeyPressed(c); }
}

/* what to do when symbol arrives */
void KbdRptParser::OnKeyPressed(uint8_t key) {
    static uint32_t next_time = 0;      //watchdog
    static uint8_t current_cursor = 0;  //tracks current cursor position

    if (millis() > next_time) {
        lcd.clear();
        current_cursor = 0;
        delay(5);    //LCD-specific
        lcd.setCursor(0, 0);
    }//if( millis() > next_time ...

    next_time = millis() + 200;  //reset watchdog

    if (current_cursor++ == (DISPLAY_WIDTH + 1)) {    //switch to second line if cursor outside the screen
        lcd.setCursor(0, 1);
    }

    int keys = (int) key;

    if (count == 4 | count == 5 | count == 6 | count == 7) {
        turn++;
        drawNo[m] = (char)keys;
        //lcd.print(drawNo[m]);
        Serial.print(drawNo[m]);
        Serial.print(m);
        ++m;
    }

    if (count == 16) {
        Serial.println("Counter equals 16 NOW");
        printScreen();
        delay(200);
        count = -1; /* <<<<<<<<<<<<<<<<<<<<<<<<<<<<Here is the problem*/

        for (int i = 0; i < sizeof(drawNo);  i++) {
            drawNo[i] = (char)0;
        }
    }
}
void printScreen() {
    int j;
    lcd.print(" DRAW NO : ");

    for (j = 0; j < 4; j++) {
        lcd.print(drawNo[j]);
    }
}
KbdRptParser Prs;

void setup() {
    Serial.begin(115200);
    Serial.println("Start");

    if (Usb.Init() == -1) {
        Serial.println("OSC did not start.");
    }

    delay(200);
    Hid.SetReportParser(0, (HIDReportParser *)&Prs);
    // set up the LCD's number of columns and rows:
    lcd.begin(DISPLAY_WIDTH, 2);
    lcd.clear();
    lcd.noAutoscroll();
    lcd.print("Scan Your Code");
    delay(200);
}

void loop() {
    Usb.Task();
}


texts: Installing MariaMole (Alternative IDE) on Mac

texts: I've heard about a alternative Arduino IDE called MariaMole and really liked the idea, but I just don't know how to install it on Mac OS X. The GitHub page claims that it is compatible with Mac but I just can't find a tutorial, or instructions, as to how the Git files can be compiled on Mac.


texts: Shared 5v power for Due dedicated application

texts:
I would appreciate input on this situation:

I plan to power a fairly high current, 5 volt supply, 3.3v signal, device from a suitable wall wart. I would like to power the due that controls it through the due's usb port by tapping the 5v from the wall wart into a suitably modified USB cable (leaving the signal pins unused). No significant external power demands would be made on the due's 3.3v or 5v headers.

So there are two devices sharing the wall wart: one device that uses high current, and the other device is the due.


texts: Protecting variables and functions within a library that has no class

texts:
If you want to have functions within a library that only the library itself should be able to use or variables that shouldn't be accessed from outside, you usually make them private by writing this in the header file:

class Lib{
  public:
    // All these can be accessed from outside
    void function1();
    void function2();
    int someNumber;
  private:
    // These two can't be accessed from outside
    void secretFunction();
    int secretNumber;
};

My question is this:

I want to write this library without using classes. How do I protect things from being accessed from anywhere in this case?


texts:
I was wondering if it was possible to use the utp port of a computer/laptop to transmit and receive data to an external device?

If you take a cat5 cable there are 8 wires, so lets say you have an Arduino would it be possible to use those wires for serial communication? If so how can I program the utp port? And is there a specification for this (for example use wire x for output and wire y for input..)

Thanks in advance,
Regards

Ps: I had no idea on which sub.stackexchange to ask it hopefully it suits here.


texts: Optical Incremental Encoder Reading using Arduino UNO

texts:
I have a HP Optical Incremental Encoder (256 CPR) in which

Pin 1 = A,
Pin 2 = VCC,
Pin 3 = GND,
Pin 8 = B.

I already read and see tutorials for rotary encoder such this one:
https://playground.arduino.cc/Main/RotaryEncoders

I have written a program that is supposed to print out the position of my encoder, however I am only getting zeros in my serial monitor. I want to be able to use interrupts. I would like to actually return the position in degrees of my encoder as we rotate it.

I was able to get it to work. I wasn't connecting my pin properly to my Arduino.

    #include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

#define encoderPinA 2
#define encoderPinB 3
#define CPR 256
volatile int counter =0;
volatile boolean flag;

volatile int var_degrees =0;

void setup() {

  pinMode(encoderPinA, INPUT);
  pinMode(encoderPinB, INPUT);
  Serial.begin (9600);
  attachInterrupt(digitalPinToInterrupt(encoderPinA), isr, RISING);
  lcd.clear();

}

void loop() {

   if(flag == true){
        var_degrees = ((360/256.0)*counter);
        Serial.println(var_degrees);
        lcd.setCursor(0, 1);
        lcd.print("Degrees: ");
        lcd.setCursor(9, 1);
        lcd.print(var_degrees);
        flag = false;
  }

}
//Interrupts

void isr_2(){
flag = true;
  if(digitalRead(encoderPinA) == HIGH){
    if(digitalRead(encoderPinB) == LOW){
      counter = counter -1; //COUNTER CLOCK WISE
    }
    else{
      counter = counter +1; //CW
    }
  }
  else{
    if(digitalRead(encoderPinB) == LOW){
      counter = counter + 1; //CW
    }
    else{
      counter = counter - 1 ; //CCW
    }
  }
}


texts: upload real time ultrasonic sensor data to pubnub using arduino and esp8266

texts:
I want to upload the real time data of ultrasonic sensor attached to my Arduino  Uno and I have been using esp8266 module for the WiFi connection.

I want to upload to PubNub but I don't know how to start writing the code for PubNub and where do I have to write the code.

I have the code working on my Arduino using the ultrasonic sensor in C++ language, printing the readings on the serial monitor. However, the code will be definitely changed in order to upload the sensor readings to PubNub.

On PubNub the most used SDK is JavaScript and I'm not very familiar to it. For C++ the most used SDK is Posix but it seems way more difficult more than JavaScript. So how I have to translate the code from C++ to JavaScript to get it published on PubNub?

Sorry, I am completely new to this stuff therefore I don't know much about it.


texts: How can you reduce the clock frequency of an Arduino Mega?

texts:
I'm trying to debug a problem and need to reduce the speed of the clock on my Arduino Mega from 16MHz to 8MHz.

I can't find any simple way of doing so, so I wanted to know if there were any gurus here who knew if this was possible, as well as how to do it.

WITHOUT PRESCALER:

long int runTime;

void setup()
{
  Serial.begin(9600);     //Setting the data transfer rate
}

void loop()
{
  delay(1000);
  runTime = millis();
  Serial.print("Runetime: ");
  Serial.println(runTime);
  delay(100);
  exit(0);
}

OUTPUT: 999

WITH PRESCALER:

long int runTime;

void setup()
{
  Serial.begin(19200);   //Setting the data transfer rate for when CLK Freq. is Halfed

  CLKPR = _BV(CLKPCE);  // enable change of the clock prescaler
  CLKPR = _BV(CLKPS0);  // divide frequency by 2
}

void loop()
{
  delay(1000);
  runTime = millis();
  Serial.print("Runetime: ");
  Serial.println(runTime);
  delay(100);
  exit(0);
}

OUTPUT: 999


texts:
I've hooked up my Arduino on this LCD, and after running the following code, all I see is a row with black boxes and another one empty.

//LiquidCrystal d(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd(0, 1, 2, 3, 4, 5);

void setup() {
     lcd.begin(16, 2);
     lcd.print("hello, world!");
}

void loop() {
     lcd.print("hello, world!");
}

Wiring:

(The UTP cable is used just for the data lines :-)

Actual wiring photos: (sorry for the total klutz in the wiring, I had limited solid-core wires so I had to use these scrap ones)


texts:
I have been putting together a small robot using an Arduino Motor Shield R3. The shield has two sockets for motors, however the wheel carriage I bought has four motors. I tried putting both right side motors in one socket set, and the left side motors in the other socket set.

When I turn on the Arduino, the left side motors turn together according to how I coded the board, however the right side behaves differently.

One of the motors does not start. If I push it a little it will start turning. Though not always. When I plugged in the misbehaving motor by itself, it runs correctly.

I am wondering about cause of the problem here. Is it likely the second motor on the right side is faulty? Or am I trying to use up too much power and disrupting the current?


texts: Append Text to Variable Names: Please Help Me Shorten This Code

texts:
I'm trying to shorten the code under "setup" below, where I have over 120 variables that are being read from an external EEPROM. There is a pattern where the variable that stores the position of the EEPROM address is the name of the variable being populated, plus the word "Pos".

byte fanSpeed, nl1Toggle, ledsToggle;
byte fanSpeedPos = 12, nl1TogglePos = 95, ledsTogglePos = 7;

void setup() {
  fanSpeed = readEE(fanSpeedPos);
  nl1Toggle = readEE(nl1TogglePos);
  ledsToggle = readEE(ledsTogglePos);
  //there are over 120 of the above readEE statements in the actual code.
}

uint8_t readEE(uint8_t entry) {
  readEEPROM(AT24C32_ADDRESS, 1, entry);
}

Ideally I would like it to work like this (I'm using pseudo code because I don't know how to do this):

char* variableNames [] = { "fanSpeed", "nl1Toggle", "ledsToggle" };
byte fanSpeedPos = 12, nl1TogglePos = 95, ledsTogglePos = 7;

void setup() {
  for (int i = 1; i < 120; i++;) {
    variableNames[i] = readEE(variableNames[i] + 'Pos');
  }

Is this possible using C++ / Arduino?


texts: Udp.remoteIP() and Udp.remotePort() calls not working

texts:
I'm trying to conect an Intel Galileo over ethernet. I'm using the code located in Examples/Ethernet/UDPSendReceiveString. Everything works fine except for the response. Udp.remoteIP() always return 255.255.255.255 and Udp.remotePort() always return 0. If I set the IP and port manually instead everything works ok.

My host pc has a windows 10 OS.
I've also checked with wireshark that every ip and port is ok.

Arduino code:

#include <SPI.h>         // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h>         // UDP library from: bjoern@cs.stanford.edu 12/30/2008

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 1, 177);

unsigned int localPort = 8888;      // local port to listen on

// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE];  //buffer to hold incoming packet,
char  ReplyBuffer[] = "acknowledged";       // a string to send back

// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;

void setup() {
  // start the Ethernet and UDP:
  Ethernet.begin(mac, ip);
  Udp.begin(localPort);

  Serial.begin(9600);
}

void loop() {
  // if there's data available, read a packet
  int packetSize = Udp.parsePacket();
  if (packetSize) {
    Serial.print("Received packet of size ");
    Serial.println(packetSize);
    Serial.print("From ");
    IPAddress remote = Udp.remoteIP();
    for (int i = 0; i < 4; i++) {
      Serial.print(remote[i], DEC);
      if (i < 3) {
        Serial.print(".");
      }
    }
    Serial.print(", port ");
    Serial.println(Udp.remotePort());

    // read the packet into packetBufffer
    Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
    Serial.println("Contents:");
    Serial.println(packetBuffer);

    // send a reply to the IP address and port that sent us the packet we received
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort()); <- there is the fail
    Udp.write(ReplyBuffer);
    Udp.endPacket();
  }
  delay(10);
}

Processing code:

 // Processing UDP example to send and receive string data from Arduino
 // press any key to send the "Hello Arduino" message

 import hypermedia.net.*;

 UDP udp;  // define the UDP object

 void setup() {
     udp = new UDP( this, 6000 );  // create a new datagram connection on port 6000
     //udp.log( true );         // <-- printout the connection activity
     udp.listen( true );           // and wait for incoming message
 }

 void draw()
 {
 }

 void keyPressed() {
     String ip       = "192.168.1.177"; // the remote IP address
     int port        = 8888;        // the destination port

     udp.send("Hello World", ip, port );   // the message to send

 }

 void receive( byte[] data ) {          // <-- default handler
 //void receive( byte[] data, String ip, int port ) {   // <-- extended handler

     for(int i=0; i < data.length; i++)
         print(char(data[i]));
     println();
 }


texts: How to know which Arduino to choose: Nano, Micro or Pro Micro?

texts:
I'm puzzled at the moment with which one to choose.

Form-factor plays a significant role in my project, so I prefer the smaller boards mentioned in the title to fuller boards like the UNO, MEGA, etc.
I have an RC522 RFID read/write module and would like to use it without having to deal with level switching, as the RFID module requires 3.3V.

What can you advise?

Thank you in advance!


texts: How can I use Methods in digitalWrite(): digitalWrite(int, "methodHere")?

texts:
When creating a piece of code to operate a 7-segment display, I ran into a problem:

The seven segment display on TinkerCad (I was using this at the time) requires you to pull down the inputs to turn a segment on, while the one that I have turns on when I pull up the inputs.

Instead of completely rewriting the code for the display that I had, I wanted to make my code more universal for if I need to use it in the future.

I cannot find a way to make the method digitalWrite(int pin, int val) work with a method that returns and int in the place of "int val"

This is the code that will not work:

int F = 11;
int G = 10;
int E = 9;
int D = 8;
int C = 7;
int DP = 6;
int B = 5;
int A = 4;
int type = 1;

 int highLow(int highOrLow)
{

  int digOutput;

  if(type = 1)
  {

    if(highOrLow = 1)
    {

      digOutput = 1;

    }
    if( highOrLow = 0)
    {

      digOutput = 0;

    }

  }
  if(type = 0)
  {

    if(highOrLow = 0)
    {

       digOutput = 0;

    }
    if( highOrLow = 2)
    {

      digOutput = 1;

    }

  }
  return digOutput;
}

void zero()
{
  digitalWrite(F, highLow(0));
  digitalWrite(G, HIGH);
  digitalWrite(E, LOW);
  digitalWrite(D, LOW);
  digitalWrite(C, LOW);
  digitalWrite(DP, HIGH);
  digitalWrite(B, LOW);
  digitalWrite(A, LOW);
}

setup
{
pinMode(F, OUTPUT);
pinMode(G, OUTPUT);
pinMode(E, OUTPUT);
pinMode(D, OUTPUT);
pinMode(C, OUTPUT);
pinMode(DP, OUTPUT);
pinMode(B, OUTPUT);
pinMode(A, OUTPUT);
zero();
}

Note : I am just using pin f to test.

Also, my etiquette is not very well defined or tested, so please keep it rather simple if you can.

If it matters, I am going to be using to using an Arduino Mega2560 produced by Elegoo.

Thanks for any help!!


texts: Is it possible to use the same power source for the arduino and a high current

texts:
I've need to control some leds which draw 300mA with an arduino (actually an atmega) and after some searching I think the following is the circuit I need, but I'm not really sure if the power source for the LEDs can be the same as for the arduino.
R1 = 1k


texts:
Im connecting a servo to my Arduino Uno Rev.3. The general recommendation is to put a 7V -12V power supply for servos as far as I understand. However I’d like to combine it with an USB to a computer since I use it to flush data from a different probe on the Arduino to my PC.

Will it be safe to use both a AC/DC adapter and serial bus?
Will it use the USB for power draw even if adapter is connected?


texts:
I am using the following code to enable an interrupt for a pin:

*digitalPinToPCMSK(pin) |= bit (digitalPinToPCMSKbit(pin));  // enable pin
PCIFR  |= bit (digitalPinToPCICRbit(pin)); // clear any outstanding interrupt
PCICR  |= bit (digitalPinToPCICRbit(pin)); // enable interrupt for the group

But I can't disable it. I am trying with this code:

if (*digitalPinToPCMSK(pin) == 0)
*digitalPinToPCICR(pin) &= ~(1<<digitalPinToPCICRbit(pin));

but it isn't working.


texts:
My Due is interfaces with a DAC which I need to update with freq 1MHz. The nice solution seems to be a timer interrupt. I found a thread here called "Arduino Due - creating an 8Mhz clock signal". I tried the following code to see if I can get 4MHz on P41. No luck. Any help will be greatly appreciated. Thanks.

volatile boolean l = false;

void TC6_Handler()
{
    TC_GetStatus(TC2, 0);
    digitalWrite(41, l = !l);
}

void startTimer(Tc *tc, uint32_t channel, IRQn_Type irq) {
    pmc_set_writeprotect(false);
    pmc_enable_periph_clk((uint32_t)irq);

    TC_Configure(tc, channel,
    TC_CMR_WAVE |
    TC_CMR_WAVSEL_UP_RC |
    TC_CMR_TCCLKS_TIMER_CLOCK1|
    TC_CMR_ACPA_TOGGLE );  // RC compare TOGGLES TIOA);

    TC_SetRA(tc, channel, 1); //50% high, 50% low
    TC_SetRC(tc, channel, 1);

    PIO_Configure(PIOC,
    PIO_PERIPH_B,
    PIO_PC25B_TIOA6,
    PIO_DEFAULT);

TC_Start(tc, channel);

}

void setup(){
pinMode(41,OUTPUT);
startTimer(TC2, 0, TC6_IRQn);
}

void loop(){
}


texts:
I made a smart blind stick for my class project. It uses an ultrasonic sensor to detect obstacles and I was asked this question in VIVA...

Why is it necessary for giving a digital high for 10 μS on the trigger (Trig) pin of an ultrasonic sensor ?

Why 10 μS only?

I changed it to 5 μS then to 20 μS and to 50 μS and it still works fine! Why so?


texts: Scope error in arduino PinChangeInt library

texts:
#include<PinChangeInt.h>
#define SensorPin 2

int ledPin = 10;
int BuzzerPin = 12;
volatile byte blip = 0;

void blipcount(){
  blip++;
};

void setup() {
   // put your setup code here, to run once:
   pinMode(SensorPin,INPUT);
   pinMode(ledPin,OUTPUT);
   pinMode(BuzzerPin,OUTPUT);
   PCintPort::attachInterrupt(SensorPin,blipCount,FALLING);
   Serial.begin(9600);
}

void loop() {
   // put your main code here, to run repeatedly:
   if(digitalRead(SensorPin)==HIGH){
      digitalWrite(ledPin,HIGH);
      digitalWrite(BuzzerPin,HIGH);
      Serial.print("blipcoun:\t");
      Serial.println(blip,DEC);
   }

   if(digitalRead(SensorPin)==LOW){
      digitalWrite(ledPin,LOW);
      digitalWrite(BuzzerPin,LOW);
   }
}

I am using arduino uno for a project.I need to record when my sensor gives a high value but i need it to read only falls in pulses.The program is giving  error as

Arduino: 1.6.3 (Windows 8.1), Board: "Arduino Uno"

Sense.ino: In function 'void setup()':

Sense.ino:14:38: error: 'blipCount' was not declared in this scope

Error compiling

please tell me what is the problem with the function.

The library link is
https://code.google.com/p/arduino-pinchangeint/downloads/list

tested the code on both 1.72 and 2.19


texts: Can multiple Arduinos be connected to a single relay?

texts:
I have a 16 channel relay that will basically manage 16 different contacts. However, each channel in the relay needs to be controlled by an individual Arduino. So in total I would have 16 different Arduino boards that will each control a single channel in the relay. Is this possible? If so, how do I make the conenctions?
 I tried it earlier using several arduinos and connecting their ground wires together but did not seem to work, the relays remained energized. I am using the SAINSMART 16-Channel 12V Relay Module


texts:
I'm using a RedBear Duo to read the Serial writes from a RedBear Nano v2. Basically, I use a digital pin of the Duo to raise an interrupt on the Nano. Once, the nano catches the interrupt it writes on its Serial.

You can find a minimum working example below:

RedBear Duo

#include <Wire.h>

/*BLE and WiFi setup*/
#if defined(ARDUINO)
SYSTEM_MODE(MANUAL);
#endif

char incomingByte;   // for incoming serial data

void setup() {
    Serial1.begin(115200);     // opens serial port, sets data rate to 9600 bps
    delay(500);
    Serial1.println("Begin!");
    Serial2.begin(115200);

    pinMode(D5, OUTPUT);
}

void readSerial() {
    while (Serial2.available() > 0) {
        incomingByte = Serial2.read();
        Serial1.print(incomingByte);
    }
    Serial1.println(" ");

}

void loop() {
    digitalWrite(D5, HIGH);
    readSerial();
    delay(2);     // Here's the delay I'm talking about
    digitalWrite(D5, LOW);
    delay(1000);
}

RedBear Nano

uint8_t fire;
void task_handle(void) {
    fire = 1;
}

void setup() {
    Serial.begin(115200);
    fire = 0;
    pinMode(D4, INPUT);
    attachInterrupt(D4, task_handle, RISING);
}

void loop() {
    if (fire == 1) {
        fire = 0;
        Serial.write("hello ");
        // Serial.println("fire");
        digitalWrite(D13, HIGH);
    }
    delay(150);
}

I found this question (https://electronics.stackexchange.com/questions/28739/arduino-delay-of-1ms-necessary-between-serial-read-and-serial-write), and I understood that the problem might be the fact that it takes a while to empty the Serial buffer.

However, I tried to bring the baudrate at 500000 (more than 3x) and still if I change the delay to delay(1), the code is not printing what it has received on the Serial.

I'm trying to understand what is really going on and why I need this delay(2).

Thanks a lot in advance!


texts:
I'm currently working with some WS2812B LEDs and tried out adding a capacitor to be safe from voltage spikes (was recommended by Adafruit). I noticed that a soon as I connect a capacitor between 5V and ground that the USB is disconnect from the PC (Windows Usb disconnect sound plays). I wondered why and tried another setup. This time just the capacitor between 5V and ground. Nothing else. According to my knownledge this isn't a short (capacitor is intact) and therefor this setup should be valid. Again the same thing happens: USB disconnects...

I really don't know why this happens but want to understand it. The capacitor I use is rated 16V 1000 mF (electrolytic in case this is relevant). The capacitor is also connected the right polarity. What forces the USB to disconnect (and let Windows play the USB disconnect sound). Am I may damaging the USB Port somehow and therefor a disconnect is forced as a security measurement?

Oh yeah... Using an Arduino Uno R3 made by Elegoo.

Hope you can help me out,
Tmirror


texts: How to connect Arduino 5v pin with multiple things?

texts:
I am trying to connect a Bluetooth module and a gas sensor to Arduino.

Bluetooth module: HM-10
Gas sensor: MQ-2

I read the guides for the HM-10 and MQ-2 and they both need to use the Arduino's 5v pin. I did a lot of searching but I could not find a proper example.

I would like you to give me a link to an example that uses the 5v pin for multiple modules. It would be nice if the circuit configuration was included.


texts:
I need to communicate between two Arduinos using XBee. I am new to XBee and hardware. The two Arduino Unos need to send a message (number) to each other and light an LED or play a sound, when they come close within a 10 meter distance.

So my doubt is which XBee shield and XBee module I need to purchase. I read about XBee series 2, XB24 etc.


texts:
I have the following code in which requestLine is always empty and I can't figure out why. request contains a raw HTTP request, and I want to get the first line of the request which contains the method and the URL.

boolean parseRequest(String* request)
{
  int firstEOLAt = request->indexOf('\n');
  if (firstEOLAt < 0)
    return false;
  Serial.println(firstEOLAt);
  String requestLine = request->substring(0, firstEOLAt);
  Serial.println(requestLine);
  // ...rest of the parsing will go here...
  return true;
}

The first println returns 26 as you would expect for the string "GET /ilyen_nincs HTTP/1.1" (25 characters long), but then requestLine is always empty. I wonder why?


texts: Newbie Using Brown Out detector on Arduino Due for saving variables to eeprom?

texts:
Hi I'm a newbie and working on a project with Arduino Due(Atmel3X8E).I want to try and save the important variables to the eeprom during a power outage,using the brown out detector.Is it possible to do this?
Thank you.


texts:
I'm  having a small problem with my soil moisture sensor

it gives me weird readings, in the second the smallest connection is made between the legs it just gives me 4096 (which is max possible value), its either about 0 or 4095

I can't really seem to see the problem, any help is appreciated

(the output voltage is read on an ESP32, almost visible in the bottom of the image)


texts: Opening and closing a hatch with different switches

texts:
I'm new to the whole Arduino thing and I'm not much of a programmer myself so I need some help...

The goal is to have 4 buttons which a person who operates it gives out different outputs from the motor connected too a hatch. The relays are connected to a hatchmotor with limit switches at both closed and fully opened positions.

My idea is like this:

button1 = activates relay 1->opens the hatch,
button2 = activates relay 2->closes the hatch,
button3 = endless loop, opens and closes the hatch,
button4 = deactivated both relay 1 and 2, and stops the loop.

My code so far:

const byte knappstangd(4); //limit switch, closed position
const byte knappoppen(5); //limit switch, open position
const byte brytareoppnalucka(6); //momentary switch for opening hatch
const byte brytarestangalucka(7); //momentary switch for closing hatch
const byte startaloop(8); //momentary switch for starting the "loop"
const byte stoppaloop(9); //momentary switch for stopping the loop.

const byte relastanga = 2; //activates relay 1 which closes the hatch
const byte relaoppna = 12; //activates relay 2 which opens the hatch

void setup()
{
    pinMode (knappstangd,INPUT);
    pinMode (knappoppen,INPUT);
    pinMode (brytareoppnalucka,INPUT);
    pinMode (brytarestangalucka,INPUT);
    pinMode (startaloop,INPUT);
    pinMode (stoppaloop,INPUT);

    pinMode (relastanga, OUTPUT);
    pinMode (relaoppna, OUTPUT);
}

void loop()
{
    if(digitalRead(brytareoppnalucka)==HIGH){       //if momentary switch brytareoppnalucka = 1 do this:
        digitalWrite (relaoppna, HIGH);             //open hatch
    }

    if(digitalRead(brytarestangalucka)==HIGH) {     //if momentary switchå brytarestangaluckan = 1 do this:
        digitalWrite (relastanga, HIGH);            //close hatch
    }

    if(digitalRead(stoppaloop)==HIGH) {             //if momentary switch stoppaloop=1 do this:
        digitalWrite (relaoppna, LOW);              //turn off relay for opening
        digitalWrite (relastanga, LOW);             //turn off relay for closing

        if(digitalRead(startaloop)==HIGH) {         //if momentary switch startaloop=1 do this:
            digitalWrite(relastanga, HIGH);         //start with closing the hatch to set a zero point

            if(digitalRead(knappstangd)==HIGH) {    //if limit switch knappstangd=1 do this:
                digitalWrite (relastanga, LOW);     //turn off Relay for closing
                delay (200);                        //wait 0,2 seconds
                digitalWrite (relaoppna, HIGH);     //turn on relay for opening
            }
            if(digitalRead(knappoppen)==HIGH) {     //if limit switch knappoppen=1 do this:
                digitalWrite (relaoppna, LOW);      //turn off relay for opening
                delay (200);                        //wait 0,2 seconds
                digitalWrite (relastanga, HIGH);    //turn on relay for closing
            }
        }
    }
}


texts: Arduino Ground Current and DC power jack

texts:
I have a project where I'm providing power via the DC jack to my Arduino then accessing the DC power via the VIN pin. According to this http://forum.arduino.cc/index.php?topic=453955.0 I am ok to draw up to 1A from the VIN pin. I have measured 400ma out of VIN, so ok on that front.

But according to this http://playground.arduino.cc/Main/ArduinoPinCurrentLimitations I can draw max 400ma, So I'm a bit confused, which is the correct amount of power VIN can supply if the Arduino is being powered via the DC jack?

If I take the first thread as correct and assume it's ok to draw up to 1A from the VIN pin (from the DC power jack), is it ok to ground that current on the Arduino GND pin ? if VIN can supply up to 1A then I assume that it's ok to ground up to 1A, is this correct?

All help appreciated


texts: Transfer a struct's data to an external struct via serial?

texts:
Using two boards of similar architecture I would like to send the contents of a struct from the sending board to the receiving board. I am using UART to transfer.

My plan was to populate an array with the starting structs data. Transfer that, than un-package the array onto the receiving boards struct.

I'm not sure this is a possible option. Unpacking the array seems sort of rigid, as I would be assigning each struct variable to the array index. It might work but I'm not really convinced I should do it this way.

Here's what my sending sketch looks like.

Send:

typedef struct NWK_DataReq_t
{
 uint8_t      state;
 uint8_t      options;
} NWK_DataReq_t;

//Instance struct
NWK_DataReq_t dataRequest;

void setup()
{
  //Give it some values
  dataRequest.state = 2;
  dataRequest.options = 4;

  Serial.begin(9600);
}

void loop()
{
  //set variable array to struct length
  uint8_t payload[sizeof(dataRequest)];

  //copy struct to variable array
  memcpy(payload,&dataRequest,sizeof(dataRequest));

  //send each item of struct, now contained in payload array
  for(int i=0;i < sizeof(payload);i++)
  {
    //Serial.print(i);
    //Serial.print(":");
    Serial.println(payload[i]);
  }

  Serial.println("");
  delay(1000);
}

Receive:

typedef struct NWK_DataReq_t
{
 uint8_t      state;
 uint8_t      options;
} NWK_DataReq_t;

//Instance struct
NWK_DataReq_t dataRequest;
uint8_t incomingPayload[sizeof(dataRequest)];

void setup()
{
  Serial.begin(9600);
  Serial.print("Recieve started");
}

void loop()
{

  if (Serial.available())
  {
    //add incoming data to array
    for(int i=0;i<sizeof(dataRequest);i++)
    {
      uint8_t incomingByte = Serial.read();
      incomingPayload[i] = incomingByte;
    }
  }

  //set array values to structs
  for (int i= 0;i < sizeof(dataRequest);i++)
  {
    structIndexPosition = incomingPayload[i];
  }
}

structIndexPosition is not attached as I wasn't sure how I might index the struct, or if this is an okay approach.


texts: Arduino Nano 3.0 and Arduino Uno Benchmarks

texts: What are the benchmarks (MIPS) of an Arduino Uno (ATmega32P) and Arduino Nano 3.0 (Atmega328) @ 1.6MHz?


texts: can an ISR change the value passed by pointer while the subroutine is executing?

texts:
So I am working on a project where the board plays a song on a buzzer using PWM and I want the song to stop when i press an external button

typedef enum stateType_enum{
waitPress, debouncePress, waitRelease, debounceRelease
} stateType;
volatile stateType state = waitPress;
volatile bool deviceOn = false;

int main(void){
   sei();
   while(1) {

   switch(state){
     case waitPress:
       break;
     case debouncePress:
       delayMs(100);
       state = waitRelease;
       break;
     case waitRelease:
       break;
     case debounceRelease:
       delayMs(100);
       state = waitPress;
       break;
   }

   if(deviceOn){
       triggerAlarm(&deviceOn);
   }
   _delay_ms(100);
}

ISR(PCINT0_vect){
   if(state == waitPress){
      state = debouncePress;
   }
   else if (state == waitRelease){
      deviceOn = !deviceOn;
      state = debounceRelease;
   }
}

My real question is, can I send the deviceOn as a pointer to the song?


texts:
My program is running on ESP32. I'm retrieving some data from Bluetooth, and the Bluetooth string is a C string. I need to save that data in an RTC_DATA_ATTR String, which is a C++ string.

Just doing c++string = cstring.c_str(); won't work, since it will just save a pointer to the location in the memory of the C string, and the purpose is to save the data in the RTC memory, so the ESP32 can go to deep sleep without losing the data.

All other data than RTC gets wiped on deep sleep, so there would just be a pointer, pointing to nothing.

How do I get the data copied from the C string to the C++ string?

Any help would be appreciated. A bit of extra info: this is how it is set up at the moment:

RTC_DATA_ATTR String ssid;

BLECharacteristic *cSsid = NULL;

ssid = cSsid->getValue().c_str();


texts:
I am going to do a project with a lot of Arduinos connected via I2C, where like of them can became master for a moment to announce an event. So I would like to see how much is the bus used. As there will be a central point, I thought about putting a LED there, from +5V to clock line, so it would shine when the transfer occurs and be black when the line is free. And so I would be able to guess the utilisation level of the bus. (The clock is effectively PWM going to zero often while in transfer, while being plain +5V when no transfer is active).

Of course direct connection is not the best idea, as it would disrupt the pull-ups and mess with the protocol (as it would drain a lot of power to clock each time it went down), there should be some separator/amplifier.

The question is - does anybody know a simple setting, where the LED would be driven by a small current to zero (that is inverting amplifier as simple as possible with high enough input impedance to not disturb I2C communication)?

Thanks for all hints :)


texts: I was looking at arduino nano boards here. Description says the arduino board is without welding plate. What does it mean for the user? If I buy this product will there be any issue? I understand that this board does not come with two headers soldered and I am OK with that.


texts: Why is my transistor switched output so low?

texts:
Help needed! I am using an Arduino Nano and a general purpose npn (2n2222a) transistor to provide a 12v signal to a low current 12vdc load in an automobile. The Arudino code is set to pulse D2 at bootup/startup for .5 second. The PWM output setting was 255 (since switched to digitalWrite). However, the switched output measures only 4.5v (expected close to 12v). What am i doing wrong?
Applying 12v+ directly to the black box works. The purpose is to simulate a temporary button push in the car so an auto function is enabled.


texts:
I’m a hobbyist and have used Arduino so far for simple projects. Now I want to build a project involving addressable LEDs, I want to write several programs on the Arduino for the LEDs and on my phone I select which ones to run.

I found ESP8266 as a good and cheap solution to talk to my Arduino. Searching on the web to learn getting it to work I found that It has its own mcu on it and I can write and upload my code in Arduino IDE! 20kB of RAM, 80MHz CPU and 4MB of flash for 3 USD (However I’m not sure of these numbers but even one fourth of it is great)!! If I just need a few GPIOs why should use an Arduino UNO? Is this module reliable?


texts: Can I program a factory fresh Atmega328P through UART pins without burning a bootloader?

texts:
Can I program a factory fresh ATMega328P using the UART pins without burning a bootloader? These pins are TX, RX, VCC, GND, and DTR pins in the schematic below. They are not the ISP/SPI pins 10-13.

Arduino Pro Mini schematic

For example, if you program an Arduino Pro Mini (which requires an ICSP programmer) with a programmer, you're not connected to the ISP pins (basically the SPI interface: MOSI, MISO, SCLK, SS), but rather to the serial i/o and reset pins.

My understanding is that a bootloader is required if you want to program through these pins, because the Arduino bootloader looks for UART traffic at these pins upon startup and hands off operation to the user's code if no attempt at programming happens during this time.

That said, I also understand burning a bootloader is done through the ISP/SPI pins, and my PCB is already manufactured, which makes burning a boatloader somewhat of a hassle. So...

Can I program an ATMega328P through the UART pins fresh off the reel, or will I need rig up a way to burn a bootloader through the ISP pins first?


texts: Sending sine wave from MATLAB and reading on Arduino Uno

texts:
I am working on timing issues associated with sampling data at high rates and storing it on an SD card (ADC delays, clock drifts and file I/O time). For this experiment, I thought of sending a sinusoidal wave to an analog pin on the Arduino Uno, and have the board read the samples. Can I eliminate the need for a function generator and instead use the Matlab Support Package for Arduino to send the sinusoid to the Arduino? (I guess this would mean two programs simultaneously, a Matlab program for generation of a sinusoid and an Arduino sketch for reading and writing.)
I'm new to Matlab, so any help would be greatly appreciated.


texts: How to send two different sets of int numbers over serial?

texts:
I have a project that require for the main computer to do most of the processing then for it to send the X and Y coordinates of this processing to the arduino. This at the time didn't seem very hard but now that I have started to dive into serial some more I am completely confused. All of the example I have seen for serial only consist of 1 set of numbers and rather confusing.

The Arduino code I kinda want to go like this
http://pastebin.com/aLJfEExw (I know this is probably completely wrong but I am pretty lost right now)

The Python code is this right now
http://pastebin.com/4aN4dnSC

If you guys could help explain this better for me it would be amazing. I understand that my code is probably wrong. So if you guys could provide an example of how to send the two different sets of int's it would be amazing. Because I am completely and utterly lost.


texts: keypad storing problem (void value not ignored as it ought to be)

texts:
I am trying to input 11 numbers only by the use of keypad but the problem is whenever i use this code. It gave me this error.

Here's my code. Help please.

#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
SoftwareSerial mySerial(6, 5);
int table[] = { 0, 0, 0 };
#include <Keypad.h>
#include <Wire.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns

char keys[ROWS][COLS] = {
    { '1', '2', '3' },
    { '4', '5', '6' },
    { '7', '8', '9' },
    { '*', '0', '#' }
};
byte rowPins[ROWS] = { 2, 3, 17, 16 }; //connect to the row pinouts of the keypad
byte colPins[COLS] = { 15, 14, 13 }; //connect to the column pinouts of the keypad
int count = 0;
Keypad kpd = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
char entryStr[13]; // This can hold up to 4 digits
int i = 0;
char n1, n2, n3;
char buf[15]; // i put here***
void setup()
{
    Wire.begin();
    Serial.begin(9600);
    Serial.begin(9600);
    lcd.begin(20, 4);
    ask();
}

void loop()
{
    Wire.requestFrom(2, 3); // request 6 bytes from slave device #2 for(int i=0;i<3;i++) {

    int c = Wire.read(); // receive a byte as character
    Serial.print(c);
    table[i] = c;
    Serial.print('\t');
    // print the character } Serial.print('\n'); Serial.print(table[0]); Serial.print('\t'); Serial.print(table1); Serial.print('\t'); Serial.print(table[2]); Serial.print('\n');

    //if(table[0]<=8) //{ //Serial.print("Flame Detected!"); //Serial.println("Level1");
}
void ask()
{

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Enter no1.:");
    lcd.setCursor(0, 1);
    lcd.print("(starts with 0)");
    lcd.setCursor(1, 2);
    n1 = GetNumber(buf, sizeof(buf) - 1);

    Serial.print(n1);

    delay(1);

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Enter no2.:");
    lcd.setCursor(0, 1);
    lcd.print("(starts with 0)");
    lcd.setCursor(1, 2);
    n2 = GetNumber(buf, sizeof(buf) - 1);

    Serial.println(n2);
    delay(1);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Enter no3.:");
    lcd.setCursor(0, 1);
    lcd.print("(starts with 0)");
    lcd.setCursor(1, 2);
    n3 = GetNumber(buf, sizeof(buf) - 1);

    Serial.println(n3);
    delay(1);
    Serial.println(n1);
    Serial.println(n2);
    Serial.println(n3);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("list of numbers ");
    lcd.setCursor(0, 1);
    lcd.print("will be shown press");
    lcd.setCursor(1, 2);
    lcd.print("reset if wrong");

    delay(7000);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Numbers Stored:");
    lcd.setCursor(0, 1);
    lcd.print("no1.:0");
    lcd.print(n1);
    lcd.setCursor(1, 2);
    lcd.print("no2.:0");
    lcd.print(n2);
    lcd.setCursor(2, 3);
    lcd.print("no3.:0");
    lcd.print(n3);
}
void GetNumber(char* result, const int maxLength)
{
    char key = kpd.getKey();
    int i = 0; // how far through buffer we are
    while (key != '#') {
        switch (key) {
        case NO_KEY:
            break;

        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':

            lcd.print(key);
            if (i < maxLength) {
                result[i++] = key;
                result[i] = 0; // terminating null
            }
            break;

        case '*': // backspace
            if (i > 0) {
                i--;
                result[i] = 0; // terminating null
            }

            break;
        }

        key = kpd.getKey();
    }

} // end of GetNumber


texts: Is it possible to infer the length of a neopixel string using 1-wire protocol?

texts:
I'have been looking at the AdaFruit NeoPixels recently and am trying to understand how the addressing scheme works.

All of the examples I've seen explicitly identify the length of the string (number of neopixel units) and are typically set using an array of 24-bit values to control the color of a particular neopixel.

My question is two fold:

How do the neopixels know where they are in a string to allow for addressing?
If the neopixels know where they are in the string, would it not be possible to potentially feed the output of the last neoxpixel back to a microcontroller to determine the number of neopixels in the string?

OP Note (this is my interpretation and may be suspect, but it is more or less my take away)

Thank you for all the answers on this - it has been very enlightening from ALL of the answers. General take away, the NeoPixel is not "directly" addressable in the sense that you can pick pixel "X" of "n" pixels. The string of NeoPixels acts essentially as a gigantic shift-register (as stated in one of the answers) so to "address" a particular pixel you have to update a buffer that represents the state of the entire string and then shift it down the wire. This is why micro-controllers, such as an Arduino, would have limitations on how many NeoPixels it could control. This is also why it is more practical to define the number of pixels in the string and allocate memory to represent that state.


texts:
My sketch contains 2 .h files. one defines
on 1st .h file:
#define JSON_SIZE_IOT 400
#define JSON_SIZE_SKETCH 300
StaticJsonDocument<JSON_SIZE_IOT> paramJSON;
StaticJsonDocument<JSON_SIZE_SKETCH> sketchJSON;

and other need to define paramJSON and sketchJSON as extern
on 2nd .h file:
extern JsonDocument paramJSON;
extern JsonDocument paramJSON;

but I get this error:
error: conflicting declaration 'ArduinoJson6172_91::StaticJsonDocument<400u> paramJSON'
 StaticJsonDocument<JSON_SIZE_IOT> paramJSON;

....
: previous declaration as 'ArduinoJson6172_91::JsonDocument paramJSON'
 extern JsonDocument paramJSON;


texts: Stepper Motor button control with A4988 Driver

texts:
So I'm quite new to programming and have inevitably worked myself into a corner. What I am trying to accomplish is to allow for a stepper motor, (powered by an A4988 driver) to move with the push of a button. The schematic is as follows:

And the code to try and make the motor move with a button is:

const int = buttonPin = 2;
const int = stepPin = 3;
const int = dirPin = 4;

int buttonState = 0;

void setup(){
    pinMode(stepPin,OUTPUT);
    pinMode(dirPin,OUTPUT);
    pinMode(buttonPin,INPUT);
}

void loop(){
    buttonState = digitalRead(buttonPin);

    if (buttonState = HIGH){
       digitalWrite(dirPin,HIGH);{
           digitalWrite(stepPin,HIGH);
           delayMicroseconds(500);
           digitalWrite(stepPin,LOW);
           delayMicroseconds(500);
           }
    }}

What am I doing wrong?


texts: Why does Serial.print print only a value for 0-84 for a 100 integer array?

texts:
int a[100],i;
void setup() {
  Serial.begin(9600);
}

void loop() {
  for(i=0; i<100; i++) {
    a[i] = i;
    Serial.println(a[i]);
  }
  exit(0);
}


texts:
I'm writing library for smart home arduino DIY project.
i want to use another library(not written by me).
here is the code:

boiler.cpp

#include "Boiler.h"

Boiler::Boiler(int pin)
{
    _pin = pin;
    dev.setDevice(_pin);                    // Set Device Output (on/off)
    turnOff();
}

boiler.h

#ifndef BOILER_H_
#define BOILER_H_

// include RF24 libs
#include "RF24.h"
#include "RF24Network.h"
#include "RF24Mesh.h"
#include <SPI.h>

// SmartHome Lib Includes
#include "Device.h"
#include "TimerOne.h"
#include "timeSet.h"

class Boiler
{

    private:

        RF24 radio(7, 8);
        RF24Network network(radio);
        RF24Mesh mesh(radio, network);

        int _pin ;

        void timerIsr();
        void DrawSCR();
    public:
        .
        .
        .

        Boiler (int pin );
        void turnOn();
        void turnOff();
};

The problem is it's not compiling
the error I get is :
Boiler.h: 32:14: error: expected identifier before numeric constant
RF24 radio(7, 8)

What am i doing wrong?
Thanks,


texts: How to read main code inside main code in Arduino?

texts:
How can I read the hex code of the main programme stored inside flash memory inside my running Arduino programme?

So far I am able to read the Flash at any given address by using PROGMEM

unsigned int displayInt;
int k;    // counter variable

void setup() {
  Serial.begin(9600);
  while (!Serial);  // wait for serial port to connect. Needed for native USB

  for(k = 0; k < 5; k++) {
    displayInt = pgm_read_word_near(k);
    Serial.println(displayInt);
  }
}

void loop() {
}

The output is

37900
13716
53
3072
37900

But this not hex code.

I am implementing the OTA (over the air) feature. I will get the new version of a code from GPRS. It will be huge code so I will write it to flash by using the custom bootloader mentioned in this thread. I am able to write to the flash memory. Now I would like to read the data from flash. To begin with I would like to read the main programme inside my main programme.


texts: ARDUINO UNO WIFI R3 (Dev Edition) Send simple http get request

texts:
I need send http request to my own server from arduino uno.

First of all I connected the board through web client configurator.

I tried different codes, the last one is:
    /*
    File: RestClient.ino
    This example makes an HTTP request after 10 seconds and shows the result both in
    serial monitor and in the wifi console of the Arduino Uno WiFi.

Note: works only with Arduino Uno WiFi Developer Edition.

http://www.arduino.org/learning/tutorials/boards-tutorials/restserver-and-restclient
*/

#include <Wire.h>
#include <UnoWiFiDevEd.h>

void setup() {

  const char* connector = "rest";
  const char* server = "<MY IP>";
  const char* method = "GET";
  const char* resource = "/";

  Serial.begin(9600);
  Serial.println("prima");
  Ciao.begin();
  Serial.println("dopo");

  pinMode(2, INPUT);

  //delay(1000);
  doRequest(connector, server, resource, method);
}

void loop() {

}

void doRequest(const char* conn, const char* server, const char* command, const char* method){
  Serial.println("Im doing the request");
  CiaoData data = Ciao.write(conn, server, command, method);
  if (!data.isEmpty()){
    Ciao.println( "State: " + String (data.get(1)) );
    Ciao.println( "Response: " + String (data.get(2)) );
    Serial.println( "State: " + String (data.get(1)) );
    Serial.println( "Response: " + String (data.get(2)) );
  }
  else{
    Ciao.println ("Write Error");
    Serial.println ("Write Error");
  }
}

But I get "Write Error" and the server does not recive any request


texts: Connecting an AB phase encoder motor to arduino

texts:
i'm trying to understand how to connect this motor:

"Mitsumi 334P/R AB"

Link to the motor i bought

connections are:

GND - Obvious.

5v - Obvious.

rest of the connections are a bit confusing to me and i do not want to fry my arduino trying.

do i need a driver or this looks like a built in one?
do i need to add any electrical components like resistors and capacitors ect?


texts:
Long time lurker, first time poster here.
Do the cheap Arduino Nano clones such as this one have external interrupt pins?
For example, the original Nano has pins 2 and 3 usable for interrupts. Do clones tend to incorporate this feature? If so, can anyone recommend one which does?
I'm planning on using an encoder for my next project and want to make sure I can use interrupts so my code doesn't skip over encoder counts.
Thank you!


texts:
Basic question: How far do I have to go to assure that integer math is done correctly? For example, this is probably overdone:

unsigned long burnTime = 0UL;
unsigned long curBurnTime = 0UL;
// Do some stuff that sets the above variables to millis() at various times
// Later on...
unsigned long adjustedBurnTime = (unsigned long) ((burnTime + curBurnTime) / 1000UL);

Would the math be done correctly if I went to a more minimal last statement (since all the elements of the equation are unsigned longs)? Like this:

unsigned long adjustedBurnTime = ((burnTime + curBurnTime) / 1000UL);

Or even:

unsigned long adjustedBurnTime = ((burnTime + curBurnTime) / 1000);


texts: Does arduino run AC or DC? Based on my small knowledge on the crystal in an arduino, it seems like AC makes sense. True? No?


texts: Arduino due - SAM-BA bootloader is it there even if you replace the original chip

texts:
On this page http://playground.arduino.cc/Bootloader/DueBootloaderExplained it mentions the sam-ba bootloader is permanently burned into the rom of the chip.

Does this mean even if I buy a new chip from Farnell, it will still have the bootloader in or is just ones that are specifically made for the arduino due?

That is different from say the mega328, with the mega328 I have to burn the bootloader on manually using isp programmer/ buy it preprogrammed.


texts:
I had fun making a 3x3x3 led cube. Now I want to build a bigger one. I'd like to find out the best IC for it. I've seen that some projects uses multiplexer like 4051 or 74HC595.

I'd like to make it at least 8x8x8 (so the multiplexer has to easily be spotted in cascade), possibly supporting also the pwm (to fade the leds).

And I'm a little bit scared by the real time with a lot of LED.. do I have to solve the problem in hardware (with a "faster" multiplexer) o via software?


texts:
i have a BGM113 bluetooth module that sends messages as binary form. I have to work on each bit separately. i am not sure about Serial.read() gets it as binary but when i am trying to see at on the serial port screen with Serial.println(Serial.read(), BIN) it shows me as string something like []...[]
What should i do ?


texts: Why is Wire.onReceive() called during requests?

texts:
I'm building a complex I2C-based networking protocol and have noticed that the Wire.onReceive() handler is called both for I2C read and write operations. When the master writes to the slave, it is called as you'd expect. But it also seems to be invoked when the master reads from the slave which is unexpected.

Ideally, I'd like a transaction with both a read and a write - e.g. the master writes a value (for instance a variable argument) and then reads back from the slave the result (for instance, the lookup of that variable.)

Compiled on the SAMD21 ArduinoCore, the following programs generate this result:

1400,700
>>> x is
<<< hello
>>>
>>> x is
<<< hello
>>>
1404,702
>>> x is

Showing that the onReceive is called twice as often as onRequest.

I don't see this behavior documented anywhere.

Master:

    #include

void setup()
{
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output
}

void loop()
{
  Wire.beginTransmission(4); // transmit to device #4
  Wire.write("foobar");        // sends five bytes
 // Wire.write(3);              // sends one byte
  Wire.endTransmission(true);    // stop transmitting

  Wire.requestFrom(4, 6);    // request 6 bytes from slave device #2

  while(Wire.available())    // slave may send less than requested
  {
    char c = Wire.read(); // receive a byte as character
    Serial.print(c);         // print the character
  }

  delay(500);
}

Slave

#include <Wire.h>

void setup()
{
  Wire.begin(4);                // join i2c bus with address #4
  Wire.onReceive(receiveEvent); // register event
  Wire.onRequest(requestEvent);
  Serial.begin(9600);           // start serial for output
}

long inCount = 0;
long outCount = 0;

void loop()
{
  char c[200];
  snprintf( c, 200, "%d,%d\n", inCount, outCount );
  Serial.print( c );
  delay(1000);

}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
inCount++;

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

  Serial.println();         // print the integer
}

// function that executes whenever data is requested by master
// this function is registered as an event, see setup()
void requestEvent()
{
  Serial.println( "<<< hello ");

  outCount++;
  Wire.write("hello "); // respond with message of 6 bytes
                       // as expected by master
}


texts: How to fetch the com port or any id I can use to upload specific program to a specific arduino? e.g. "a.ino" to arduino micro

texts:
My project is a head mouse for which I am using two arduino boards . I want to upload a specific program to a specific arduino. How can I do it? And if I need to use a pid or com port id about which the official arduino forum people suggested, how can I retrieve this id? I'm using an Arduino micro and a pro micro if it helps any.

I need some suggestion on how to load the sketch to arduino through code without actually opening the arduino ide directly.Because it's a client project. And how can I make a specific program upload to the specific arduino one at a time. e.g. "a.ino" to arduino micro and "b.ino" to arduino pro micro. How should I identify the arduino boards through code.As for the OS, I am using Windows 10 64 bit.


texts: Intercept Data being sent to XBee Module via UNO

texts:
An XBee Pro S1 module sits on a DIP socket on-board a Personal Weather Station (PWS) to transmit data.
Instead of letting the station transmit data wirelessly via the XBee, I would like to read that data off the socket pins on which it sits, via an Arduino UNO.

Is this possible? If so, what should I look into?
I am new to wireless communication with a µC, so any help would be appreciated.


texts:
I'm trying to flash pure c-code to arduino Mega2560 board from linux using avr-gcc & avrdude. Compilation is done , now trying to flash using avr-dude, getting error as "avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00"

I used below command to produce hex file

avr-gcc -mmcu=atmega2560 -DF_CPU=16000000UL led.c -o led.elf

In file included from led.c:3:0:
/usr/lib/avr/include/util/delay.h:95:3: warning: #warning "Compiler optimizations disabled; functions from  won't work as designed" [-Wcpp]
 # warning "Compiler optimizations disabled; functions from  won't work as designed"

And then

avr-objcopy -j .text -O ihex led.elf led.hex

finally for flashing

avrdude -F -V -c arduino -p ATMEGA2560 -P /dev/ttyACM3 -b 115200 -U flash:w:led.hex

FYI: port is correct & RX pin is blinking i.e connection is perfect between computer & board


texts: How to program a CAN-BUS Arduino shield to control car windows?

texts:
My project is to control car windows using voice recognition. I have successfully controlled some LEDs using the EasyVR Arduino shield using and Arduino MEGA. Now I want to take control of the windows using the CAN-BUS arduino shield.

Because the car that I own doesn't have an OBD-II connector, I am using two Arduinos with two CAN-BUS Arduino shields making one a sender and the other a receiver. How can I program the CAN-BUS Arduino shield to make a simulation of the car's windows?

CAN-BUS shield that I am using: https://www.sparkfun.com/products/10039

Arduino Mega: https://www.sparkfun.com/products/11061


texts: How to remote control Arduino using an old 2.4Ghz toy remote controller?

texts:
I have been wondering how to remote control my arduino robot using an old 2.4ghz car toy transmitter which has 4 buttons, up down left and right.
I have the nRF24L01(+) 2.4GHz transceiver to use it as a receiver.

Is there anyway to detect the signals going out from the remote controller and use them to make my arduino works,
I am a newbie so i am sorry if any mistake.

Thanks guys!


texts:
I have been trying to bootload a fresh ATmel328P-PU micro-controller with Arduino but it keeps on failing, giving this error:

avrdude: Device signature = 0xff00ff
avrdude: Expected signature for ATMEGA328P is 1E 95 0F
         Double check chip, or use -F to override this check.

The device signature keeps on changing every time I click the Burn Bootloader option.

I referred Arduino Official and Instructables.

Please help. How could I install the Arduino bootloader in a fresh ATmel328P-PU?

I hope someone has solved this already!


texts:
I'm trying use the NodeMCU WebSocket.

I downloaded the required libraries from:
https://github.com/Links2004/arduinoWebSockets
and pasted them in my Arduino libraries folder. I uploaded my code but got this error:

WebSocketsServer.h: No such file or directory.

Can you please tell me why my Arduino IDE won't find the WebSocketsServer.h header file when it is physically present in my Arduino libraries folder?   Or if there's an alternative way to use the NodeMCU WebSocket?

Here's the code:

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <WebSocketsServer.h>
#include <Hash.h>

// Replace with your network credentials
const char* ssid = "<WiFi-SSID>";
const char* password = "WiFi-PASSWORD";

WebSocketsServer webSocket = WebSocketsServer(81);
ESP8266WebServer server(80);   //instantiate server at port 80 (http port)

String page = "";
int LEDPin = D5;

void setup(void){
 //the HTML of the web page
 page = "
Simple NodeMCU Web Server

<button>ON</button>&nbsp;<button>OFF</button>
";
 //make the LED pin output and initially turned off
 pinMode(LEDPin, OUTPUT);
 digitalWrite(LEDPin, LOW);

 delay(1000);

 Serial.begin(115200);
 WiFi.begin(ssid, password); //begin WiFi connection
 Serial.println("");

 // Wait for connection
 while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
 }

 Serial.println("");
 Serial.print("Connected to ");
 Serial.println(ssid);
 Serial.print("IP address: ");
 Serial.println(WiFi.localIP());

 server.on("/", [](){
    server.send(200, "text/html", page);
 });

 server.on("/LEDOn", [](){
    server.send(200, "text/html", page);
    digitalWrite(LEDPin, HIGH);
    delay(1000);
 });

 server.on("/LEDOff", [](){
    server.send(200, "text/html", page);
    digitalWrite(LEDPin, LOW);
    delay(1000);
 });

 server.begin();
 webSocket.begin();
 webSocket.onEvent(webSocketEvent);

 Serial.println("Web server started!");
}

void loop(void){
  webSocket.loop();
  server.handleClient();
  if (Serial.available() > 0){
    char c[] = {(char)Serial.read()};
    webSocket.broadcastTXT(c, sizeof(c));
  }
}

void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length){
  if (type == WStype_TEXT){
   for(int i = 0; i < length; i++) Serial.print((char) payload[i]);
   Serial.println();
  }
}
~~~


texts:
I wrote a code to handle an ISR triggered by UART input. I'm looking for 2 characters or more. I can handle extra characters and garbage values, but problem arises when I get less than 2 chars, specially when an empty string is sent to the atmel. The UART_receive() on the atmel gets stuck at: while ( !(UCSR0A & (1<<RXC0)) );

Is there any way I can break out of this? The code is posted below:

unsigned char USART_Receive_string(unsigned char *x, unsigned char size)
{
unsigned char i = 0;

if (size == 0) return 0;            // return 0 if no space

while (i < size - 1) {              // check space is available (including additional null char at end)
    unsigned char c;
    while ( !(UCSR0A & (1<<RXC0)) );  // wait for another char - WARNING this will wait forever if nothing is received
    c = UDR0;
    if (c == '\0') break;           // break on NULL character
    x[i] = c;                       // write into the supplied buffer
    i++;
}
x[i] = 0;                           // ensure string is null terminated

return i + 1;                       // return number of characters written
}

The actual ISR in question is posted below. It reads the value, sets a flag, and exits as soon as possible.

ISR(USART_RX_vect)
{
    len = USART_Receive_string(uart_string,4); //makes space for 2 character and "\0"
    UART_flag = 1;
}

The the buffer is set up in main()

unsigned char uart_string[20];


texts:
I have written a little project, it works so far as it should but the for loop is only iterated once, then the result is displayed on the LCD.

#include <LiquidCrystal.h>
#include <stdlib.h>
const int Contrast=20;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int led = A5;
const int button = A3;

void setup() {
  Serial.begin(9600);
analogWrite(6,Contrast);
lcd.begin(16, 2);

pinMode(led, OUTPUT);
digitalWrite(led,LOW);
pinMode(button, INPUT_PULLUP);
}

void loop() {

unsigned long mittelwert = 0;

for(int i=0; i<10; i++){
  unsigned long r = random(1,5000);
  unsigned long now = millis();

  digitalWrite(led,HIGH);

  while (digitalRead(button) == HIGH){
    lcd.setCursor(0,0);
    lcd.print("druecken");
  }
  mittelwert = mittelwert + millis() - now;
  digitalWrite(led, LOW);  //LED aus

}

lcd.clear();
lcd.setCursor(0,0); //setze Cursor auf 1.Stelle in der 1. Zeile
lcd.print(mittelwert/1000);
lcd.setCursor(0,1);
lcd.print("Sekunden");

delay(5000);
lcd.clear();

}


texts:
Pipes and Channels...I realize this type of question has been asked to death but I have not yet found a clear answer...the project has 3 or more transmitters each capable of sending to any of the same 10 or so selected Receivers, but only one per transmitter.
As there are only 6 Pipes available, changing the pipe address will leave me short of the required Receiver quantity, so I was going to keep the Pipe addresses constant and change only the channel for each Receiver, selecting the required Transmit channel thru a menu on the Transmitter. Confirmation of data received is not critical so i will provably not look for it.
Is this a workable approach for this project. If the above is not clear, please ask specifics and i will try to answer.
Doug


texts: Can I turn a headset with a cord into a bluetooth headset with multiple connections?

texts:
I'd like to connect Arduino with bluetooth shield to multiple bluetooth devices (TV & baby monitor), plug a corded headset into the contraption, sprinkle LEDs on top, and do the following:

If there is a signal above certain threshold coming from the baby monitor listen to a mix of TV and baby monitor audio with LEDs blinking; otherwise listen only to TV audio.

Thus the questions:

Can bluetooth connect with multiple devices simultaneously?

What do I need to implement that?


texts: getting simple socketIO server to work with MRAA library on Edison

texts:
I spent the last week working with the CylonJS framework on my edison using a Maxbotix sensor.
Everyting works with a web client on the front end.
However at the last moment I can't get the edison to talk to an existing AIR client which I must use.
Something to do with how socketIO is implemented in Cylon.

The following simple socketIO server works for me. What I need to do is incorporate support for the mraa library and get analogue input from the Maxbotix sensor.

Can anyone please help? I'm up against a deadline!!!

var express = require('express');
    var app = express();
    var server = require('http').createServer(app);
    var io = require('socket.io').listen(server,{transports:['flashsocket', 'websocket', 'htmlfile', 'xhr-polling', 'jsonp-polling']});
     var port = Number(8080);
    server.listen(port);
     app.use(express.static(__dirname + '/'));
     var temp;
     var _this = this;
     io.on('connection', function (socket) {
      console.log('connection '+socket)
     socket.on("data",function(d){console.log('data from flash: ',d);});
      socket.emit("message","wtfwtwftwftwf hello from server");
      socket.on('disconnect', function (socket) {
      console.log("disconnect");
  });

  console.log('_this ='+_this);
  _this.socket=socket;

});


texts: Switching LED on and off using microcontroller

texts:
I am new to microcontrollers and just become confused trying to solve the following problem:

An ATmega32 chip is connected to four on/off switches (SW0-SW3) and 4 LEDs (LED0-LED3). SWi is connected to PAi.  LEDi is connected to PA(4+i).

How will I code in such a way that turning a switch on, turns the corresponding LED on? For example, turning SW1 on will turn LED1 on. I am confused in the part that after taking input what will I send to port A? Multiple switches can be switched on at the same time.

For clarification:

switch0 is connected to PA0
switch1 is connected to PA1
switch2 is connected to PA2
switch3 is connected to PA3

LED0 is connected to PA4
LED1 is connected to PA5
LED2 is connected to PA6
LED3 is connected to PA7


texts:
I connected my ESP32 to Wifi and I can see this in my Wireless Statistics:
ID |       MAC Address      |Current Status| Packets Received | Packets Sent | SSID
1  | 3C: 71: BF: 0D: CB: 00 | Connected    |         52       |       47     |mySSID

I can ping via IP but I can't see ESP device in the DHCP list or ARP.
Could you explain why? And how I can fix this?


texts: What pins should I use when blinking AtTiny13 with arduino IDE?

texts:
I'm trying to program AtTiny13 using Arduino IDE. I have connected the atTiny to my PC using USBasp programer.

I want to write a simple blink application to test whether it works or not. Which pins should I blink?


texts: ESP8266-01 serial communication with Arduino UNO

texts:
I have been looking forever why my serial communication is not working, hopefully someone can help me here.

Arduino UNO code:

//ARDUINO UNO CODE

#include <arduino.h>
#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3

SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);

void setup() {
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  Serial.begin(9600);
  mySerial.begin(9600);
  delay(5000);
}
void loop() {

  String incommingString = "";
  bool Stringready = false;

  //Serial.println(mySerial.read);

  while (mySerial.available())
  {
    Serial.println("available");
    incommingString = mySerial.read();
    Stringready = true;
  }
  if (Stringready)
  {
    Serial.println(incommingString);
  }

}

//ESP8266-01 CODE

void setup() {
  //Serial S Begin at 9600 Baud
  Serial.begin(9600);
  delay(5000;)
}

void loop() {
  Serial.write("Hallo");
  delay(2000);
}

I connect esp rx to pin 3 and TX to 2 but when I connect the arduino to my computer and open the serial monitor nothing happens


texts: Difference between L298 and L298N motor driver

texts:
I was planning to buy a motor driver for my project purpose, but I don't understand which motor driver will suit my purpose. As there are two motor drivers available online. Can someone explain me the main difference between the two :

L298N : https://www.amazon.in/L298N-Based-Motor-Driver-Module/dp/B01N1H97CL

L298 : https://www.amazon.in/Robodo-L298-Motor-Driver-Module/dp/B00N4KWYDE?tag=googinhydr18418-21


texts: How to tell Arduino Uno that I pressed or released a key on PC keyboard over serial?

texts:
I want to implement a simple musical keyboard with Arduino using tone() and noTone() functions, etc.

The desired behavior is:

While PC and Arduino are connected via USB/Serial...
...when I press a key, a corresponding note starts playing...
...and if I release that key that note stops playing...
...or if I press another key, another note replaces the former one.

So, basically, instead of "while key is pressed" logic, I would like to just write a byte to serial when a key is pressed, write nothing while the key is held pressed, and write another byte when that key is released.

I will be using a Python script in the PC, but examples in other languages, or just using a plain serial monitor, are fine.


texts: In a circuit with a switch and a pull-down resistor, why does the high impedance of the input not discourage current from flowing into pin?

texts:
I'm a beginner to Arduino and circuits. I've spent the last couple hours hung up on the concept of how current flows through switches and pull-down resistors, having read every thread and watched every YouTube video I could find on the subject.

I understand that pull-down (and pull-up) resistors are necessary in order to prevent pins from floating. What confuses me is that, if the input pins effectively have a built-in 100 megohm resistance (according to this page), then how is it that a 10k ohm pull-down resistor is enough to dissuade current from flowing directly into ground even when the switch is closed?

Here is a diagram of my circuit:

Am I conflating the high-impedance state of input pins with resistance more generally?

Would really appreciate any clarification on this. Thanks!


texts:
Following this guide, it says to include a library in the C++ Linker called m. What is this for?

Specifically, Your second Arduino project.

4) Configure project

5th dot point:

  AVR C++ Linker -> Libraries: Under libraries, add arduino_core and m (in that order). Under path, add the path to the correct core library, e.g. "${workspace_loc:/arduino_core/328P_16MHz}"


texts:
I'm trying to put all my settings in a config.h file and then #include it in the Arduino sketch.

Here's what my config.h looks like:

RobotConfig.h

#ifdef BOT
    //hardware pins
    int motor1Pin = 9; //s0
    int motor2Pin = 10; //s1

    //pins for light
    int light2 = A4;
    int light3 = A2; //right
    int light1 = A1; //left

And here's what .ino sketch looks like:

#define BOT
#include "RobotConfig.h"

void setup() {
  //Light INIT
  pinMode(light1, OUTPUT); //left light with motor1/s1 in front
  pinMode(light2, OUTPUT); //middle light with motor1/s1 in front
  pinMode(light3, OUTPUT); //right light with motor1/s1 in front
  ...
}

This compiles fine on my Mac but I'm trying to compile this on Raspberry Pi (Pi3 with new Jessie install with sudo apt-get install arduino) and get an error while doing so. The error says:

  A1 was not declared in the scope etc.

What am I missing?