texts: Use LoLin V3 pins starting with 'S' in Arduino

texts:
I have this LoLin NodeMcu V3 board:

What are the pins S3, S2, S1, SC, S0, SK?
Can I use them as GPIO in Arduino?

Thank you for your help!


texts: Digispark don't work when I power it by 5v and GND inputs and chip starts heating

texts: I'm beginner so probably I did something stupid, but now my digispark don't work when I power it by 5v and GND inputs but chip starts heating immediately. When I power it by USB everything works well. Did i broke it? And how can I check it?


texts:
I have this code:

#include <TinyGPS++.h>
#include <SoftwareSerial.h>

#define GPS_RX_PIN 2
#define GPS_TX_PIN 3

TinyGPSPlus gps;
SoftwareSerial ss(GPS_RX_PIN, GPS_TX_PIN);

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

char clat[11];
char clng[11];

void loop()
{

        bool isGpsLocationValid = false;
        do
        {
            while (ss.available()>0)
            {
                char c = byte(ss.read());
                if (gps.encode(c))
                {
                    if (gps.location.isValid())
                    {
                        dtostrf(gps.location.lat(), 11, 6, clat);
                        dtostrf(gps.location.lng(), 11, 6, clng);
                        isGpsLocationValid = true;
                    }
                }
             }
        } while (isGpsLocationValid == false);
        Serial.write(clat);
        Serial.println();
        Serial.write(clng);
}

Now when all is done, the clng value is printed twice in the serial monitor.
The value i get is in this format:

27.275869  15.151013
  15.151013

As you can see, clng is printed twice. Any ideas why is that?


texts: Programming Arduino to dynamically connect pairs of Gertboard I/O pins together

texts:
The "Gertboard" requires several link wires to be connected between Pi GPIO inputs and outputs before different python or 'c' programs are run on the Pi.

What "Arduino" code could you suggest I might use on the "Gertboard ATMega" to configure these connections by inputting a sequence of two pin references for any given Pi program. e.g. From the "Gertboard" Manual Page 17 Fig. 13: The wiring diagram necessary to run the "Gertboard" LED test program, leds (12 Pi GPIO connected pins used in this example - too many for ATMega pins?).

This, in an attempt to avoid the requirement to physically wire the pins manually for any given pi or 'c' program.


texts: What is the relation between Arduino's clock and possible VGA resolution?

texts:
I have seen it said over and over (in different places) that in order to achieve 640x480 resolution out to a DB15 VGA connection, the arduino would need to be clocked at 25Mhz or that at half resolution it would need to be clocked at 12.5Mhz.

What is the relation between resolution and internal clock? I would expect that so long we can feed the signal fast enough that would be enough.


texts:
I am currently trying to learn how to use my MQ 7 CO Standalone to read CO in the air around the sensor. Currently Im using this circuit using my Arduino Uno. I get results of 900-1000. Here's a Fritzing Schematic on my setup.

Currently this is the code I am using on the arduino:

[code]

int mqx_analogPin = A0; // connected to the output pin of MQ-X

void setup(){
  Serial.begin(9600); // open serial at 9600 bps
}

void loop()
{
  // give ample warmup time for readings to stabilize

  int mqx_value = analogRead(mqx_analogPin);
  Serial.println(mqx_value);

  delay(100); //Just here to slow down the output.
}

I'm following the setup from this Instructables:
http://www.instructables.com/id/Smoke-Detector/?ALLSTEPS

However his readings are around 150-200ppm outside. I'm unsure how to reach these values since im following basically everything from the guide. Does anyone any experience with a MQ7 sensor?

I've been reading I need to preheat the sensor but I can't find any circuit that clearly shows how to preheat an MQ7 sensor or find any code for the arduino.


texts: Calculate battery (18650 Li-ion) voltage using ESP8266-12E

texts:
i am trying to calculate the battery voltage using ESP-12E module. I am using a voltage divider circuit to calculate the same. Here is how my circuit looks like:

And here is how my code looks like:
float volt =0.0;
float temp=0.0;
float r1=320000.0;
float r2=100000.0;

void setup(){
    Serial.begin(115200);
    Serial.println(String(VoltageCalculator()).c_str());
}

float VoltageCalculator(){
  for (int thisReading = 0; thisReading < numReadings; thisReading++) {
    readings[thisReading] = 0;
  }
  Serial.println(analogRead(A0));
  for(int i = 0;i<=10; i++){
    total = total - readings[readIndex];
    // read from the sensor:
    readings[readIndex] = analogRead(A0);
    // add the reading to the total:
    total = total + readings[readIndex];
    // advance to the next position in the array:
    readIndex = readIndex + 1;

    // if we're at the end of the array...
    if (readIndex >= numReadings) {
      // ...wrap around to the beginning:
      readIndex = 0;
    }

    // calculate the average:
    float analogvalue = total / numReadings;

    //  int analogvalue = analogRead(A0);
    temp = (analogvalue * 3.3) / 1024.0;
    volt = temp / (r2/(r1+r2));
  }

  if(DEBUG_ENABLE){
    Serial.println();
    Serial.print("Actual Voltage : ");
    Serial.print(volt);
    Serial.println();
  }

  float volt_percent;

  if(volt == 3.1){
    volt_percent = 0;
  } else{
    float volt_diff = volt - 3.1;
    volt_percent = (volt_diff/1.1)*100;
    if(DEBUG_ENABLE){
      Serial.println();
      Serial.print("Voltage percentage : ");
      Serial.print(volt_percent);
      Serial.println();
    }
  }
  return volt_percent;
}

When i use this circuit with NodeMCU it works very fine, but when it comes to ESP-12E module it do not show the proper voltage. on Serial.println(analogRead(A0)); always shows 1024.
Any suggestions why this is happening and how can i do this to achieve the most accurate value?


texts: Transistors to use for eight voltage sweeps from two PWM Arduino pins

texts:
On my Arduino Mega, there are two PWM pins open. There are eight analog voltage inputs to a datalogger. They are connected through a PCB, and I need test them with a DC voltage sweep. (There are many boards, so that is why I'm making a testing device instead of manually doing each with a variable power supply.)

As an analogy, it's like using four DMMs to measure the the same +Vcc to see if each DMM works.

Is some sort of amplifier circuit needed to output a maximum of 5 V to the eight datalogger inputs? Is an external power source needed? Please give me some direction.

The DC sweep does not have to go to 5 V. For what it's worth:

for(int s = 51; s < 256; s += 51)
{           // PWM: 255 = 5V
  analogWrite(analogWpin, s);      // sweeps thru 1, 2, 3, 4 & 5 V
  delay(500);
  analogWrite(analogWpin, 0);
  delay(500);
}

Related

Connecting many RGB LEDs to same PWM pins?
Controlling multiple pc fans with single pwm pin
Controlling multiple fans using arduino uno
Multiple DC motors from 1 pwm


texts:
This is my first post to this forum.  I am fairly experienced in electronics, but am in the process of learning C, Arduino coding, and how to use microcontrollers in general for various applications.

I have a toy-like 5 degree of freedom (DOF) robot arm that is currently controlled using the OEM hand-held switch box.  It is a basic electromechanical robot arm to illustrate the fundamentals and it uses DC motors to drive the joint motions.  The direction of motion is controlled by changing the polarity of the applied voltage.  The manufacturer did offer an "interface board" and SW to be able to hook up the arm and control it using a computer program.  However, this approach was fairly dated and their SW was not compatible with windows 8.1.  I wanted to experiment and use an Arduino Uno Rev 3 and 5V DC relay PCBs to develop my own interface system.

Basically, the HW aspect was straightforward and is working fine.  The Arduino SW also is working fine.  I am playing around with 2 variations of the program: 1) One program that simultaneously moves up to 3 joints and 2) A sequential joint movement program where each joint only moves after the other has finished moving.  One note about the simultaneous program is that I am using the "internal" batteries in the robot's base (only 3V each direction) and thus can not realistically move more than 3 joints at the same time without putting too much load on the source voltage.

Ok, now to my question! As it stands now, the program works well, but is not intuitive.  Each joint has 2 relays associated with it: one for each direction of travel.  There are 5 joints total in the robot arm.  I am able to use the program easily since I know directly (from setting up the HW and then the SW) which relays correspond to which Arduino pins and of course which relays correspond to each joint.  I'd like to make the program more intuitive where instead of "2,2,0,0,3,4" input string for example, the user would do something like "B,CCW,S,CW"  where B is for B = base, CCW = is counter clockwise etc.

Please note that in the numerical only input string "2,2,3,4" for example, the 2nd value corresponds to the duration in seconds that the relay will be ON (and thus the joint moving).  The robot arm is not very sophisticated in that it doesn't have encoders for position feedback.  The simplest way (and the method which the OEM interface board uses) to interface this arm and make a program where the arm will move in a "hands-off fashion" was to use relays and program delays (to create time durations of joint movement".  The numerical only input works really well currently and it was very easy to use examples to figure out how to parse a comma separated string.

I understand (I think) from looking at the examples how to parse a comma separated text string and pull from it the input values.

BUT, I am uncertain how to use those input values and then associate them in the SW with the correct relays (Arduino Pins)!

I have already tried seeking help with this but am unable to understand this thread:  http://forum.arduino.cc/index.php/topic,94701.0.html

Basically, I need a 2D table where the joint and direction are input and then the SW associates one particular relay with those inputs. Please see the table below for a graphical example of what I tried to say above.

One possible solution that I dread and saw mentioned was to use a ton of if else-if statements....  I dread this since I want to be able to input any joint in any order and thus it seems like when the code parses the input string for the ith relay, it would have to check ALL of the conditions to see which joint it is, which direction etc.  For example, I think I could minimize the # of if statements needed if I only entered in the input commands in a certain order: base first, shoulder next, etc.  Doing so however, limits the intuitiveness of the program.

Thank you all for reading this!  I hope this isn't too challenging!


texts:
I want to connect an Arduino Pro Mini with ATmega328P so as to drive a SI4463. But I don't know BLK, CTS, DTR should be connected to what pins of ATmega328P.

How do I connect this?


texts:
I am trying to read sensor data from a FIFO buffer embedded in the sensor (LSM9DS1), and store that data on a Teensy 3.2 board to later be put in a file. I can only read 6 bytes at a time from the FIFO.

The sensor's FIFO is read by the Teensy when an interrupt triggers an isr function. I want to store the data on the Teensy memory. Then, after the ISR store the memory, I plan to parse the data and do a few simple calculations in the loop() function before writing it to file.

What is the best way to accomplish this? I tried using a FIFO library for Arduino here, but it doesn't work with interrupts. I encountered errors with declaring it as a volatile memory type.

Could I used shared memory using the sys/shm.h library from C++? If so, how can I import this to my arduino code?


texts: Logging exceptions locally - SPIFF filesystem?

texts:
I am creating a system of 10 nodemcu(s) communicating and sharing data over painlessmesh. Each of these is powered by 240V to 3.3V power supplies.
One of these nodes is designated to

collect the data from the mesh
disconect from the mesh
connect with a given internet network via wifi
send the data via a REST API
reconnect to the mesh

This is done every 3 minutes.
My problem is that although the system works well (from sharing the data over the mesh to making the API request) for a few hours, later on the nodes start dropping, and once they do, they never join the network unless I power cycle them manually.
I'd like to log all exceptions/errors (which will appear on the serial monitor) which might be leading to this behaviour.
Thanks
PS: Happy to get any advice on the system architecture


texts: Trying to pass a char to software serial with a button press

texts:
Good day everyone,
I'm returning to the Arduino world after my a 3 year hiatus following the birth of my son.

I'm trying to push a button connected to pin 2 and have that send a 'd' to SoftwareSerial on pins 10,11. This should trigger an output back from the device connected to the SoftwareSerial.

I'm encountering an issue:

When I press the button it sends about 15 d's. I would like to limit this to just one char per button press, I attempted to build an if statement but it seems to ignore the conditions.

#include <SoftwareSerial.h>
// software serial #1: TX = digital pin 10, RX = digital pin 11
SoftwareSerial portOne(10, 11);
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status
int button1State = 0;

// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT);
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // Start each software serial port
  portOne.begin(4800);
  while (!portOne) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
}

// the loop function runs over and over again forever
void loop() {
  int Once = 0;
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH ) {
    if (Once == 0) {
      Once = 1;
      // turn LED on:
      digitalWrite(ledPin, HIGH);
      // send D to Radio
      portOne.write("d");
      Serial.write("d");
      Serial.print(Once);
      Serial.println();
      delay(1);
    }
  }
  else (buttonState == LOW) {
    // turn LED off:
    Once = 0;

    digitalWrite(ledPin, LOW);

  }
  portOne.listen();
  // while there is data coming in, read it
  // and send to the hardware serial port:
  while (portOne.available() > 0) {
    char inByte = portOne.read();
    Serial.print(inByte);
  }
}


texts: Vary voltage using relay. Is this possible?

texts:
I am planning to control a RGB lamp using Arduino. The lamp is 24V and I want to be able to control the brightness of the lamp. I found a relay that will let me control the 3 channels (red green and blue), but will only let me turn it on and off (Not control brightness)

I am looking for a way to control the lamp both on/off and brightness. What component will do the same as my relay, but also let me use the varying voltage from the arduino to control my 24V lamp? (Just like a transistor)

I have an external 24V powersupply along with 5V for the arduino

Thanks!


texts:
I'm using this SparkFun Sound Sensor in my project for a simple ambient sound meter.

I'm just trying to monitor the raw analog envelope output for the moment.

My problem is that the output only changes with peak sounds, like a clap in my hands for example. But when the ambient sound is louder, people talking or loud music, the output doesn't change.


texts: How to detect button presses with a 74HC595 shift register?

texts: Is there a way I can have my arduino uno differentiate between pushbuttons that are wired through a shift register and detect when each are pressed or not? I found this tutorial for the 74HC165 but I'm not sure it's applicable to the 74HC595.


texts: Is setting AVR TWCR for mega328p TWEN in each function necessary?

texts:
I found this useful website explaining for to configure and implement the TWI for mega328p, but what I found not so obvious is that in the website they set TWEN in every function, while in the datasheet C code example, they only set it in START and STOP functions.

I also find another style in Arduino Wire library, that they implement more easier functions for starting and ending the module.

This is the website, could anyone take a look and tell me if setting TWEN in each function is necessary?

Also, is it necessary to check for TWINT after sending STOP command?

http://www.embedds.com/programming-avr-i2c-interface/

Regards,


texts: How to read Negative number with serial.read

texts:
how i can read negative number with command Serial.read()?
beacouse i with  this

    char tmpChar = Serial.read(); //read incoming character from serial port
    if (isDigit(tmpChar)) { //check if the in character it's a number
        setpoint =  (setpoint  * 10 ) + tmpChar - '0'; // convert from ascii code to it's corresponding number; '0' == DEC 48
      }
if (tmpChar == '\n' || tmpChar == '\r') { //if CR or LF was received
    if (setpoint > 0) {
      tmpChar = "";
      Serial.print(setpoint);
      Serial.println(" NUMERO STEP IN AVANTI");

    }

im using an encoder motor, i want to move for N steps the motor forward (positive number) or backward (negative number) , i insert the number of step in serial input

i can read only positive number. Thanks for help

how suggest Majenko i made a partial solution :

char buf[8];
int valore = 0;

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

void loop() {
  if (Serial.available() >= 8) {
    for (int i = 0; i < 8; i++) {
      buf[i] = Serial.read();

    }
    String str();
    if (buf[0] == "-") {
      valore = (atoi(buf)) * -1;
      Serial.println(valore);

    }
    else {
      valore =  atoi(buf);
      Serial.println(valore);
    }
  }
}

but the problem now it's the static array ,
unpleasant to use


texts: How are locations in FLASH memory addressed?

texts:
There is an external FLASH memory (W25Q80DV) that I want to use with the Arduino.
This memory has 4096 pages of 256 bytes each.
I want to make multiple writes per page to use memory evenly and erase less.
Test code:
#include <SPI.h>

#define readStatusReg_1 0x05
#define readArrayReg 0x0B
#define writeEnableReg 0x06
#define pageProgramStatusReg 0x02

#define FLASH_SELECT_CHIP 33

// # Select / Unselect chip
void selectChip(bool state) {
  switch (state) {
    case true:
     digitalWrite(FLASH_SELECT_CHIP, HIGH);
     digitalWrite(FLASH_SELECT_CHIP, LOW);
      break;
    case false:
     digitalWrite(FLASH_SELECT_CHIP, HIGH);
      break;
  }
}

// # Wait flash ready state
void notBusy() {
  uint16_t whileCounter;
  selectChip(true);
  SPI.transfer(readStatusReg_1);
  while((SPI.transfer(0) & 1) && whileCounter < 45000) { whileCounter++; }
  selectChip(false);
}

// # Send command and address
void sendCommandAndAddress(const byte command, const unsigned long address) {
  SPI.transfer(command);
  SPI.transfer((address >> 16) & 0xFF);
  SPI.transfer((address >> 8) & 0xFF);
  SPI.transfer(address & 0xFF);
}

// # Write enable
void writeEnable() {
  notBusy();
  selectChip(true);
  SPI.transfer(writeEnableReg);
  selectChip(false);
}

// # Write FLASH page
bool writeFlashData(const unsigned long address, byte * data) {
  writeEnable();
  selectChip(true);
  sendCommandAndAddress(pageProgramStatusReg, address);
  uint16_t len = sizeof(data);
  for(uint16_t i = 0; i < len; i++) {
    SPI.transfer(*data++);
  }
  selectChip(false);
  notBusy();
  return true;
}

void setup() {
  // SPI
  pinMode(FLASH_SELECT_CHIP, OUTPUT);
  digitalWrite(FLASH_SELECT_CHIP, HIGH);
  SPI.begin();
  SPI.setDataMode(0);
  SPI.setBitOrder(MSBFIRST);

  // Write FLASH
  #define TESTADDRESS 0x1000
  byte msgData[] = "Hi all!";
  writeFlashData(TESTADDRESS, msgData);
}

void loop() {}

Here, the address #define TESTADDRESS 0x1000 (4096) is specified for writing data.
I'm not clear if this is the page address or the byte address from which I will start recording?
I would like to actually split one page into multiple blocks and write data for them separately.


texts:
For a university Lab course i have to realize a UPS unit with a internal LiPo battery . The unit uses as battery charger a buck converter
I have only a problem with the battery charger (buck converter). Few weeks before i verify the code and it works without problem. Now i can notice that the analog value that i read are floating too much and this represents a problem for the Constant Current (CC) and Constant Voltage (CV) phases of the battery charge process.
I found that this problem happens when plug arduino  after i have started the PC, while it doesn't happen when i plug the USB cable of arduino and then start the PC. It seems to be a problem with the ground of arduino.
the circuit scheme is the following one:

and what i obtain is that:

as you can see i have a strange increase of all the voltage that i read with the analog pin of arduino. The code is correct since before this week it works well, but if necessary i will upload it.
the 10Ohm resistor is placed in the buck converter only to measure the chargin current that i calculate as:
charging_current=(analogRead(A1)-analogRead(A2))*5.00/1023.00
The battery must be charged at constant current equal to 50mA until the battery voltage became equal to 4.10V, after that value the battery must be charged at constant voltage equal to 4.20V until the charging current became smaller than 10/5mA.
Notice that i try also to make more acquisition for each voltage: i made 8 measurement and then i calculate the average value, but the result doesn't change.


texts: Has anybody seen/created a gps guided vehicle with arduino?

texts: I thought the idea of Amazon Prime air drone delivery was a pretty cool one when it first came out and I started to question whether something like that (an autonomous gps guided vehicle) could possibly be created with the Arduino microcontroller(s). Any thoughts?


texts: A/C doesn't detect IR codes sent from Arduino

texts:
I have an IR receiver and an IR LED I got from a kit (I don't have the datasheets for them).
I uploaded an Arduino sketch to record my A/Cs IR codes. Those were NEC encoded 32bit integers.
After recording the codes, I tried retransmitting them. The A/C unit failed to detect the signals.
Troubleshooting a bit, I sent the code from the Arduino the receiver sketch from the previous step - it received them successfully.

All the above steps used the IRRemote Arduino library

The question is, what could explain this behavior?
A few possibilities I had in mind:

IR frequency. Could it be that the detection circuit worked with the default settings but transmitting wouldn't?
IR wavelength. Any chance the A/C side doesn't detect my IR pulses at all?
Decoding/Encoding of the NEC protocol in IRRemote. If there is no standard for the NEC protocol, the Arduino and A/C implementation might be a little different.


texts: Question about browsing the web using arduino

texts: I have got an arduino, a TFT touch screen and a WIFI module. The question is can i visit a specific web site and display it on that screen and interact with it.


texts: Using the physical serial port on a BSFrance LoRa32u4?

texts:
I can use the serial-over-USB channel by simply using Serial in my code.

The LoRa32u4 has an RXD1 and TXD1 pair on pins 20/21 (Arduino 0/1).

https://docs.bsfrance.fr/documentation/11296_LORA32U4/LoRa32u4_pinout_diagram.pdf

How do I configure and use this serial port (for receiving NMEA GPS)?


texts: I'm going to use this tutorial : https://www.arduino.cc/en/Tutorial/ShiftOut to make a Nixie Clock. I was asking myself if other components that'll be easier to use existed ?


texts: Why can't I print boolean variable values (0 and 1) through println function?

texts:
source code :

int buttonPin = 8;
boolean buttonState = 0;

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

void loop()
{
   buttonState = digitalRead(buttonPin);
   Serial.println(buttonState);
   delay(500);
}

But when, instead of boolean I specify an int data type for buttonState variable it produces the result I want i.e. 1 when pressed and 0 when not pressed.
Is it related to the way these variables when stated with different data types give different values to the println() function to convert them into ASCII values?


texts: Arduino uno + XBee Shield Not transmitting when under battery power?

texts:
I have a few Arduino's along with XBee Shields communicating with one another.

The problem I'm having is that, when all the Arduinos+XBee Shields are powered via USB(PC) they seem to work fine and all transmissions get through to one another. But, when I use them with 9Volt batteries(fairly new batteries) the whole thing crashes and I never receive responses back from the battery powered ones.

I'm wondering if this is really a power issue? wouldn't a 9volt be enough to power a single arduino(uno)+xbee shield?


texts: GPS led not blinking and wrong LAT Long values

texts:
I want to extract the latitude and longitude values of my location but my gps led is not blinking. Also result appearing on the serial monitor is wrong.

This is my Arduino code:

#include <TinyGPS++.h>
#include <SoftwareSerial.h>

SoftwareSerial gpsSerial(3, 4);
TinyGPSPlus gps;
float latitude,longitude;
void setup() {
  // put your setup code here, to run once:
  gpsSerial.begin(9600);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
while(gpsSerial.available())
  {
    int data=gpsSerial.read();
    if(gps.encode(data))
       {
          latitude = (gps.location.lat());
          longitude = (gps.location.lng());
          Serial.print("Latitude");
          Serial.println(latitude);
          Serial.print("Longitude ");
          Serial.println(longitude);
       }
   }
}

Please tell me what is wrong in the code?


texts: Honeywell HPMA115S0, sensor not start again after stop

texts:
I use HPMA115S0 sensor with Arduino for Nodemcu, i can read it value but face one problem. The sensor not work after send stop measure command (fan not start too).

const int StartPmMeasure[4] = {0x68, 0x01, 0x01, 0x96};
const int StopPmMeasure[4] =  {0x68, 0x01, 0x02, 0x95};
...
void stopSensor() {
  if (isSensorStart) {
   Serial.println("INFO: Stop sensor");
   sendCommand(AutoSendOff);
   sendCommand(StopPmMeasure);
   isSensorStart = false;
 }
}

void startSensor() {
 if (!isSensorStart) {
  Serial.println("INFO: Start sensor");
  sendCommand(StartPmMeasure);
  sendCommand(AutoSendOn);
  isSensorStart = true;
 }
}


texts:
In my recent project, working with JSON and Arduino. Till now, I am getting proper JSON data and add this one into Arduino data. But here I face one problem. My data are not updated in real time.

For example, my JSON string is:

{"TPS_Json":"0.40"}

And below is my Arduino code:

#include<LiquidCrystal.h>
#include <ArduinoJson.h>

LiquidCrystal lcd(12, 11, 7, 6, 5, 4);

String response = "";
bool begin = false, finished;

//------------------------------ Variable ---------------------------------//

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

  lcd.begin(16, 2);
}

void loop()
{
  //----------------------------TPS----------------------------//

  float TPS = analogRead(A0) * (5.0 / 1023.0);

  //-----------------------JASON DATA--------------------------//

  StaticJsonBuffer<100> jsonBuffer;

  while (finished == false)
  {
    if (Serial.available())
    {
      const char in = Serial.read();
      if (in == '{')
      {
        response = "";  // Blank the string
        begin = true;
      }
      if (begin)
      {
        response += (in); // Only write if within the {}
      }
      if (in == '}')
      {
        begin = false;   // Prevent any chars between } and { leaking through.
        break;
      }
    }
    delay(1);
  }

  JsonObject& root = jsonBuffer.parseObject(response);

  float TPS_Json = root["TPS_Json"];

  float TPS_Final = TPS + TPS_Json;

  lcd.setCursor(0, 0);
  lcd.print("      ");
  lcd.setCursor(0, 0);
  lcd.print(TPS);
  lcd.setCursor(8, 0);
  lcd.print("      ");
  lcd.setCursor(8, 0);
  lcd.print(TPS_Json);
  lcd.setCursor(0, 1);
  lcd.print("      ");
  lcd.setCursor(0, 1);
  lcd.print(TPS_Final);
}

So, now I add TPS_Json with TPS. Where TPS_Json is JSON data and TPS is an analog value from A0. And TPS_Final is the addition of TPS_Json and TPS. I displayed all this on LCD.

Suppose, TPS_Json = 0.40, TPS = 2.40... So addition is 2.80 means TPS_Final = 2.80...
And this all data displayed on LCD successfully.

But when I changed my analog value means TPS value then it is not updated and I'm not getting the correct result.

Suppose, I change the value of TPS means makes it 3.00 from 2.40 than my TPS_Final must be 3.40.But nothing updated. It updated when I send JSON data again. I don't know why this happens. I want to change it in real time means When I changed TPS then TPS_Final must be changed in real time.


texts:
I've been reading a lot on the ESP8266, but still my understanding is shaky. I have the Arduino IDE running on a PC, which uses wires to connect to the ESP8266 via a USB device (Device Manager > Ports (COM & LPT) > Silicon Labs CP210x USB to UART Bridge). This is how I uploaded a simple sketch to the ESP8266.

It works and has been installed in the wall. I'm happy and relieved to complete the project... except for one small thing: I noticed that it shows up on WiFi. I can connect to it without a password, with a "Limited" connection. After that I'm lost, but I wonder if someone who knows what they are doing can use this unsecured connection to hack my install. I'd like to disable the WiFi, if possible, since I'm not using it.

The worst part is my learning curve now starts over. I thought that when my sketch gets uploaded, it replaces the original firmware. Now "firmware" is an elusive concept. I keep thinking that it shows up on WiFi because of something running in firmware. My sketch hasn't any code for WiFi. What am I missing/do I have wrong?


texts:
I am quite new to the Arduino stuff. I have got the Arduino IDE installed side by side with Eclipse. I am using Eclipse with the Arduino plugin, which is working well for me, including the SerialMonitor.

If you're using Eclipse with the Arduino plugin, it'll also add two new views. One is the serial monitor, the other one is called scope. Scope is a 6 channel Oscilloscope. But I don't know how to get values displayed there.

I am just curious how to use the scope there. I can't find any tutorial for this.

Can somebody explain how to show something inside the scope?


texts: Why can't I connect more than one Arduino Uno + Ethernet Shield to my network?

texts:
I'm using 3 Arduino Uno boards with Ethernet shields. Each is connected to my home Internet switch with an Ethernet cable.  I assigned a different local IP address to each Arduino and gave each board a different MAC Address.

Each Uno is collecting temperature/humidity for a bedroom in my house.  The data is sent to a MySQL Database using PHP/HTML.

They work fine for a while (5 minutes) and then they conflict each other.  If I use one Arduino at a time it works fine, but I can't get them to work together.

Any idea how to solve the problem?


texts: I got a question regarding the ultrasound sensor (HC-SR04) connecting to the arduino. I have a project, and the space is really tight, so i will have to bend the pins of the HC-SR04. Is this okay to do, and if yes, how should i go about and do this ?


texts: I'm not getting the readings of sensors connected to an Arduino MEGA correctly using PLX-DAQ

texts:
I'm trying to send data from four sensors that are connected to my Arduino MEGA to an excel file using PLX-DAQ. So I want to keep taking readings at an interval of 1 second until I wish to stop. So I have two questions. First, this code is not working, I just get three readings but all in one row. And I try resetting the Arduino the first time using the physical button on it, and again I get the next set of three readings AFTER I press the reset button the second time. So there is no real-time updation. For example, I upload the code and I click on connect in PLX_DAQ. I see nothing in the Excel file. I press the reset button, and I get three readings all in one row. I wait for some time, I press reset again and I get another three readings and that's it.

Second, how do I control when to start taking readings or stop taking readings, either using Arduino code or by PLX-DAQ.

int sensC=A12;
int sensA=A13;
int sensB=A14;
int sensD=A15;

void setup() {
  Serial.begin(9600);
  Serial.println("CLEARDATA");
  Serial.println("LABEL,A0-Voltage,B0-Voltage,C0-Voltage,D0-Voltage");
}

void loop() {
  Serial.print(analogRead(sensA));
  Serial.print(",");
  Serial.print(analogRead(sensB));
  Serial.print(",");
  Serial.print(analogRead(sensC));
  Serial.print(",");
  Serial.println(analogRead(sensD));
  delay(1000);
}

**********EDIT 1**************

@user85471, ok so I added another line right under void loop(), which is: Serial.print("DATA,");

and I ran it again. Now i see my data being stored, but I have four sensors, but only three are of the right output.

A0-Voltage should be somewhere around 330-340, but I'm getting some sort of a time output.


texts: Arduino Nano Atmega328P doesn't work on Macbook

texts:
I've bought and Arduino Nano compatible on eBay:

But by the time I connect it to my Macbook Pro (OS X El Capitan 10.11.2) doesn't appear under "Tools -> Port" in Arduino IDE:

I've followed some instructions by other posts here in StackOverflow:

Arduino Nano no serial port for MacBook Air 2013
Arduino Nano with Mac OS Yosemite 10.10

But none of them worked :(

If someone could help me out with this issue I'll be grateful.

Thanks.


texts: Teensy not pulling down despite digitalWrite(x,LOW)

texts:
I'm trying to switch a ATX PSU on and off by serial command. My code is as follows:

#include <Arduino.h>
#define PIN_LOW_FOR_POWER PIN_F0

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

void loop() {
  String sCode = Serial.readStringUntil('\n');
  if (sCode == "M80"){
    digitalWrite(PIN_LOW_FOR_POWER, LOW);
  }
  else if (sCode == "M81"){
    digitalWrite(PIN_LOW_FOR_POWER, HIGH);
  }
  else{
    Serial.println("Unknown command");
    return;
  }
  Serial.println("OK");
}

I'm getting "OK" back, and the power switches. After sending M81 I read 5V across the pin and ground, but after sending M80 for some reason I read 2.37V and not 0V. If I switch to "F1" (keep the wire connected to F0) I do read 0V.

The ATX PSU needs F0 to be pulled down in order to turn on. I soldered the ground of the ATX PSU to the Teensy ground, and the wire to be pulled down (green) to F0. I supply the 5V to the Teensy through USB, so the VCC pin is left unconnected.

The PSU does turn on if I manually create a short between F0 and ground.

Why doesn't the Teensy pull F0 down, and how do I resolve this? (All I could come up with is something of internal resistance within the Teensy being too high, which seems unlikely to me. (If the resistance within the PSU and wires between "green" and ground is equal to the resistance within the Teensy this would happen, right?))

PS: It turns out I bought a fake Teensy from China, if it's related. Ordered a new one for a different project, but still had this one laying around.


texts: How to access multiple peripherals and one central using BLE (MKR1010 BLE)

texts: How to access , multiple peripherals one central using BLE(MKR1010) .


texts: Does 12v 5A power supply is okay to operate motor shield external power

texts:
I am new to arduino.

Recently purchased motor shield V1.0 which have two l293 and can run 4 DC motors simultaneously.
But here the problem comes: when I purchased the shield I was not aware that it can only supply 2A peak current.
However, my DC motor rating is 12v 5A. So I purchased a 12v 5A power supply.
But now I am not sure to operate shield with external power of 12v 5A.

Does it works or will it burn?


texts: How does serial communications work on the Arduino?

texts:
With reference to the Arduino Uno, Mega2560, Leonardo and similar boards:

How does serial communications work?
How fast is serial?
How do I connect between a sender and receiver?

Please note: This is intended as a reference question.


texts:
I'm having a very strange problem. I have a Tian that is programmed to send out sensor data to a server
every x seconds.
My program run well but after 14,15 hours of operation it stops working and I don't receive datas. The program is fast at the beginning, then after 2 to 3 hours before stopping, it becomes more and more slow with the message "timeout".

I think maybe a misuse of the Ciao library on my part could be at the root of the problem. Or maybe a modification at the program level could correct the problem. So if I can have some help about this..
(the problem doesn't come from the use of String, I have already tested use of array with cstrings and it doesn't work).

Here is the part of the program that I think is problematic (there is another CiaoReadWrite nearly similar to the first) :

void CiaoReadWrite1() { CiaoData data = Ciao.read("restserver");
if (!data.isEmpty())
{
  String id = data.get(0);
  String sender = data.get(1);
  String message = data.get(2);

  splitString(message,"=",LtT2,9);

  gen            =LtT2[0].toInt(); LtT2[0]="";
  belt           =LtT2[1].toInt(); LtT2[1]="";
  genReady       =LtT2[2].toInt(); LtT2[2]="";
  hvOnOff        =LtT2[3].toInt(); LtT2[3]="";
  beep           =LtT2[4].toInt(); LtT2[4]="";
  heart1         =LtT2[5].toInt(); LtT2[5]="";
  sendConf       =LtT2[6].toInt(); LtT2[6]="";
  heart2FB       =LtT2[7].toInt(); LtT2[7]="";

  beepFB         =beep;
  heart1FB       =heart1;
  sendConfFB     =sendConf;

  Ciao.writeResponse("restserver",id, String(baroAlti*100)+"="+baroHumi*10+"="+baroPres+"="+baroTemp*10+"="+beepFB+"="+heart1FB+"="+heart2+"="+sendConfFB+"="+
                                      secCust1+"="+secCust2+"="+secEmrgSW+"="+secloop+"="+secLoop1+"="+secLoop2+"="+gndSwGnd+"="+gndSwUGnd+"="+statusA1+"="+
                                      statusA2+"="+statusA3+"="+beltStat1+"="+beltStat2+"="+beltStat3+"="+beltStat4+"="+request+"=");
  request++;
}

}


texts:
I started recently working with a uBlox Neo 6M GPS module (data sheet http://www.u-blox.com/images/downloads/Product_Docs/NEO-6_DataSheet_%28GPS.G6-HW-09005%29.pdf). I connected it to an Arduino Uno as shown:

GPS  Arduino
VCC-- 3.3V
RX -- D11
TX -- D10
GND-- GND

I tried this example code from TinyGps++ (of course, changing the pins and the gpsbaud to 9600, which is the gps' default).

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
/*
   This sample sketch demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/
static const int RXPin = 10, TXPin = 11;
static const uint32_t GPSBaud = 9600;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

void setup() {
  Serial.begin(115200);
  ss.begin(GPSBaud);
  Serial.println(F("DeviceExample.ino"));
  Serial.println(F("A simple demonstration of TinyGPS++ with an attached GPS module"));
  Serial.print(F("Testing TinyGPS++ library v. ")); Serial.println(TinyGPSPlus::libraryVersion());
  Serial.println(F("by Mikal Hart"));
  Serial.println();
}

void loop() {
  // This sketch displays information every time a new sentence is correctly encoded.
  while (ss.available() > 0)
    if (gps.encode(ss.read()))
      displayInfo();
  if (millis() > 5000 && gps.charsProcessed() < 10) {
    Serial.println(F("No GPS detected: check wiring."));
    while(true);
  }
}

void displayInfo() {
  Serial.print(F("Location: "));
  if (gps.location.isValid()) {
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(","));
    Serial.print(gps.location.lng(), 6);
  } else {
    Serial.print(F("INVALID"));
  }

  Serial.print(F("  Date/Time: "));
  if (gps.date.isValid()) {
    Serial.print(gps.date.month());
    Serial.print(F("/"));
    Serial.print(gps.date.day());
    Serial.print(F("/"));
    Serial.print(gps.date.year());
  } else {
    Serial.print(F("INVALID"));
  }

  Serial.print(F(" "));
  if (gps.time.isValid()) {
    if (gps.time.hour() < 10) Serial.print(F("0"));
    Serial.print(gps.time.hour());
    Serial.print(F(":"));
    if (gps.time.minute() < 10) Serial.print(F("0"));
    Serial.print(gps.time.minute());
    Serial.print(F(":"));
    if (gps.time.second() < 10) Serial.print(F("0"));
    Serial.print(gps.time.second());
    Serial.print(F("."));
    if (gps.time.centisecond() < 10) Serial.print(F("0"));
    Serial.print(gps.time.centisecond());
  } else {
    Serial.print(F("INVALID"));
  }
  Serial.println();
}

However, I do not get the GPS LED to blink, as well as my Arduino's RX LED, so the module is not transmitting any data. This is the output from the code:

A simple demonstration of TinyGPS++ with an attached GPS module
    Testing TinyGPS++ library v. 0.92
    by Mikal Hart

    Location: INVALID  Date/Time: 0/0/2000 00:00:00.00
    Location: INVALID  Date/Time: 0/0/2000 00:00:00.00

Thanks!


texts: Problem sending GPS coordinates with SMS when requested

texts:
I have made a project that sends GPS coordinate but the problem is, when GPRS sends coordinates as 00.0000,00.000. So, I want to know if my code is wrong.

Thank you for your answer.

#include <SoftwareSerial.h>
#include <TinyGPS++.h>

double latitude, longtitude;
char Received_SMS; //Here we store the full received SMS (with phone sending number and date/time) as char
short MSG_OK = -1; //Used later it shows if there's the word "DHT"/"MLX" within the received SMS "-1" means they are not found
String Data_SMS; //Here's the SMS that we gonna send to the phone number, it may contain DHT data or MLX data

TinyGPSPlus gps;
SoftwareSerial mySerial(2, 3); //gps
SoftwareSerial ss2(9, 10); //gprs

void setup() {
  Serial.begin(9600);
  mySerial.begin(9600); //Begin all the communications needed Arduino with PC serial and Arduino with all devices (SIM800L+DHT+MLX)
  ss2.begin(9600);
  Serial.println("GPS Tracking");
  delay(1000);
  Serial.println("Starting ...");
  delay(3000); //Delay to let the module connect to network, can be removed
  ReceiveMode(); //Calling the function that puts the SIM800L moduleon receiving SMS mode
}

void loop() {
  mySerial.listen();
  while (mySerial.available()) {
    gps.encode(mySerial.read());
  }
  if (gps.location.isUpdated()) {
    latitude = gps.location.lat();
    longtitude = gps.location.lng();
  }
  String RSMS;
  ss2.listen();
  while (ss2.available() > 0) { //When SIM800L sends something to the Arduino... problably the SMS received... if something else it's not a problem
    Received_SMS = ss2.read(); //"char Received_SMS" is now containing the full SMS received
    Serial.print(Received_SMS); //Show it on the serial monitor (optional)
    RSMS.concat(Received_SMS); //concatenate "char received_SMS" to RSMS which is "empty"
    MSG_OK = RSMS.indexOf("GET-GPS"); //And this is why we changed from char to String, it's to be able to use this function "indexOf"
  }
  if (MSG_OK != -1) { //If "DHT" word is found within the SMS, it means that DHT_OK have other value than -1 so we can proceed
    Serial.println("found MSG"); //Shows on the serial monitor "found DHT" (optional)
    Data_SMS = ("http://www.google.com/maps/place/" + String(latitude, 6) + "," + String(longtitude, 6));
    Send_Data(); //This function set the sending SMS mode, prepare the phone number to which we gonna send, and send "Data_SMS" String
    ReceiveMode(); //Come back to Receving SMS mode and wait for other SMS
    MSG_OK = -1; //If the DHT is found the variable should be reset to -1 otherwise it will be kept as !=-1 and will send SMS over and over
  }
}

void Serialcom() { //This is used with ReceiveMode function, it's okay to use for tests with Serial monitor
  delay(500);
  while (Serial.available()) {
    ss2.write(Serial.read()); //Forward what Serial received to Software Serial Port
  }
  while (ss2.available()) {
    Serial.write(ss2.read()); //Forward what Software Serial received to Serial Port
  }
}

void ReceiveMode() { //Set the SIM800L Receive mode
  ss2.println("AT"); //If everything is Okay it will show "OK" on the serial monitor
  Serialcom();
  ss2.println("AT+CMGF=1"); // Configuring TEXT mode
  Serialcom();
  ss2.println("AT+CNMI=2,2,0,0,0"); //Configure the SIM800L on how to manage the Received SMS... Check the SIM800L AT commands manual
  Serialcom();
}

void Send_Data() {
  Serial.println("Sending Data..."); //Displays on the serial monitor...Optional
  ss2.print("AT+CMGF=1\r"); //Set the module to SMS mode
  delay(100);
  ss2.print("AT+CMGS=\"+66xxxxxxxxx\"\r"); //Your phone number don't forget to include your country code example +212xxxxxxxxx"
  delay(500);
  ss2.print(" You are here "); //This string is sent as SMS
  delay(500);
  ss2.print(Data_SMS); //This string is sent as SMS
  delay(500);
  ss2.print((char)26);//Required to tell the module that it can send the SMS
  delay(500);
  ss2.println();
  Serial.println("Data Sent.");
  delay(500);
}


texts: How to pass value of a function from the RFID-RC522 library into a variable then be sent into either serial or ethernet?

texts:
I'm using an RC522 RFID reader with an Arduino UNO. There is a function?? (or whatever it's called :)) in Miguel Balboa's new MFRC522.h library which is mfrc522.uid.uidByte[i] that prints the bytes of the unique ID. The repetition of the function results in 8 piece of HEX digits that are from the 2 numbers that each function outputs (2+2+2+2=8). Whenever I use the line of codes that are commented out, the serial monitor outputs them successfully. So for example, 12345678 is the unique id, each array displayed 12, then 34, then, 56, then 78 which is 12345678 in the serial. which is fast and unnoticeable besides that there are no spaces included when on output. The thing is, I want to output all of these into a single variable.(Please help me also on how to concatenate) How can I do this? An attempt was done below (not commented out) but it outputs only the number 16, consistently, which is I think due to a data type problem. The variables are initialized as int. The "function" which I found in the library is initialized as byte (correct me If I'm wrong). But when the variables are initialized as byte, I cannot upload the sketch since there are errors. Please help. :( (The reason I need it to be saved into a single variable is because I am placing it in the GET method of an Ethernet Client. I don't think the bare function can do that. (Or if it can, can you please help with the code? :)) Thanks

// Dump UID
        //Serial.print("Card UID:");

            //Serial.print(mfrc522.uid.uidByte[0], HEX);
            //Serial.print(mfrc522.uid.uidByte[1], HEX);
            //Serial.print(mfrc522.uid.uidByte[2], HEX);
            //Serial.print(mfrc522.uid.uidByte[3], HEX);

            serNum0={mfrc522.uid.uidByte[0], HEX};
            serNum1={mfrc522.uid.uidByte[1], HEX};
            serNum2={mfrc522.uid.uidByte[2], HEX};
            serNum3={mfrc522.uid.uidByte[3], HEX};
            Serial.print(serNum0);
            Serial.print(serNum1);
            Serial.print(serNum2);
            Serial.print(serNum3);


texts: Is it possible to test SPI communication having only one board?

texts:
How do I study my Arduino device? I just read ATmega328 datasheet and tutorials for some theory and then try to implement it on my device - Arduino Uno R3 (with ATmega328 on board). Now I am studying SPI communication using this micro-controller. But as I understand correctly I must have at least two communicating devices: master and slave.

I know how to manipulate its registers in order to set up SPI communication. The problem is I do not have another ATmega micro-controller. Am I destined to skip this part of using ATmega until I have another SPI compatible device?


texts:
I need to work with Arduino Uno, LCD and Wi-Fi shield.

I was wondering whether I can use the LCD in the link, 2.2" TFT Display - Test the Display with the Uno and Wi-Fi shield - and how to search for them?


texts: DHT11 data in Arduino UNO to Firebase through ESP8266

texts:
Hello Good Day to Everyone.
I have a project where I need to send DHT11 sensor data to a Firebase database using both Arduino UNO and Esp8266 esp-01 wifi module. Both of them must work together to send the data.

Arduino Code:

#include <dht.h>

dht DHT;

#define DHT11_PIN 7

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

}

void loop() {
 // put your main code here, to run repeatedly:
int chk = DHT.read11(DHT11_PIN);
Serial.print("Temperature = ");
Serial.println(DHT.temperature);
Serial.print("Humidity = ");
Serial.println(DHT.humidity);
delay(1000);

}

My arduino code is working fine. Now comes the part where I need to program the ESP8266 which I am really confused how to pass the data to the wifi module and send it to firebase. I tried to code some and this is my

ESP8266 Code:

#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
#include <DHT.h>

#define FIREBASE_HOST "test.firebaseio.com"
#define FIREBASE_AUTH "authcode"

#define WIFI_SSID "mywifi"
#define WIFI_PASSWORD "12345"

#define DHTTYPE DHT11
#define DHTPIN  7

DHT dht(DHTPIN, DHTTYPE);
float temp_f;
unsigned long previousMillis = 0;
const long interval = 2300;

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

WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("connecting");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
 Serial.println();
 Serial.print("connected: ");
 Serial.println(WiFi.localIP());

Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);

 }

void loop() {
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
delay(50);
Firebase.setFloat("temp",t);
Firebase.setFloat("hum",h);
delay(1000);
}

I don't want my esp8266 to go stand alone. I wanted the data to come from the arduino but somehow I don't know how to receive the data from the arduino in the esp8266.

I hope someone can enlighten me..
thank you


texts:
I accidently bought a "Common Anode" 7-segment display instead of a "Common Cathode".

I understand that the polarity of the leds within the display is 'reversed'. So instead of putting the common pin on GND I have to put it to 5v (with current limiting resistor)

My questions on this are:

Can I still use only one current limiting resistor on the common pin? Instead of a resistor on every segment pin.
Can I use the pins from arduino to drive it (withouth pull-up/pull-down?) By making the signal LOW the current will flow from 5V common anode to the arduino and thus the segment wil light?
Can I still use a shift register to drive the segment led? (By inversing the outputs (in software))

Obviously I would like to have wiring more like this (but then I would ofcourse change  the GND line to a 5V line.

The wiring below is the worst-case wiring I can think of.

^ So can I avoid this, when using a Common Anode 7-segment display or am I forced to buy a Common Cathode 7-segment display?


texts: Arduino - Ultrasonic Sensor for use instead of analog potentiometer for proximity control

texts: I was hoping someone could assist me with a project. I have built a device which uses a potentiometer (analog) to control an audio filter (analog). I was looking to use the arduino dual ultrasonic sensor module (HC-SR04) to replace the potentiometer in this circuit to act almost like a proximity sensor; raising the filter cut off when a person gets close to the sensor. Do you know anyone who might be able to help in coding this? and also, what needs to be connected to what?? Thank you for any help you can provide. The potentiometer I would like to replace with the sensor is circled in red. I don't use the 'Fine Tune' potentiometer next to this, so please ignore.


texts: program evaluating if clause incorrectly

texts:
As the title says i'm having a problem with an if clause evaluating incorrectly in one particular function

uint16_t    getSleepTime()
{
    volatile uint8_t flag = EEPROM.read(3);

    uint8_t high    = EEPROM.read(0);
    uint8_t low     = EEPROM.read(1);

    if(flag != 0xaa);
    {
        Serial.println(flag);
        Serial.println("ERROR: SLEEP TIME NOT DEFINED, CANNOT CONTINUE.");
        while(true)
        {
            digitalWrite(PIN_LED, true);
            delay(250);
            digitalWrite(PIN_LED, false);
            delay(250);
            wdt_reset();
        }
    }

    return word(high, low);
}

the result is that the if function evaluates as true always
my first thought was, ok the eeprom wasn't written properly, hence i added the println, the returned value was 170 == 0xaa
then i thought well maybe the flag variable is optimized out, hence the volatile
and then, well maybe its a type comparison issue so i also defined a const uint8_t flagv with value 0xaa
same results in every case

13:21:00.991 -> 170
13:21:00.991 -> ERROR: SLEEP TIME NOT DEFINED, CANNOT CONTINUE.
and the corresponding blink

the thing is that being such a trivial code i'm out of ideas right now, as anyone here experienced something like this?


texts:
In my past projects I created tcp server-client architecture to communicate mobil apps. For instance, I created an AP on ESP8266, mobile phone connects to AP send some data then esp8266 send response to app then socket closes.
I want to create this architecture over BLE. I got Neil Kolbans BLE libraries and did some examples. Libraries contains Notify methods. I thought I can do it with notify?
If you have any experience or examples/tutorials about this topic, can you share?


texts: Sending to Arduino UNO multiple values from Python code

texts:
I'm starting to learn how to work with Arduino, particularly communication between a Python code running on a PC and an Arduino Uno.

So I decided to start with what I thought to be a easy task. That is, sending the user input from Python. There are 2 values, one delay between Arduino LED (port 13) and the servo angle.

It didn't work and I couldn't find any answers, hope you can help me.

Arduino Code -

#include <Servo.h>

const int ledPin = 13; // pin the LED is attached to
int incomingByte = 1000;      // variable stores  serial data
int pos = 0;
int incoming[2];
Servo myservo;

void setup() {
  // initialize serial communication:
  Serial.begin(9600);
  myservo.attach(9);
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
   digitalWrite(ledPin, HIGH);
   myservo.write(180);
   delay(1000);
   digitalWrite(ledPin, LOW);
   myservo.write(0);
}

void loop()
{

  if (Serial.available()>=2)
  {
     for (int i = 0; i < 1; i++)
     {
      incoming[i] = Serial.read();
     }
    digitalWrite(ledPin, HIGH);
    delay(incoming[0]);
    digitalWrite(ledPin, LOW);
    myservo.write(incoming[1]);
  }
}

Python (3.7) code -

import serial
import time

ser = serial.Serial('COM5', 9600, timeout=1)

user_input = '1'
while user_input != 'q':
    user_input = input("'Blink time is or q = quit' : ")
    servo_input = input("What position servo go? ")
    byte_command = str.encode(user_input)
    ser.write(byte_command)
    servo_command = str.encode(servo_input)
    ser.write(servo_command)
    time.sleep(0.5)

print('\nq entered. Exiting the program')
ser.close()


texts: How to record steps a stepper motor takes and how to rotate it backward and forward with analog input?

texts:
I am trying to control a stepper motor's movements with a pressure sensor input (0 to 5 V digital). For example, if the input is 4 V then the stepper motor should move forward 4 steps. If the input is 3 V then it should come backward 1 step. Please suggest a command in Arduino to keep record of the previous sensor value and steps taken by stepper motor.

This is the code I have written for simple rotation of the motor:

const int stepPin = 8;
const int dirPin = 9;
int sensorValue=A0;
int i;

void setup() {
  Serial.begin(9600);
  pinMode(sensorValue, INPUT);
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
}

void loop() {
  sensorValue = analogRead(A0);
  float voltage = sensorValue * (5.0 / 1023.0);
  if(voltage==1) {
    digitalWrite(dirPin, HIGH);
    for(int x = 0; x < 200; x++) {
      digitalWrite(stepPin, HIGH);
      delayMicroseconds(5000);
      digitalWrite(stepPin, LOW);
      delayMicroseconds(5000);
    }
    delay(1000); // One second delay
  }
  digitalWrite(dirPin, LOW);
  for(int x = 0; x < 200; x++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(500);
  }
  delay(1000);
  while(1);//only once
}


texts: Reading from a pin Arduino Uno (assembly)

texts:
I am creating a project in which an Arduino reads (gets) a value from
a DHT sensor. The DHT sensor returns two values:

Temperature
Humidity

My assembly code:

sbi ddrd,5
cbi ddrd,2
sbi portd,5

start:

in r16,Pind2
cpi r16,80
brne On

jmp start

On:
cbi portd ,5
jmp start

After the code, the light remains turned on, but if the sensor sends '80'
and I get it correctly it should be turned off.

Question: Am I Using the write way to read a pin?


texts:
I was trying to evaluate the speed of communication between pc and Arduino, using this code in Arduino:

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

void loop() {
  Serial.println("Ciao Arduino");
}

and this in Python:

import time, serial

arduino = serial.Serial('/dev/cu.usbmodem1421', 250000)

time.sleep(3)
count = 0
start = time.time()
while True:
   a = arduino.readline()
   print a
   count = count+1
   time1 = time.time()
   if time1-start >1 :
      print "--" + str(count)
      print a
      count = 0
      start=time1

Wich print out how many readline() he managed to do to evaluate the speed in further project.
And I realized two things:

The program is working even with different baudrate
and with correct baudrate(For ex. 300-300 or 250000-25000) the baudrate is irrelevant(and wrong), I mean the 300 baudrate makes 20000 readline() and the 250000 make 5000 of them.

What's the problem? thank you


texts:
My MkrWan running on 5v 3A external adapter without battery. When short time(15-20 second) power outage happens Mkrwan still seems running. I think it consumes power on capacitors on adapter but voltage value drops. When electric comes back, it doesnt work anymore. Why it doesnt reset itself ?
How to solve this problem ?


texts:
Can I power a Wemos D1 R2 via the VIN and GND pins?
If so, at what voltage?


texts: Need help in the project "Arduino for audio processing"

texts:
I am following this link from Instructables site:

http://www.instructables.com/id/Arduino-Audio-Input/

My question is:

Instead of using the Microphone Radioshack 33-3038, which is listed in the tutorial, can I use https://www.sparkfun.com/products/9964?

Kindly suggest if there any modifications required in other parts for the circuitry, if I go for Electret Microphone.


texts: Adding HC-SR04 ultrasonic sensor to the board

texts:
I would like to add three more HC-SR04 sensor

Currently I have combined the Arduino UNO R3 with the AR 293d(refer to below graph), and pluged in one HC-SR04 sensor to the SRO4 hole at the left top corner. So I need to find the holes for t3 more sensor.

I have done some research already , for the connection , found more document

HC-SR04 Arduino
Vcc     +5V
Trig    GPIO
Echo    GPIO
GND     GND

The questions are ,

1) From the above graph, is that mean I can only add two more sensor to the board , since there are only 2 more 5V, GND , 12 , 13 pins (at the top and bottom holes)

2) How can I connect them separately ? That means, what I need to connect from sensor to the board?

3) If I need other board eg. breadboard to connect them, How should I connect sensor to breadboard and how can I connect it with the main board(AR 293d)?

Thanks a lot for helping. Any answer is useful for me


texts:
I have the components as shown and I installed the TinyGPS library.

I'm pretty new to hardware stuff and I'm not sure if these wires would work? (pins on both sides)

The GPS module has 5 pins - GND,5V,IN,OUT and I can barely read the last one. I'm assuming I need to connect only the first 4?

Thanks a lot.


texts: How to call multiple delayed functions using a single millis()

texts:
I am working in a project where I need to call more than 1 functions actually 4 functions using a single millis()
Here is the code below.
 unsigned long then = 0;

 void loop(){

     unsigned long now = millis();

     if(now-then >=0){

         Serial.println("Function 1 called");

     }else if(now-then>=2000){

         Serial.println("Function 2 called");

     }else if(now-then>=4000){

         Serial.println("Function 3 called");

     }else if(now-then>=6000){

        Serial.println("Function 4 called");

         Serial.println("The end");

         then = now;
     }
 }

All the functions above gets run successfully but not in a proper sequence.
The running sequence of the functions seem to be very improper and random.
The 'function 1' gets executed in a proper sequence and timing but rest of the others are making a messy output.
How can I fix it please?
Thanks.


texts:
Parts

Arduino Uno R3 (Atmega328 - assembled)
Adafruit Bicolor LED Square Pixel Matrix with I2C
Backpack
Electret Microphone Amplifier - MAX4466 with Adjustable Gain
Half-size Breadboard
Breadboarding wires

Description
I have been following the build guide for the "Piccolo Music Visualizer" on the Adafruit website (https://learn.adafruit.com/piccolo?view=all), using all of the same components and code (following the guide exactly as shown). I first tested the 8x8 matrix to see if it was working properly, and it works beautifully. The problems started when I wired up the electret microphone...

In regard to how I wired this to the breadboard, I followed the example for the R3 on the Adafruit guide (since that's my current version):

Note
The files (code) used for this project are found here: (https://github.com/adafruit/piccolo). The ffft file is supposed to be saved to the library (this worked for me). The Piccolo file is supposed to be saved to the Sketchbook (this did not work for me - kept giving error messages when trying to reference it). I instead copied the code found in the Piccolo file, and saved it as a new sketchbook file. Let me know if this might be the cause of the problem. This is my first arduino project, so I am still trying to figure out how the IDE works.

Problem
The electret microphone is supposed to pick up audio and the LED matrix should display a waveform based on the loudness and frequency of the audio. Instead, I only have 2 bars on the bottom left lighting up (the effect is static - wont respond to volume or frequency changes). Oddly, when pulling out the microphone from the breadboard, the waveform begins displaying as it should, but in a glitchy/unstable form. I figured the problem was with the adjustable gain on the microphone, but no matter how much I adjust the screw only the 2 bars are affected and still static (when adjusted to the left only green LED, in middle is green and orange, to the right is red/orange/green on the matrix).

A little confused as to what the problem could be... is the microphone broken, code malfunctioning, wiring incorrect, etc.

Pictures to reference (DropBox link):
- See comment below for link (must have 10 rep to use more than 2 links in post)
(zip file contains 3 pictures: "wiring", "when_on", "pulling_out_mic")
Photos are over 2MB so I couldnt upload here.


texts: Is it possible to use Arduino UNO programmer for other AVR microcontrollers?

texts:
I got an Arduino UNO which I started using with microc for avr to add more customizations.
I'm wondering if it is possible to use the Arduino UNO programmer to program other AVR microcontrollers (I know that it is possible using ATmega 328p and 168).


texts: Can I use this pinhole camera with arduino?

texts:
The pinhole camera is a 420TVL, 3.7mm Passive Infrared Detector Color Covert Security Camera. Can I use this camera with an arduino creation?

Things I don't know to answer the question:

Does the power need something special arduino can't offer?
Is the arduino powerful enough to push the video feed/photos to a computer or any other method to video/photos.

Here are some specs from the site:

  Sensor   1/3" Sony Super HAD II CCD
  Picture Elements  NTSC 768x494
  PAL 752x582
  Horizontal Resolution 420 TVL
  Minimum Illumination  0.001 Lux
  S/N Ratio more than 50dB
  Scanning System   2:1 interlace
  Synchronous System    Internal, Negative sync
  Auto Electronic Shutter   NTSC 1/60s ~ 1/100,000s
  PAL 1/50s ~ 1/100,000s
  Gamma Characteristics 0.45
  Video Output  1 Vpp, 75 ohms
  Auto Gain Control Auto
  Power / Current   DC 12V (±10%) / 150mA
  Lens  3.7mm Taper Pinhole Lens

Is it possible? They're on sale but I don't want to throw money away and find out that they don't work with any arduino. Also, I don't have any setup for this to be plugged into. Therefore, I'm not tied down to previous creations the cameras need to fit in.


texts:
The uArm is a robot arm with a suction cup (or gripper). I'd like to try to make just the suction part of it, and I'm wondering what components I'd need?

By the looks of it, I'd need a hobby vacuum pump, but these seem few and far between on UK components sites.

How would I power it? It looks like they're all 12v, and I believe Arduino gives you 5v?

Exact what components would I need? Do I need any shields?

Here's a short video of the suction cup I'd like to copy:


texts: Connect SD card to Arduino with or without a level shifter

texts: I have some audio files in an SD card and I want to play them using Arduino, thus connect the SD card to the Arduino. Since the transfer of the data will be from the SD card (+3.3V) to the Arduino (+5.0V) and not vice versa, is a level shifter necessary?


texts:
I am recieving SD card failuer and I did everything I could.
I use the correct SPI pins;
CS > 10
MOSI > 11
MISO > 12
SCK > 13
VCC > 5v
GND > GND

I did format my SD card to FAT32
I did write;
pinMode(csPin, OUTPUT);
digitalWrite(csPin, HIGH);

and I did add a blank file to sd card.
pls make harambe live ;-;
here is my code;
#include <pcmConfig.h>
#include <pcmRF.h>
#include <TMRpcm.h>
#include <SD.h>
#define sd_pin 10
TMRpcm tmr;

int speaker_pin = 3;
int trig_pin = 8;
int echo_pin = 9;
int buzzer_pin = 6;
long cm;
long lecture_echo;

void setup()
{
  Serial.begin(9600);
  Serial.println("active");

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

  if(!SD.begin(sd_pin)){
    Serial.println("harambe is dead");
    return;
  }
  else{
    Serial.println("harambe is alive");
  }

  tmr.speakerPin = speaker_pin;

  pinMode(echo_pin, INPUT);
  digitalWrite(trig_pin, LOW);
  pinMode(trig_pin, OUTPUT);

  pinMode(buzzer_pin, OUTPUT);

}

void loop()
{
  digitalWrite(trig_pin, HIGH);
  delay(100);
  digitalWrite(trig_pin, LOW);

  lecture_echo = pulseIn(echo_pin, HIGH);
  cm = lecture_echo / 58;

  Serial.println(cm);
  delay(500);

  if(cm < 4)
    {

    }
  else
    {
      tmr.setVolume(5);
      tmr.play("test");
    }
}


texts: Program crashes when I use Serial.println()?

texts:
I'm working with a fuzzy logic controller with Arduino, I'm trying to emulate an AC by entering inputs [temperature and humidity] using two potentiometers and the output is the AC power.

This is the basic part of the program, every thing is good, I can print the values of Temp and HU. But when I try to print the value of the Power, nothing happens, and the serial monitor displays nothing. By trial and error, I can see that Serial.println with power or any variable related to power crashes the program. What may be the reason?

    void loop()
{
    // Read Input: Temperature
    ttemp = analogRead(temp);

    Serial.println("the analoge Tempreture is ");
    Serial.println (ttemp);

    ttemp = map(ttemp, 0, 1023, 5, 65);
    ttemp = constrain(ttemp, 5, 65);

    Serial.println("the actual Tempreture is ");
    Serial.println (ttemp);
    Serial.println("-------------------------");
    delay(100);

    g_fisInput[0] = ttemp;

    // Read Input: Humidity
    hhu = analogRead(hu);
    Serial.println("the analoge Humidity is ");
    Serial.println (hhu);

    hhu = map(hhu, 0, 1023, 16, 100);
    hhu = constrain(hhu, 16, 100);

    Serial.println("the actual Humidity is ");
    Serial.println (hhu);
    Serial.println("-----------------------");
    delay(100);
    g_fisInput[1] = hhu;

    g_fisOutput[0] = 0;

    fis_evaluate();

    // Set output vlaue: Power
    int ppower1 = g_fisOutput[0];
   // Serial.println("the actual Power is ");
   // Serial.println (ppower1);
    ppower = map(ppower1,100,3000,0,255);
    ppower = constrain (ppower, 0,255);
    analogWrite(power , ppower);

   // Serial.println("the analoge Tempreture is ");
    //Serial.println (ppower);
   // Serial.println("--------------------------");

}


texts: Digital LED clock - matrix circuit question

texts:
i'm making a digital clock.
Right now the plan is to matrix them on a atmega328 using transistors.
I figured i need a transistor on both sides or the current would be sinked/sourced by the atmega, which is not what i want.

I'd rather use the MAX7219 but i'm not sure if it's possible to use transistors, because i don't think the MAX7219 can handle the current.

I found the circuits here, i smushed them together, is this correct? Idk.

This is the led segment i'm using, there's four of them. So four 337 transistors, one for each digit. And seven 327 transistors, one for each segment.
I will scan through the four digits and turn on the apropriate segment.

So yea, please let me know if this is totally wacky or something else.

Edit :
I guess this would be 1 digit. Sorry it's confusing to draw the whole matrix. I hope this clears it up. It's just a normal matrixing situation but with more leds.

So normally it goes something like this :
The cathodes of the leds are controlled directly by the atmega, but results in the atmega supplying the current. So my reasoning would be to put a row of transistors there instead, would that be correct?


texts: How to use ADC interrupt on STM32 blue pill

texts:
I'm currently using the STM32F1xx boards from http://dan.drown.org/stm32duino/package_STM32duino_index.json
To program my blue pill but I can’t find how to write the interrupt for the ADC. I’ve set the registers to output an interrupt when it finishes but I can’t find how to write the code for the interrupt.
I’ve tried the ”ISR(ADC_vect)” function which works for arduino, but the compiler is complaining that ”ISR” is not recognized. I’ve tried to look for the documentation for the STM32duino, but the little I could find didn’t even mention the ADC or any interrupt routines. I’ve searched though the STM32duino forum without any luck. If anyone knows how to solve this or where to find information about interrupt code for the STM32 boards I would be very happy :)


texts: Can I connect to WiFi with an Arduino, "wireless SD shield" and XBee

texts:
I want to create a growhouse sensor system. I have an Arduino UNO, wireless SD shield and I have just ordered a series 2 XBee XB24.

Any info I find seems to revolve around having 2 Arduinos and 2 XBee modules, why is that?

I am presuming that once I connect the XBee to the shield that I can then connect to my Arduino on the network and send and receive data, am I wrong?

I'm a developer and sysadmin but a noob to Arduino so any help is much appreciated.


texts:
Im using a 5v 1A power supply and connected to VIN pin on the NodeMCU. I also use 18650 battery to keep NodeMCU running in case the power supply shuts off due to power interruption.

I'm planning to use the 5V from power supply, convert it to 3.3V with voltage divider and connect it to the gpio to detect power interruption.

Is it possible? Can the NodeMCU handle the current from the power supply?


texts:
I am trying to load some variables from an SD card on the start up of my arduino Uno. I have been given some advice but am unable to communicate at the same hours. Using this advice, I have the following edited code, but it doesn't work and I believe that it's my implementation that is the problem. All help would be greatly appreciated.

myFile = SD.open("test.txt", FILE_READ);
    if (myFile) {
        while (myFile.available()) {
            myFile.read();

            km = myFile.parseInt();
            kmTemp = myFile.parseFloat();
            kmrevs = myFile.parseInt();
            miles = myFile.parseInt();
            milesTemp = myFile.parseFloat();
            milesrevs = myFile.parseInt();

            }
        myFile.close();
        }
    else {
        Serial.println("Read Error");
    }


texts: How to connect receiver in an Arduino with a motor shield?

texts:
I have an Adafruit motor shield v1 stacked on an Arduino Uno. I want to add a 433Mhz receiver to the Uno so I can control it wirelessly. However as you know the motor shield completely covers the Arduino board and all its pins, except perhaps the analog ones (it appeared to me).

So can you please suggest a way to connect the receiver if possible. I desperately need it and can't afford to buy a Mega now.

Please help asap.


texts: Digital I/O threshold voltages for ATmega32u4

texts:
What are the voltages on a ATmega32u4 (eg Arduino Leonardo) such that a HIGH or LOW is read?

I want to ensure that I'm reading the chip reference manual correctly, where Table 29-1 says:

VIL: Input Low Voltage, Except XTAL1 and Reset pin

Min: -0.5
Max: 0.2VCC-0.1V (LVTTL)

VIH: Input High Voltage, Except XTAL1 and RESET pins

Min: 0.2VCC+0.9V (LVTTL)
Max: VCC + 0.5V

My questions:

What is LVTTL?
How do I interpret the VIL Max and VIH Min?
Is the input undefined between those two values?


texts:
I am trying to serial print the value of b[0][0].

Has to be zero but it dose not work!

Here is the code

void setup() {
  Serial.begin(115200);
  byte b[321][241];
  Serial.println(b[0][0]);
}

void loop() {

}

If the array is small like b[2][2] it dose work

In theory esp32 has ram of  520 KiB SRAM so can this be a problem?

Here is the error code

rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6352
entry 0x400806b8

The code complies fine but the error gets when esp32 is running

esp32 version for arduino is 1.0.4


texts:
I am looking make my own version of theses digital relay/FET controllers so I can have more usability and matrixes.
Switch pro sp9100
it looks like to me they send a serial signal to the controller and then the controller turns the relays on and off. I believe I should be able to achieve the same thing with a arduino and a relay board. I thought about using resistors to sence voltage drop across the switches but then that would limit me to momentary switches only and no latching switches. Just need some help getting in the right direction. Does anyone know of a protocol or have a idea that would work good for this?
First idea
[1]: https://raspberrypi.stackexchange.com/questions/24488/how-can-i-combine-many-inputs-on-one-pin


texts: How do I run multiple vibration motors from an Arduino Mini with PWM?

texts:
I'm building a project for my Physical Computing class that involves 4 vibration motors for varied haptic feedback based on serial input via analogRead. I have each coming out of their own pin and assigned to conditionals.

I'm wondering:

how do i control the PWM of each individual motor?
assuming I need an external power source for the motors, do I need to have a diode and transistor in between each motor and the ground?

Thanks in advance - I'm still learning but definitely looking forward to taking Part II next semester!


texts: Reducing Clock Speed increases sketch size?

texts:
I just lowered the clock speed of my arduino promini 3.3v - 328p from 8Mhz to 1Mhz on the external clock disabling the brounout detection and when I compiled I my old sketch it wouldn't upload any more because suddenly the size has increased from 31KB to 35KB.

Does anyone know why this could happen. I didn't make any changes in the code and it still loads into the 8Mhz Arduino without any problems.

I used these low power config files: https://github.com/joe-speedboat/Arduino-LowPower


texts:
I'm trying to make a use of a relay module,
I want a clear way to configure and control my relay module
I've defined the struct and filled it with some info about id, pin number, title, and relay state
I can't loop with for in the array of controls, because I can't get the sizeof the array right
typedef struct{
  int id;
  int pin;
  String title;
  bool state;
}  SwitchControl;

SwitchControl controls[2] = {
  {1, 22, "Switch 01", 1},
  {2, 23, "Switch 02", 0},
};

for(int i=0; i<sizeof(controls) - 1; i++){
}

thanks


texts: Want to make an “On Air” sign that corresponds to my computer’s mic status

texts:
I have an idea for a project but I’m not sure where to start. I’m a web developer but I’ve never worked with hardware before.
I’d like to make an “On Air” sign that is connected to my computer via USB and turns on when the computer mic is on, and turns off when the mic is muted.
Is this possible with arduino?


texts: Arduino Mega Pins for SoftwareSerial (vs. AltSoftSerial)

texts:
I am currently looking at using an Arduino Mega to build a MIDI Receive box that will then pump the data over USB, but am having design issues/uncertainties with the Arduino's receiving end.

I am looking to having (hopefully) 16 MIDI (as 5-pin DINs) inputs on this build, with no outputs other than the USB. The Mega has the 4 Rx pins, which still leaves me with 12 to create in software. From what I've read it appears that SoftwareSerial will not support simultaneous reads from different inputs, while AlftSofSerial does. However, it also appears (at least from what I've gathered) that AltSoftSerial is not supported on as many pins as I would need to make this work.

With my setup up, not all 16 MIDI devices would be sending data into the Arduino at once, but only 2 - 4; these would be operating at the same time though (i.e. a Keyboard note along with a volume fader), so I don't believe SoftwareSerial would work well for what I need.

Is it possible to work out what I need with SoftwareSerial/AltSoftSerial and the physical UARTs? If there's any necessary info that seems to be missing or I seem to be misunderstanding something, please let me know. Thanks!


texts:
I try to communicate with my Arduino clone (Elegoo Uno R3) from Arduino IDE (v1.8.4 installed by dnf from repos) at Fedora 27. Compiling and upload of normal example code works well. However, as I try to start any serial communication (e.g. for debug), the compiler fails returning following segfault:

"/usr/bin/avr-gcc"  -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p  -o "/tmp/arduino_build_407070/AnalogReadSerial.ino.elf" "/tmp/arduino_build_407070/sketch/AnalogReadSerial.ino.cpp.o" "/tmp/arduino_build_407070/../arduino_cache_983152/core/core_arduino_avr_uno_1621df717313d057c92202babd71649a.a" "-L/tmp/arduino_build_407070" -lm
lto1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugzilla.redhat.com/> for instructions.
lto-wrapper: fatal error: /usr/bin/avr-gcc returned 1 exit status
compilation terminated.
/usr/lib/gcc/avr/6.3.0/../../../../avr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Uno.

I found similar issue here https://github.com/sudar/Arduino-Makefile/issues/486 However, that solution deals with Arduino-Makefile software that is little bit complex for me.

I would appreciate any help either how to solve the segfault itself, or how to easily use Arduino-Makefile (I would like to compile from Arduino IDE or any user-friendly IDE).


texts:
I have the same problem with these two boards: Ruggeduino (Uno compatible) and DFRobot Romeo 1 (Duemilanove compatible). On one of my Macs (a Macbook Pro running 10.11.4), I can see a new port  /dev/cu.usbmodem641 or /dev/a4005g3t depending on the board. On the other computer (a Mac Mini late 2014), they just won't show. Same cable, same boards, and no hub. I don't know where to look to see an indication of a failure of some sort.

These two ones use a type-b USB socket (printer style)

Also on the Mac Mini that won't see any of those boards, I can connect an EtherMega2560 (Arduino Mega 2560) which happens to use a micro USB socket. I don't know if that is related to the problem.

Both computers run the same OS (OS X 10.11.4) and the latest version of Arduino.

Here is a difference (found in /var/log/system.log):

On the working computer:

Mar  3 22:20:42 pc101 kernel[0]: AppleUSBFTDI: fInBufPool,kMaxInBufPool 8,64
Mar  3 22:20:42 pc101 kernel[0]: AppleUSBFTDI: Version number - 5.0.0, Input buffers 8, Output buffers 16

On the non working one:

cfprefsd[114]: BUG in libdispatch: 15E49a - 1718 - 0x0

..


texts: Is it possible to configure uboot without the "Yun Serial Terminal" sketch by using the hardware serial on pins 0 and 1 instead?

texts:
Trying to rescue a Yun with the 1.5.3 image.
It's not possible to upload the required "Yun Serial Terminal" sketch  because the device hangs at U-Boot (hence the rescue attempt).
Using putty serial with:
Pin 0 (Rx)
Pin 1 (Tx)
Baud: 250000
8N1
This capture shows the result (which is the best I can find so far).
How do I properly connect to the serial console using the GPIO pins?


texts:
I am currently developing a project that needs 9 led stripes, each led stripe has 5 meters, 300 leds, it consumes 60W per stripe in a total of 540W...

This are the led stripes - 5M 12W/M 24V SMD 2835

This led stripes use a 24V power supply.

The thing is I want to drive them with an arduino and PWM. What would I need to do it. I was looking for something like CAT4101 but I never dealt with so much power before and I would like your advice.

Thanks


texts: How far can i go just with this starter kit?

texts:
I want to buy this kit: http://www.banggood.com/UNO-Basic-Starter-Learning-Kit-Upgrade-Version-For-Arduino-p-970714.html

However, as shipping stuff from China takes like 3 months to arrive, i need to be certain i won't have much else to buy.

How far can i go just with this kit, and what would you recommend me buying together with it?

Thanks in advance.


texts: Distance sensor - Not working on fabric surface

texts:
I am using ultrasonic HC-SO04, not giving reading on fabric. I lost many hours on testing my obstacle avoidance robot car in front of my sofa, every time it hits hard but works fine on other hard surfaces. Is there any other distance sensor which can detect soft objects like fabric from long or short distance?

Also looking any other accurate long distance cheap sensor which can work easily with Arduino. Please let me know.  Thanks


texts: How to convert string to byte array on arduino

texts: Well my title pretty much sums it up , how to convert string to byte array? i cant find any usefull code


texts: Connect optocoupler 4N35 to Arduino Uno to control LED light strips

texts:
I want to use an Arduino Uno to control the LED light strips, based on the input signal from a robot controller. The robot controller sends a digital signal with "HIGH" of 24 V and "LOW" of 0 V.  I have thought of using an optocoupler between the robot controller and the Arduino to reduce the voltage from 24 V to 5 V, suitable for the Arduino pin.

Can I connect the optocoupler's emitter to the Arduino ground?

The LED strips work on 12V DC and at 2000mA. If I power the Arduino with 12V DC power source connected to the DC jack, can I give the power to the LED's also using the V-in pin of the Arduino?

Please look at my circuit and tell me where I went wrong and why?


texts: Interrupting a servo sweep with a force sensor

texts:
this is my first time dealing with arduinos and I have a school assignment. I have a servo and a force sensor. When "1" (a character, not an integer) is typed in the serial monitor, the servo needs to rotate 180 degrees but can be interrupted when the force sensor sends a value over let's say 300. And when "0" is typed in, the servo goes back to its initial position.
I have been trying really hard figuring this out.

I basically need to exit a loop when the analog value exceeds 300.

here's my code:

#include <Servo.h>
Servo myservo;

int initpos; //initial position of the servo before the sweep (this doesn't change)
int angle; //used to store the servo angle value (this changes)
char code; //the value entered in the serial monitor
int force; //value of the analog force sensor

void setup()
{
  initpos = 10;
  Serial.begin(9600);
  myservo.attach(4);

  myservo.write(170); // makes the servo sweep(absolutelly useless for my project but I left it there)
  delay(500);         //
  myservo.write(10);  //
  delay(500);         //

  code = Serial.read();

}

void loop()
{

  if(Serial.available())
  {

    angle = initpos;
    force = analogRead(A1);
    Serial.println(force);

    for(angle = 0; angle < 180; angle += 1)
    {
      if (code == "1" and force <= 300)
      {
        angle += 1;
        Serial.print(code);
        myservo.write(angle);
      }

      else if(code == "0")
      {
        myservo.write(initpos);
      }
    }

  }
}

any help is deeply appreciated and if there is already a topic on this please redirect me to it


texts:
In the sketch I'm working on, I'm storing several 1-bit values representing different boolean states in a single byte, trying to save precious RAM.
(example for 5 boolean states: dec10 = b00001010, the five states are 0, 1, 0, 1, 0)

I'm then using an if statement to determine if the relevant bit is TRUE or FALSE:
if ((options>>3) & 1 == 1)

The above will evaluate true when the relevant bit is 1, so if I want to carry out something in that case, great, no problem!

However, if I want my if statement to evaluate TRUE in the event that the relevant bit is 0, I can't work out what code I need.

I thought the problem might be that the other 'non-relevant' bits were interfering, so I tried bit shifting the LSB all the way to MSB position and then shifting back to LSB:
if ((options<<4>>7) & 1 == 0)
but this still isn't doing what I'm trying to achieve (and seems like a lot of work for the processor).

It also feels like I've tried just about every combination of ~&0, !&0, ==0, !=0, ~&1, !&1, ==1, !=1 there is, but I must have missed something...

Can anyone tell me how I get an if statement to evaluate true in the event that the bit is a zero?


texts:
I am trying to learn how to use a Rotary Encoder together with an LCD display where I can use the encoder to choose Letters that will be printed in the LCD.

This is the kind of result I should be getting, but instead I am getting this:

1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16

c  d  e  f  0  1  2  3  4  5   6   7   8   9   a   b

10 00 10 00 11 01 11 01 10 00  10  00  11  01  11  01

A:
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0

B:
0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1

Shouldn't I be getting a sort of
001100110
100110011
pattern to be able to tell which way it is rotated?
How can I fix this?
I am using the following connections:


texts: Is there a way to use the atmega 32u4 breakout board to make a mp3 player without the mp3 shield?


texts: How can I pass a char array as the parameter to a function?

texts:
I am creating a menu for adjusting system variables.

The menu is made up of pointers like so:

char* options4[] = {"hMin1", "hMax1", "refr1", "fSpeed1"};

I want to pass the selected string as the parameter for an 'adjust' function for use in some conditional logic and for display on a HCMAX7219 7 segment display. Here's what I've got:

int option = 0;
float variable = 82.0;

if(Serial.available() > 0) {
  key = Serial.read();
  if(key == back) {
    return;
  } else if(key == fwd) {
    float newVar = adjust(String(options4[option%4]), variable);
  } else if(key == down) {
    option++;
  } else if(key == up) {
    option--;
  }
}

float adjust(char* str, float var) {
  ...do some stuff...
  display.print7Seg(str, 8);
  EDIT: forgot this call..
  display.print7Seg(var, 1, 4);
  ...do stuff to var...
  return var;
}

The library function takes (char[] TextString, unsigned int Offset) as it's parameters.

EDIT: the library also has functions print7Seg(long number, byte decimalPlace, unsigned int Offset) and print7Seg(long number, unsigned int Offset)

Now I'm new to pointers, but I can see that I am passing a pointer to my adjust function, and expecting it to dig out a char array from memory. I can't see any problems with that, though I may be missing something. When I try to compile, the IDE just crashes with exit status 84; so no debug info.

Am I going about this the wrong way?


texts: How to execute three functions at the same time?

texts: How to implement three functions, which can execute in the same time (function of input random variables)?


texts:
I am currently playing with Arduino timers (on UNO currently) and I am building a library that  has a function that must be called every millisecond.

There is plenty of code samples on Internet so I went with something that seemed perfect for my needs. I have then updated it to make it a reusable C++ class.

Here is my code (simplified to just isolate the issue):

#define BIT(x) (0x01 << (x))

static volatile uint32_t milliseconds = 0;

class Timer
{
    public:
    Timer()
    {
        // Disable interrupts
        uint8_t savedStatus = SREG;
        cli();
        // Use Timer2 with 1 ms interrupts
        // OC2A & OC2B disconnected, mode 2 (CTC, Clear Timer on Compare match)
        TCCR2A = BIT(WGM21);
        // Don't force output compare (FOCA & FOCB), mode 2, Clock Select clk/128 (CS = 5)
        TCCR2B = BIT(CS22) | BIT(CS20);
        // Set timer counter compare match (when value reached, 1ms has elapsed)
        OCR2A = 125 - 1;
        // Reset Timer2 counter
        TCNT2 = 0;
        // Set Timer2 interrupt mode (Set interrupt on OCR2A compare match)
        TIMSK2 = BIT(OCIE2A);

        // Restore interrupt enabling state
        SREG = savedStatus;
    }
};

static void callEveryMillisecond(uint32_t ms)
{
    // Do something here
}

// Attach interrupt routine to the Timer Compare Interrupt
ISR(TIMER2_COMPA_vect)
{
    milliseconds++;
    callEveryMillisecond(milliseconds);
}

After checking ATmega328 datasheet (section 17) several times, I came to the conclusion that what I do in Timer class constructor above is correct, and for Arduino UNO, the values used must lead to one call of the ISR every ms:

CPU frequency = 16MHz
Prescaler = 128
-> timer frequency = 16MHz/128 = 125KHz
-> max counter value = 125

I decided to use the CTC (Clear Timer on Compare match) mode, which means that when the timer TCNT2 (which is incremented at 125KHz frequency), reaches OCR2A value, then it will trigger the ISR, and then will be reset on next tick; the additional tick to reset the counter explains why we use 125 - 1 for OCR2A and not just 125.

Now comes the weird stuff. In order to check that my code worked, I decided to blink the LED on pin 13 every 10 seconds, hence I have added the following code to my program:

static void callEveryMillisecond(uint32_t ms)
{
    if (ms % 10000 == 0)
        digitalWrite(13, digitalRead(13) ^ 1);
}

static Timer timer;

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

void loop()
{
}

Then I measured the time during which pin 13 LED is lit on (or off, both measures are the same). Measures are not very accurate (I just used my wristwatch) but good enough for my check.

I was surprised to see the measured time to be about 20 seconds instead of 10s.

Initially I thought about a mismatch in CPU frequency, but after performing a lot of small changes, here is what I found which worked perfectly:

//static Timer timer;

void setup()
{
    static Timer timer;
    pinMode(13, OUTPUT);
}

Just moving the Timer instance into setup() did the trick: my measures rightly indicated 10 seconds between 2 states of the pin 13 LED.

Now my questions are:

Why the second code sample works perfectly, whereas the first does not?
Is there, in standard Arduino included code, some code that would overwrite some of the settings I perform for Timer2 in Timer::Timer()?
Is there a way to make the first code sample work? Note that I don't like the second sample because it does not seem natural coding, also, I will need access to Timer timer instance in several locations of my future program, hence it can't be possible if it is declared in the scope of setup().


texts:
I'm preparing this kit on eBay to create the following instructable - http://www.instructables.com/id/4x4x4-RGB-LED-Cube/
But I have doubts about 0.1uF and 22pF capacitors since the once on eBay are 50v. Also MOSFETs - instructable uses IRF9531 but the ones I found on eBay are IRF9540N.
Is the equipment I added on eBay compatible with instructable?


texts: I'm doing my project regarding 40khz ultrasonic sensor which will be used to get accurate distance measurements. I have a separate transmitter and receiver. I want to get the time between the moment my transmitter transmitted the waves and the time my receiver received it. However, I couldn't actually make it work. Does any of you give me a code that would help me transmit and receive the 40khz waves and get the time in between so I could use it to compute for the distance?Thank you in advance. I would greatly appreciate it!


texts: sent commends by bluetooth to sd card as one line of string

texts:
void loop() {

  if (Bluetooth.available() > 0) {
           dataIn = Bluetooth.readString();
   //the problem is here
           while(dataIn !=""){
                   dataSd += dataIn;
                   dataSd += "," ;
           }

 if (dataIn.startsWith("s1")) {-----------}
 if (dataIn.startsWith("save"){ save to sd card }

// what I want is to sent command by bluetooth to variable dataSd as a line
of string seperated by commas
like ("left,right,up,down,left,stop,right") and  when i send command save, it
will save to sd card, but this code didnt work


texts:
I am using an Arduino UNO along with a Cooking Hacks CAN Bus Module and Multiprotocol Radio Shield. The CAN module is connected to the radio shield which is plugged into the Arduino. I got this radio shield keeping future applications in mind where I can combine multiple protocols, for eg. CAN and Bluetooth.

I connected them through an OBD2-DB9 cable to the car's OBD port but noticed that I was not really getting any messages. Well I am getting messages but just:

   -- Constructor Can(uint16_t speed) --
   SPI configured
   The MCP2515 has been successfully reset, configuration mode activated
   Speed=500kps
   -- End Constructor Can(uint16_t speed) --

   Data in buffer 0
   id: 7FF  rtr: FFFFFFFF => Data in buffer 0
   id: 7FF  rtr: FFFFFFFF => Data in buffer 0
   id: 7FF  rtr: FFFFFFFF => Data in buffer 0

After analysing the connections, I realised that the hardware is probably fine since the continuity between the pins of the cables is fine and the CAN module(MCP2515 + MCP2551) is receiving power and I also checked the voltages at the pins and think they're mostly fine apart from a few pins which I'm not sure about. Which brings me to the software issue. I can see that the SPI is not getting configured properly and the MCP2515 controller doesn't enter configuration mode which means the bit times defined are not being used and hence the controller is not initialising like it should. I even tried manually changing to configuration mode by changing the values of the REQOP bits of the CANCTRL register as opposed to doing a software reset which was how I was doing it initially. Even then, no luck. To verify the SPI connection, I chose a random read/write control register like BFPCTRL and wrote a value to it and then read it back to verify that it matched the values I wrote. However, the value read back is not the same as the value I wrote. Also, the controller only has trouble going into configuration mode. It seems to change to normal and listen only mode without problem since the CANSTAT register displays the correct values for the REQOP bits. I don't understand why the controller has problem entering configuration mode but no problem changing to the other modes. Can anybody help me?

SPI Code:

    bool CAN::begin(uint16_t speed)
    {
    #if (DEBUGMODE ==1 )
    Serial.println("-- Constructor Can(uint16_t speed) --");
    #endif

    //Initialization SPI
    SPI.begin();
    SPI.detachInterrupt();
    SPI.setBitOrder(MSBFIRST);
    // both mode 0 & 3 should work
    SPI.setDataMode(SPI_MODE0);

    //Set the SPI frequency
    SPI.setClockDivider(SPI_CLOCK_DIV4);

    #if (DEBUGMODE==1)
    Serial.println("SPI configured");
    #endif

    //Configure MCP2515 pins
    pinMode(CAN_CS,OUTPUT);
    pinMode(CAN_INT,INPUT);
    digitalWrite(CAN_CS,HIGH);

    writeRegister(BFPCTRL, (1<<B0BFM) | (1<<B1BFM));
    int dat = readRegister(BFPCTRL<<2);
    Serial.println(dat);

    //Software resets MCP2515
    reset();
    delay(100);
    //After the reset, controller enters configuration mode
    dispMode();

When I read back the values of B0BFM and B1BFM bits, they should be 1 but the display says that their values are 0.

   void CAN::writeRegister( char direction, char data )
   {
   //CS low to select the MCP2515
   digitalWrite(CAN_CS,LOW);

  SPI.transfer(SPI_WRITE);
  SPI.transfer(direction);
  SPI.transfer(data);

  //CS line again to release
  digitalWrite(CAN_CS,HIGH);
   }

  char CAN::readRegister(char direction)
  {
  char data;
  //CS low to select the MCP2515
  digitalWrite(CAN_CS,LOW);

  SPI.transfer(SPI_READ);
  SPI.transfer(direction);
  //Read data SPI
  data = SPI.transfer(0xff);

  //CS line again to release
  digitalWrite(CAN_CS,HIGH);
  return data;
  }


texts: Arduino Uno and Leonardo SPI clock can't be measured

texts:
I want to measure the SPI clock (pin 13) using the Arduino example code for the SPI library (very simple example). Basically independent from the loop function, the clock should be fired continuously.

I deployed the Arduino SPI example code on the board and measured pin 13 on an oscilloscope, but nothing was found, always zero volt.


texts: I am under the impression that the origin of RAM on a Cortex M is 0x20000000.  However, in the linker file for it, the ORIGIN of RAM is set to 0x1FFFF800.  Is that an error, or is there a reason for the discrepancy?