texts:
My little weather station is run on a Nano and has the anemometer and the temp/humidity sensor.  A smoke detector is on the way because I live where wildfire is a big concern.

I would like to build a simple weather vane without spending a lot to buy the commercial solutions.  Rotary potentiometers have dead spots and using a bunch of hall effect sensors would use up too many digital inputs to be useful, afaik.

Question:  How can I build a simple direction sensor?


texts: Using an Arduino as a crystal oscillator

texts:
I want to overclock my Game Boy Advance SP. It has a built-in 4 MHz crystal, and I was able to temporarily replace it with an 8 MHz crystal to see if I was able to overclock it, which I was :).

However I'm wondering if it's possible to emulate/simulate a crystal using an Arduino? Like instead of a crystal soldered to the Game Boy, two output pins from the Arduino? If not, is there a such thing as a variable oscillator? Like a crystal with a potentiometer to change the frequency when the potentiometer is adjusted?


texts: Problem in getting the output (language: Processing and Arduino IDE)

texts:
I am working on a small project with Processing and Arduino, in which, depending upon the value of a photoresistor, it displays whether it is day/night/evening.

I read the value from the photoresistor and write the value to the serial port. Then in Processing I read the value from the serial port and display depending on the value.

But I get a very flickery output, and there is always a -1 imprinted on the screen as shown in the video.

Please help me out.

link to the video

Code for Arduino:

int ldr1 = A0;
int x,y;

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

void loop() {
  x = analogRead(ldr1);
  Serial.write(x);
  delay(100);
}

Code for Processing:

import processing.serial.*;
Serial port;
int x,y;

void setup() {
  size(640, 320);
  port = new Serial(this, "COM3", 9600);
}

void draw() {
  background(0);
  x = port.read();
  text(x,100,100);
  if(x < 400 && x > 200) {
    textSize(32);
    fill(0,0,255);
    text("it is evening",200,200);
  }
  if(x < 200 && x > 20) {
    textSize(32);
    fill(0,255,0);
    text("it is night",200,200);
  }
  if(x > 400 && x < 900) {
    textSize(32);
    fill(255,0,0);
    text("it is morning",200,200);
  }
}


texts:
There is no error in the code it already stored 11 numbers in serial print  but the problem I want to input 11 numbers only in keypad That will display 11 numbers also in LCD. But it display many numbers in LCD. Any idea please?

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

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

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

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

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

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

    Serial.print(n1);

    delay(1);

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

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

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

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

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

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

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

            break;
        }

        key = kpd.getKey();
    }

} // end of GetNumber


texts: Uno - PCA9685 Servos are too shaky before stabilizing - when using two channels

texts:
I'm trying to control a Tilt pan with an Arduino Uno. And the Sunrounder servo driver is used to do this, which comes with it's own capacitor out of the box.

The pan has two Servo motors, that help it face any direction.

I have set this up and even calibrated, so that I can input numbers between -90 degrees to +90 degrees horizontally, and 0 to 90 vertically. And it is working...

But the problem is that, when it is idle for too long, or when I connect it in the beginning, The tilt pan shakes intensely for about 20 to 30 seconds and turns every other direction before stabilizing to the correct point. As if it had a seizure!

When I disconnect one of the Servos, this problem solves. Two servos are connected to the first and second channel of the servo driver. So it seems that these two channels have an effect on each other.

Besides, there is not much weight on the tilt pane. And removing the weight does not seem to help.

init code:

pwm = Adafruit_PWMServoDriver();
pwm.begin();
pwm.setPWMFreq(60);  // Analog servos run at ~60 Hz updates
yield();

turning horizontally:

void Platform::setHorizontal(int d){
  if(d > 90)
    d = 90;
  if(d < -90)
    d = -90;
  point->setHorizontal(d);
  d = (d * 2.555) + 70.0; // calibrating.
  pwm.setPWM(0, 0, 325 + d); // 325 = (150 + 600) / 2
}

How can I solve this?


texts: Failed to boot VL53L0X: VL53L0X Error: -6

texts:
I am using a VL53L0X sensor in my project.
It was working fine when suddenly it started to show failed to boot error.
I tried debugging but of no use. I ran I2C scanner sketch and it detected the sensor at 0x29.
I get the following error -
23:38:27.797 -> Adafruit VL53L0X test
23:38:27.830 -> VL53L0X Info:
23:38:27.830 -> Device Name: VL53L0X ES1 or later, Type: VL53L0X, ID: VL53L0CBV0DH/1$1
23:38:27.830 -> Rev Major: 1, Minor: 1
23:38:27.864 -> VL53L0X: StaticInit
23:38:27.932 -> VL53L0X: PerformRefSpadManagement
23:38:27.932 -> refSpadCount = 2226323456, isApertureSpads = 92
23:38:27.932 -> VL53L0X Error: -6
23:38:27.932 -> Failed to boot VL53L0X

This is the code I used (its the example code with just 0x29 and true passed in begin function for verbose output):
#include "Adafruit_VL53L0X.h"

Adafruit_VL53L0X lox = Adafruit_VL53L0X();

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

  // wait until serial port opens for native USB devices
  while (! Serial) {
    delay(1);
  }

  Serial.println("Adafruit VL53L0X test");
  if (!lox.begin(0x29,true)) {
    Serial.println(F("Failed to boot VL53L0X"));
    while(1);
  }
  // power
  Serial.println(F("VL53L0X API Simple Ranging example\n\n"));
}

void loop() {
  VL53L0X_RangingMeasurementData_t measure;

  Serial.print("Reading a measurement... ");
  lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!

  if (measure.RangeStatus != 4) {  // phase failures have incorrect data
    Serial.print("Distance (mm): "); Serial.println(measure.RangeMilliMeter);
  } else {
    Serial.println(" out of range ");
  }

  delay(100);
}

I am using an Arduino nano -
following are the connections
ARDUINO->VL53L0X
3v3->Vin
GND->GND
A4->SDA
A5->SCL
I have rechecked the connection and voltages the sensor does receive 3v3 and gnd.
I need help with this asap.
Thanks in advance :)


texts: Achieving nanosecond accuracy with MKR Vidor 4000

texts: Can I achieve nanosecond accuracy with Arduino Vidor MKR 4000? Has anyone experience? Obviously by using the FPGA it has on it. I do not find much support on this module on google search...


texts: PubSubClient - MQTT_MAX_PACKET_SIZE How is it calculated

texts: I'm using an ESP32, and I want to rule out a probable MQTT error. In PubSubClient , MQTT_MAX_PACKET_SIZE is set to 256. Is 256 the size for message only ? if not, what is left for message only ?


texts: Arduino and Raspberry Pi - initiate I2C communication as slave

texts:
I would like to interconnect Raspberry Pi and Arduino over I2C.

RPi will act as MASTER while Arduino is SLAVE.

I understand that I2C is designed that only master can send messages to slaves and then wait for responses.

I have sensor connected to Arduino, Arduino check periodically sensor value. My intent is, when sensor value exceed defined limit, inform RPi - send message to it. I want RPi as MASTER, because it also can query Arduino anytime. Can I start communication as SLAVE device?

Is it possible somehow? Do I need to use different bus than I2C?


texts:
I just bought a KEYESTUDIO W5500 Ethernet Arduino without realizing that the Ethernet socket on the board impedes adding any additional shields to the device because:

Horizontally the socket runs right up next to the shield connector sockets
Vertically the socket is a good 1/4 inch higher that the shield connector
sockets

Is there a good solution for extending the shield connector sockets vertically so that they clear this Ethernet socket?


texts: Connect two 64x32 RGB P4 panels Arduino Mega

texts:
I'm using an Arduino Mega and two RGB Led Panels to plot some data. The problem is that the data plotted in the first panel is duplicated in the second as well. What I want is to plot the data on both using just one Arduino Mega. Is it possible? I've read that you can achieve it using one Mega for each panel or using a more powerful controller for both. This question was asked before here
Join two rgb ledPanel 32x64 in order to get one 64x64 (How to)
but no clear answer about commands or changes to made in the code were given. Any idea?
Thanks in advance


texts:
Can anyone assist me to make a power supply whose output voltage will be controlled by an Arduino, with the latest voltage setting automatically saved in non volatile memory?

I am in an OJT (On the Job Training Scheme). I was given a task to make a Arduino controlled voltage variable power supply whose outputs can be switched between several preset values using pushbutton control.   It's like switching between two different outputs when a designated button is being pushed.

Here is what I have done so far. I made an LM317 based power supply with the output voltage controlled by a potentiometer. I followed this youtube tutorial. It works well but I was ask to upgrade it.

Instead of using a potentiometer to adjust the voltage, I wish to use switching buttons to choose between two or more preset voltage levels. Each switch buttons have their corresponding voltages.

This link may also be relevant.
Code is given below the circuit diagram.
ARDUINO AS A POWER SOURCE ALTERNATOR


texts:
I've synced my Uno with the Arduino IDE and I'm using the following code to get the raw GPS coordinates:

#include <SoftwareSerial.h>

static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;

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

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

void loop()
{
  // Output raw GPS data to the serial monitor
  while (ss.available() > 0){
    Serial.write(ss.read());
  }
}

When I compile, it uploads successfully but when I check the serial streams, it simply displays:

⸮7C⸮wyCCZVa⸮HR-⸮K=LR3⸮(⸮:⸮xk;GqB⸮9Jb⸮j
⸮{BP⸮GQ:⸮⸮⸮bpXB⸮wYP⸮BP⸮⸮⸮⸮BBBμkCzPCy⸮j⸮_c
B⸮JZR⸮⸮7CjCC;Va⸮IR-⸮K=LR3⸮(⸮Z⸮u@ZC]{⸮+Xb9CR⸮⸮R⸮=*Wi⸮⸮7C!jCC;Va⸮IR)⸮K=LR3⸮(⸮[⸮qBZC]{⸮+⸮⸮⸮J⸮⸮K;⸮PR⸮HT

and so on. Is the code wrong? I found it in an online reference where it does work with their module.


texts: Serial monitor returns "48" when I enter "0"

texts:
I am going through an Arduino Learning Book(978-1-59327-448-1) and I've run into the same issue twice now.

When I enter data into the serial monitor, the number that it reads and displays(when asked to print) is way different than what I'm entering.

In diagnosing the problem, I went to https://www.arduino.cc/en/Serial/Read
Copied the code into a new sketch, and tried to run it.
When I Enter 0, I get 48, and a second line saying 10. Enter 1, I get 49 and 10, etc. Here are the results when I enter 0, then 1, then 2, then 3

I received: 48
I received: 10

I received: 49
I received: 10

I received: 50
I received: 10

I received: 51
I received: 10

here is the code I'm using

int incomingByte = 0;   // for incoming serial data

void setup() {
    Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps
}

void loop() {

    // send data only when you receive data:
    if (Serial.available() > 0) {
            // read the incoming byte:
            incomingByte = Serial.read();

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

I have the serial monitor set to 9600.
All sketches have worked fine so far, including those that use Serial.print functions, but when I use Serial.read, things seem to get screwed up.

I'm sure I'm missing something stupid, but I've googled around and all the answers are much higher level than just trying to run the code in the Arduino.cc example

Thanks in advance for helping a first timer!

PS: I Tried to get all of the code into the grey box with various line spacing and indenting strategies, but it's not perfect. Does anyone have any tips on that?


texts: I have recently made a home automation system using node mcu and relay module and i am powering both together using my 5V ,2A dc adapter and i am scared that if I'll keep using it for very long hours and that too daily my node mcu board would disrupt soon. So i wanted to ask that what to keep the minimum voltage. So to keep the board safe


texts: esp32 http client response only 200 didn't receive the data after that

texts:
i am using esp32 as a client and using following example. So here i am getting header response only that is 200. I am not getting any response after that. here is the example
#include <WiFi.h>
#include <HTTPClient.h>

const char* ssid = "yourNetworkName";
const char* password =  "yourPassword";

void setup() {

  Serial.begin(115200);
  delay(4000);
  WiFi.begin(ssid, password);

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

  Serial.println("Connected to the WiFi network");

}

void loop() {

  if ((WiFi.status() == WL_CONNECTED)) { //Check the current connection status

    HTTPClient http;

    http.begin("http://jsonplaceholder.typicode.com/comments?id=10"); //Specify the URL
    int httpCode = http.GET();                                        //Make the request

    if (httpCode > 0) { //Check for the returning code

        String payload = http.getString();
        Serial.println(httpCode);
        Serial.println(payload);
      }

    else {
      Serial.println("Error on HTTP request");
    }

    http.end(); //Free the resources
  }

  delay(10000);

}

given url works with me as well. but if i give other url then i am getting response as 200 only. but not receiving json data which is present on the request url.


texts:
What I am trying to do is while connected locally in the esp8266 and give it a ssid and password, save them in a global variable and use them to start a connection inside loop function with a flag so it happens only once and let the program run while I check when the connection is complete. Do you foresee any problems with this application?:

setup(){
    wifi.mode(WIFI_AP_STA);
    setup softAP
    server.on("/",handleroot)
    server.begin()
}
loop(){
    server.handleClient()
    if(credential_submited){
        Wifi.begin(credentials);
        flag_connection_started =true;
        credential_submited = false;
        flag_for_internet_server=true;
    }
    if(WiFi.status()==WL_CONNECTED && flag_for_internet_server==true){
        server.on("/",handleroot)
        server.begin()
        flag_for_internet_server=false;
    }

I know there is also WifiManager But I am trying to do it on my own. The thing is some wifi networks take a lot of time to connect. More precisely they connect but then the esp doesn't get an ip and disconnects.
Thank you for your time


texts: SM 130 RFID reader, with Arduino Uno. Trying to read RFID passive tags on Arduino version 1.6.7

texts:
I am trying to read passive tags using these two devices and an arduino uno, for a class project of trying to make my own doggy door. However, all the code I have been able to find is out of date, including the code on the sparkfun product site ( I think the code is out of date not 100% sure?). I think the main issue with the code is that is based on SoftwareSerial instead of NewSoftSerial. So if anyone has any experience programming with RFIDs (hopefully this device in particular) I would love any pointers, example code, help, words of advice, etc., The code I tried to use is available on the links. Also, I am by no means an expert in any of these fields, so if anything I said is wrong please correct me. P.S., I do not believe it is a wiring issue since these are both shields, and I did very clean soldering. The "Power" LED on the evaluation sheet/antenna is on, but the "Search" and "Found" LED's never light up (even with a tag making contact with the board).
Reference of Devices: https://www.sparkfun.com/products/10126 - RFID Module SM130 https://www.sparkfun.com/products/10406 - RFID Evaluation Shield


texts:
for a project my supervisor gave me a Arduino Mega ADK board (https://store.arduino.cc/arduino-mega-adk-rev3) and the usb-cable.

I only programmed a Atmega32 8 bit controller on linux ubuntu. I have no possibility to use windows (i heard it's easy to program the arduino using atmel studio). I can only use ubuntu 16.04. Is there a convient way to program the Arduino like a microcontroller?

I'm not aloud to use the highlevel Arduino libraries. I have to do a cascaded control for a dc-motor and sensor-fusion.

Thanks in advance.

If it's offtopic, could you transfer me to a suitable board?


texts: Arduino MIDI Program Change to Voodoo Labs GCX Converter

texts: To define the problem, the L6 Helix can generate 6 immediate MIDI messages. These messages are pretty flexible as to what you want, but the Voodoo Labs GCX needs at least 8 CC messages to properly configure it worst case. Also, I don't want to burn all of my immediate commands to control most of the GCX. So I had the idea to create a Arduino project that would take MIDI PC and MIDI Bank Select to produce a 8 bit value which I could then convert into 8 CC messages between CC#80 and CC#87.


texts: How to declare a pointer for arduino neopixels library so I can set it up in the setup function with dynamic variables?

texts:
I am using NeoPixel strips, and I want to be able to declare a pointer to them, but not initialize them until the setup function (because they will initialize with certain variables only made available in setup).

For simpler data types, I am just doing:

int totalNumColors = 4; //number of colors user can cycle through`
uint32_t* colorArray = new uint32_t[totalNumColors];
void setup() {
  for (int i=0;i<totalNumColors;i++){
    colorArray[i] = totalColorArray[i];
  }
}

How do I do this for NeoPixel strip intializers? I tried:

Adafruit_NeoPixel* pixels = new Adafruit_Neopixel;`

but I get the error:

expected type-specifier before 'adafruit neopixel'


texts:
I want my Arduino to log data while connected to a battery.
After few hours, I need to reconnect the Arduino via COM port to a PC and read the logged data.

The com port will not reconnect. This is part of the code I am using. It works if I am not disconnecting the com port. Any idea how to fix this?

if (digitalRead(buttonPin) == HIGH) {
    LoopIndex=0;
    Serial.begin(9600);
    Serial.println("Start printing");
    while (LoopIndex < MinCounter) {
        // print the results to the serial monitor:
        Serial.print("Time = ");
        Serial.print(PressurePerMin[LoopIndex++]);
        Serial.print("\t sensor = ");
        Serial.println(PressurePerMin[LoopIndex++]);
    }
 }


texts:
I am sending a polymorphic object over serial between two Arduinos. The transmission should be fine, indeed if on the receiver side I static_cast the pointer to the Derived class it works properly. On the other hand if I try to call virtual functions on the Base pointer, Arduino resets. What is causing this behaviour?

Some samples of the code follows.

Sender:

RS485_Serial bus;
void loop ()
{
  Random r(1); //targeting device 1 in the bus
  if (r.request(bus)) { blink(r.val); } //make a request for a random number
                                        //blink the led the given number of times

  delay(1000);
}

Receiver:

RS485_Serial bus;
bus.set_address(1);
void loop ()
{
  listen(bus);
}

Selected common parts:

struct Action {
  byte target_address;

  Action(byte addr): target_address(addr) {}
  virtual ~Action() {}

  virtual size_t size() const { return sizeof(*this); }
  virtual int  vrequest(RS485_Serial &) = 0;
  virtual void vrespond(RS485_Serial &) = 0;

  int request(RS485_Serial & bus) {
    bus.write(reinterpret_cast<byte*>(this), size());
    return vrequest(bus);
  }
  void respond(RS485_Serial & bus) {
    vrespond(bus); // <--- This virtual call makes the sender reset
  }
};

struct Random: Action {
  size_t size() const override { return sizeof(*this); }
  int val;
  Random(byte address): Action(address) {}

  int vrequest(RS485_Serial & bus) override {
    return bus.read(val);
  }
  void vrespond(RS485_Serial & bus) override {
    bus.write(static_cast<decltype(val)>(random(2,5)));
  }
};

void listen(RS485_Serial & bus) {
  byte * data = nullptr;
  byte length = 0;
  if ( bus.read(data, length) ){
    Action & a = *(reinterpret_cast<Action*>(data));
    if (a.size() == length) blink(3);
    if (a.target_address == bus.address) {
      a.respond(bus);
      //static_cast<Random*>(&a)->vrespond(); works but it has no point
    }
  }
}

My doubt is that if the vtable is stored in different positions, than the vtable pointer in the object obtained by the receiver will be off, causing the crash.


texts:
I'm working on a code based on PaletteCrossfade.ino example. But I found the motion speed too fast. It's stated in this:

  static uint8_t startIndex = 0;
  startIndex = startIndex + 1; /* motion speed */
  FillLEDsFromPaletteColors(startIndex);
  FastLED.show();
  FastLED.delay(1000 / UPDATES_PER_SECOND);
}

void FillLEDsFromPaletteColors( uint8_t colorIndex) {
  uint8_t brightness = 255;
  for( int i = 0; i < NUM_LEDS; i++) {
    leds[i] = ColorFromPalette( currentPalette, colorIndex + sin8(i*16), brightness);
colorIndex += 3;

Since the startIndex defined in uint8_t, it cant be lower than 1. So I used float and set it to 0.2 in my code. Which seems to work, and animation slowed down. However I'm not sure how is that float value added into the ColorFromPalette function.

Its documentations states:

  CRGB  ColorFromPalette (const CRGBPalette16 &pal, uint8_t index,
  uint8_t brightness=255, TBlendType blendType=LINEARBLEND)

To my understanding it accepts only integer, and also int based sin8 being added to float value. So, what exactly happens there? Is this method viable, or is there any better way to slow down the animation?

I'm thinking about adding a millis() based delay and only increasing the colorindex every 2-3 seconds or so.


texts: Due: Write to digital pin when ADC is running

texts:
I have a problem writing to a digital pin on Arduino Due while my ADC is running.

I have the following code:

 #undef HID_ENABLED

// Arduino Due ADC->DMA->USB 1MSPS
// by stimmer
// from http://forum.arduino.cc/index.php?topic=137635.msg1136315#msg1136315
// Input: Analog in A0
// Output: Raw stream of uint16_t in range 0-4095 on Native USB Serial/ACM

// on linux, to stop the OS cooking your data:
// stty -F /dev/ttyACM0 raw -iexten -echo -echoe -echok -echoctl -echoke -onlcr

// source: https://gist.github.com/pklaus/5921022
// applied patch 1 from: http://forum.arduino.cc/index.php?topic=137635.msg2526475#msg2526475
// applied patch 2 from:  https://gist.github.com/pklaus/5921022 comment on Apr 2, 2017 from borisbarbour

volatile int bufn,obufn;
uint16_t buf[4][256];    // 4 buffers of 256 readings

void ADC_Handler(){     // move DMA pointers to next buffer
  int f=ADC->ADC_ISR;
  if (f&(1<<27)){
   bufn=(bufn+1)&3;
   // patch 2 start
   //ADC->ADC_RNPR=(uint32_t)buf[bufn];
   ADC->ADC_RNPR=(uint32_t)buf[(bufn+1)&3];
   // patch 2 end
   ADC->ADC_RNCR=256;
  }
}

void setup() {
  SerialUSB.begin(0);
  while(!SerialUSB);

  pmc_enable_periph_clk(ID_ADC);
  adc_init(ADC, SystemCoreClock, ADC_FREQ_MAX, ADC_STARTUP_FAST);
  ADC->ADC_MR |=0x80; // free running

  ADC->ADC_CHER=0x80;

  NVIC_EnableIRQ(ADC_IRQn);
  ADC->ADC_IDR=~(1<<27);
  ADC->ADC_IER=1<<27;
  ADC->ADC_RPR=(uint32_t)buf[0];   // DMA buffer
  ADC->ADC_RCR=256;
  ADC->ADC_RNPR=(uint32_t)buf[1]; // next DMA buffer
  ADC->ADC_RNCR=256;
  // patch 1.2 start
  //bufn=obufn=1;
  bufn=1;
  obufn=0;
  // patch 1.2 end
  ADC->ADC_PTCR=1;
  ADC->ADC_CR=2;

  // this doesn't work:
  pinMode(52, OUTPUT); //
  digitalWrite(52, HIGH); //
}

void loop(){
  // patch 1.1 start
  while((obufn + 1)%4==bufn);// wait for buffer to be full
  // patch 1.1 end
  SerialUSB.write((uint8_t *)buf[obufn],512); // send it - 512 bytes = 256 uint16_t
  obufn=(obufn+1)&3;
}

Pin 52 says 0 V.

With this function, I can pull the digital output voltage to 1.58 V:

void digitalWriteDirect(int pin, boolean val){
  if(val) g_APinDescription[pin].pPort -> PIO_SODR = g_APinDescription[pin].ulPin;
  else    g_APinDescription[pin].pPort -> PIO_CODR = g_APinDescription[pin].ulPin;
}

Any ideas?


texts: Which board/shield to generate (non-PWM) analog outputs?

texts:
I am currently building a project involving a laser scanner (two galvanometers with mirrors that deflect a laser beam) that I want to control. The galvos need +-10V differential signals (and I'd like to have a least 12Bit) that I want create with some small board.

Most Arduinos I know use PWM to create an analog output which is not usable for this project. I found the Teensy3.1 which has at least one 12Bit DAC so that also doesn't work. An alternative would be a DAC breakout board like "MCP4725" but it would be nicer to just have a single board with no additional parts.

The best thing would be a small board with already two 12Bit DACs. (even If I had to upscale the voltage +-10v)

Is there a board I haven't found so far? Or have I missed a completely different approach?


texts:
I want to use 2 "displays" with 4 digits. The displays are common cathodes with cathode transistors connected to the digits, as the figure:

The segments of both displays are connected together on the digital pins.
The problem is that I tried to use some libraries for 7 segment displays and they worked with only one 4 digit display, but when I connected the second display, did not display the numbers correctly. The numbers that will be written are integers and I'm using mega 2560 R3.

Here are my attempts:

#include "SevSeg.h"
byte digitPins_1[] = {29, 30, 31, 33};//Digits pins
byte digitPins_2[] = {25, 26, 27, 28};
byte segmentPins[] = {38, 39, 40, 41, 42, 43, 44, 46}; //segment pins
SevSeg disp1;
SevSeg disp2;

void setup() {
disp1.begin(P_TRANSISTORS, 4, digitPins_1, segmentPins);
disp2.begin(P_TRANSISTORS, 4, digitPins_2, segmentPins);
disp1.setBrightness(20);
disp2.setBrightness(20);
}

void loop() {
disp1.setNumber(8888, 0);
disp1.refreshDisplay();
disp2.setNumber(1111, 0);
disp2.refreshDisplay();
}

or using another lib:

#include <SevenSeg.h>
SevenSeg disp1(38,39,40,41,42,43,44);//segment pins
SevenSeg disp2(38,39,40,41,42,43,44);
int digitPins1[4]={29,30,31,33};//digitpins
int digitPins2[4]={25,26,27,28};

void setup() {
disp1.setDigitPins(4,digitPins1);
disp2.setDigitPins(4,digitPins2);
disp1.setDigitDelay(1600);//time delay
disp2.setDigitDelay(1600);
disp2.setActivePinState(HIGH,HIGH);//seg active HIGH, digit active HIGH
disp1.setActivePinState(HIGH,HIGH);
}

void loop() {
disp1.write(8888);
disp1.clearDisp();
disp2.write(1111);
disp2.clearDisp();
}


texts: Gamepad connection using Pro Micro(ATMEGA32u4 + HC-05

texts:
I have been working on making a HID compatible Gamepad using Pro Micro and HC-05 module. I have successfully configured the class of HC-05 module to appear as an Input device(A gamepad) on my PC without changing the firmware of the HC-05. However, after the bluetooth device gets paired there is no option showing to connect to it. My question is how do I start the blutooth connection?
Note: The class of device calculator tells you the hex for the class of device you want to make.


texts: How to make ESP8266-1S module work on Arduino Uno?

texts:
I currently have an Arduino Uno with an ESP8266-1S. However I can't make them work... I use the ESP8266wifi.h library and its connection functions do return a true (returns true when received a valid IP), but I can't find it in my network...

When I send 'AT' ending with CR and NL on 115200 baud I still don't get a response.

Also, do I have to connect RX with RX and TX with TX or RX to TX and vice versa?

And also, do I need any converters? Because now I directly connect the TX and RX to the Arduino's TX and RX.

So this is how my board looks like:

So what am I doing wrong?


texts: How to use different device address for MCP23017 so I can use multiple chips?

texts:
I want to use more than 3 MCP23017-E/SP DIP28 chips so I can use many digital pins. I use Adafruit-MCP23017-Arduino-Library. I tried this solution but only device address with 0x00 is working.

The question is what device address should I use for additional chip?

#include "Adafruit_MCP23017.h"
Adafruit_MCP23017 mcp1;
#define addr1 0 // tested 1,2,3,4,5, 0x01, 0x02, 0x20, 0x21 but only 0 and 0x00 is working.
void setup()
  {
    mcp1.begin(addr1);
    mcp1.pinMode(0, INPUT); //pin 21 on chip
    Serial.begin(9600);
  }

  void loop()
  {
      if(mcp1.digitalRead(0)== HIGH )
      Serial.println("HIGH");
  }


texts: avrdude: ser_open(): can't open device "\\.\COM3"?

texts:
My computer cannot detect my Arduino Uno anymore,

Reset button- > L led light blinks and it turns on forever
Arduino 1.6.5: Tools->Port (greyed out) I remembered that previously it wasn't like this
Unable to upload any sketch codes into the Uno anymore
The existing code uploaded onto the Uno is FastLED(FirstLight) and it will work on my LEDs when I plugged them in

I have tried to .... but none fix my issue

Restart my computer
Press the reset button on the Uno
Using the device mananger to change COM ports
Device manager -> Other devices -> (nothing about Arduino Uno is found here)
Plugged Uno into another computer but still doesn't work
Reinstalled IDE

Problem shown in sketch,

avrdude: ser_open(): can't open device "\.\COM3": The system cannot find the file specified.
Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.


texts: How the output of a bicycle dynamo can be displayed using Arduino?

texts:
I am on a project in which I need to make bicycle dynamo frequency meter.
The power generator’s output should vary with the speed of the wheel.

Which parts do I need to make it work?

The project should look like: : http://www.lanzo.se/experiments/dynamo/dynamo.html
                 or http://practicalphysics.org/bicycle-dynamo-and-oscilloscope.html

-->without oscilloscope ( which is replaced with Arduino and panel )


texts:
I have a SD card reader that is working fine exept that sometimes SD.begin fails for no apparent reason.
To work around this issue I have put the SD.begin in a while loop and then I display the error on my LCD. When the error happens I then remove and reinsert the card witch works usualy on the first or second try. I have never seen any problem ones the card is initilized.
Does anyone has any idea what might be the problem?


texts: RFID RC522 reads the previous tag serial with different tag

texts:
I hope someone can help me.

I'm using a Mega with RC522, and this happens:

I use a tag, it reads the right serial (e.g. AA:BB:CC:DD). Then I use a second tag and sometimes it gives me the correct value (e.g. 00:11:22:33), but often it gives me the previous tag serial (AA:BB:CC:DD). After a few attempts, it finally gives me the right one (00:11:22:33).

I really can't find what's wrong and i'd be grateful if someone could shed some light.

Here's the code:

if (RC522.PICC_IsNewCardPresent())  {
           RC522.PICC_ReadCardSerial();
          String strID = "";
        for (byte i = 0; i < 4; i++) {
          strID +=
            (RC522.uid.uidByte[i] < 0x10 ? "0" : "") +
            String(RC522.uid.uidByte[i], HEX) +
            (i != 3 ? ":" : "");
        }
        String seriale = strID;

        if (seriale != "0"){

          for(h=0; h<=numerogiocatori -1;h++){

            if (seriale == seriali[h]) {
              lcd.clear();
              lcd.print("Saldo Gioc. ") ;
              lcd.print(h + 1) ;
              Serial.print("tag ID: ");
              Serial.print(seriale);
              Serial.print(" .    ");
              lcd.setCursor(0, 1);
              lcd.print(totaledenaro[h]) ;
              delay(1500);
              lcd.clear();
              lcd.print("Importo");
              lcd.setCursor(0, 1);
            }
          }
        }}}

Thanks to anyone willing to help!


texts: Connecting Mac to Adafruit Feather 32u4 Bluefruit LE over serial

texts:
The Adafruit board connects fine over USB serial, and fine over Bluetooth to a mobile app, but it will not connect to a Mac serial monitor over Bluetooth.

Is there any way to use the Adafruit's Bluetooth chip as a pass-through, to allow serial communication over Bluetooth from the Mac to the board itself?


texts:
I need to send Arduino some instructions from the web. Basically I would have a web app with a few buttons, and when I press them they send an instruction to Arduino to move for example a motor or turn a lamp. This has to function remotely, so not locally.

I'm using an Arduino Yùn.

How should I do this? Websocket? How? Thanks!


texts: Programming Attiny45 using Arduino Uno with weird behavior

texts:
I bought an Arduino Uno a few days ago.

I programmed an ATtiny45 using an Arduino Uno following "How-To: Shrinkify Your Arduino Projects" video on YouTube.

I uploaded the blink example successfully. I altered the sketch in a way so there is also a blinking on pin 4 (which is ATtiny45 pin 3).

Now, if I connect +5V from the Arduino to ATtiny45 pin 8, ground to pin 4 and the LEDs from pin 2 and 3 to ground everything works as expected.

But if I use 4 AA batteries instead of the power from the Arduino I only get a blinking on ATtiny pin2.

What could be the reason for this behavior? Is it because I use 4 AA -> 6 V instead of 5 V? I tested it also with 3 AA batteries and got the same result.

So why does it work if I use power and ground from the Arduino but not from the batteries?


texts:
I'm working on project 9 of the arduino starter-kit - the motorized pinwheel.

Here is the schematic:

The diode in question (and the only one here) is toward the bottom right of the breadboard. It is to prevent the back-voltage from the motor from harming the circuit.

According to the above img, would the backvoltage travel back down the motor's supply of energy (the red wire)?

If so, what is the diode preventing here? That whole energy strip will just have current running through it and the diode's cathode will prevent it from running to the transistor - which would also happen fi we just didn't connect anything to that power strip.

If not, and the back-voltage is running through the black wire (our ground), then I still do not see how the diode is helping. The diode seems to want to pull the extra energy back to our power strip (which is why the anode is facing toward the left, where the motor's output is. But this doesn't prevent the current from still hitting the green wire which leads to the transistor's 'source'.

So how is this diode working?

Thanks!


texts: Duplicate libraries while compiling for ESP32 in the Arduino IDE

texts:
I have just added the ESP32 toolchain to the Arduino IDE (v1.8.0) on Windows 10.  To get the IDE to allow me to select ESP32 chips I had to place the Espressif folder in "D:\Program Files(x86)\Arduino\hardware" (Yes my C drive is called D, its a long story)

I managed to compile and run Blink and after several minutes of celebration I tried the ESP32 Example Wifi->WifiScan.  It failed to compile because

WARNING: Category '' in library OneWire is not valid. Setting to 'Uncategorized'
In file included from D:\Program Files (x86)\Arduino\libraries\WiFi\src\utility\spi_drv.cpp:21:0:

D:\Program Files (x86)\Arduino\libraries\SPI/SPI.h:16:26: fatal error: avr/pgmspace.h: No such file or directory

compilation terminated.

Multiple libraries were found for "WiFi.h"
 Used: D:\Program Files (x86)\Arduino\libraries\WiFi
 Not used: D:\Program Files (x86)\Arduino\hardware\espressif\ESP32\libraries\WiFi
Multiple libraries were found for "SPI.h"
 Used: D:\Program Files (x86)\Arduino\libraries\SPI
 Not used: D:\Program Files (x86)\Arduino\hardware\espressif\ESP32\libraries\SPI
exit status 1
Error compiling for board ESP32 Dev Module.

If I am reading this correctly, there are a couple of duplicate libraries, Arduino versions and ESP32 versions and the IDE picked the Arduino versions.

Is there a way of telling the IDE to prefer the ESP32 libraries rather than Arduino ones?  I suspect all I need to do is change the order of the -I and -L commands, but I don't have a clue how, or if that's the right thing to do.


texts: Arduino Yun Python ImportError: No Module named mime.multipart

texts:
So, I have an Arduino Yun, and I'm trying to send an email with python. I have this code that I got from https://github.com/amicojeko/YouCantTouchThis

But when I try to call the file with $python sendemail.py test.png, it returns me an error:

ImportError: No module named mime.multipart

I already tried to change to lowercase the imports, but it keeps showing the same error. The python version in the Arduino is 2.7. I've read something about module reorganization but even with the changes the error keep showing. Here is the code:

# coding=utf-8
# Copyright (C) 2014  Stefano Guglielmetti

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import smtplib, os, sys
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.Utils import COMMASPACE, formatdate
from email import Encoders

#From address, to address, subject and message body
from_address    = 'FROM_ADDRESS@EMAIL.COM'
to_address      = ['YOUR_ADDRESS@EMAIL.COM']
email_subject   = 'Alert!!! Zombies!!! Ahead!!!'
email_body      = 'A non dead intruder has been detected and needs to be eliminated!'

# Credentials (if needed)
username = 'EMAIL_LOGIN'
password = 'EMAIL_PASSWORD'

# The actual mail send
server = 'smtp.gmail.com:587'

def send_mail(send_from, send_to, subject, text, files=[], server="localhost"):
    assert type(send_to)==list
    assert type(files)==list

    msg = MIMEMultipart()
    msg['From'] = send_from
    msg['To'] = COMMASPACE.join(send_to)
    msg['Date'] = formatdate(localtime=True)
    msg['Subject'] = subject

    msg.attach( MIMEText(text) )

    for f in files:
        part = MIMEBase('application', "octet-stream")
        part.set_payload( open(f,"rb").read() )
        Encoders.encode_base64(part)
        part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(f))
        msg.attach(part)

    smtp = smtplib.SMTP(server)
    smtp.starttls()
    smtp.login(username,password)
    smtp.sendmail(send_from, send_to, msg.as_string())
    smtp.close()

send_mail(from_address, to_address, email_subject, email_body, [sys.argv[1]], server) #the first command line argument will be used as the image file name


texts: Arduino secure two way communication over radio

texts:
I would like to implement a secure communication channels between 2 arduinos communicating over 433 mhz radio modules (to be more precise using the barebone Atmega 326 chips).

I know that the lack of resources are a problem with the Atmega chips. The best starting point I could find was this library, which never got written:

https://forum.arduino.cc/index.php?topic=314845.0

The way I see it it does not matter what kind of encoding we use if an attacker can capture and replay that OTA, there has to be a 2nd component between the devices which is not known for an attacker and changes the same way like a DS based timer. If a client could encrypt its messages using key=timeXpassword key->encrypt(datatobesent) then the server could decrypt it the same way if it arrived in a proper time period like +-/5 seconds where the time does not have to be the current accurate time just a clock which is in sync between the devices. When the message is received by the server it would calculate 5 different data possibilities for the 5 seconds and look into a decrypted data for certain string to determine if that is a VALID data packet.

For this again there would be the need of an external timer circuit like the DSXXXX series because the internal timer in the chip is not reliable/overflows after a while.

Any other ideas for secure communication?


texts: What are the possible outcomes of calling status() on a WiFiServer from ESP8266WiFi.h? The only documentation I could find only says it returns uint8_t. Here's the link.


texts: Can I have more than 1 pin "activated" at the same time?

texts: I have a group project in school. My group mates want an alternate blinking, rapid blinking and fading LEDs in our project. The thing is they want it to go simultaneously. Is there anyway I can do that?


texts: I followed a guide to control my arduino uno using a python web server API (flask), and it works like a charm using the COM port on my PC. I would like to extend this over the network with an ESP8266 module so i can have a web server handling my project's event scheduling and hard work using python/html/css/js (anything supported/needed) and have the arduino as a client receiving the server data and acting accordingly. I am not limited to this method as it seems pretty hard to generalize over the network (Use a virtual COM port on the server side and forward the arduino using the router?//i  have to specify where the arduino port is located) so any other way to setup a Web server handling the event triggering and sending the ON/OFF information to my arduino (i just need to trigger a relay) is accepted.


texts: Arduino Serial Communication possible with IDE 1.8.5 but not with IDE 1.8.13

texts:
I have the following problem: I am working with an Arduino Nano 33 IoT and a second serial interface via sercom0. The code is just taken from this tutorial:
http://www.getmicros.net/serial-communication-on-the-arduino-nano-iot.php
In loop, I just print the input from my serial connection to the standard serial connection. The input comes from a ozon sensor that sends data packages every single second.
Now when I program the arduino with my Laptop, my IDE version being 1.8.5, it works well, but when I use my PC with a newer version (IDE 1.8.13), it doesn't work any more. The code is the same, the cable and the arduino are the same, the only difference is the PC. But when I try to use an hyperterminal to print the data packages recieved from the sensor, both the Laptop and the PC receive the correct packages. Somehow, the Arduino or the difference in IDE versions causes the communication to fail....
Does anyone have experience with this error?


texts: Instantiate class in the constructor rather in the top end?

texts:
Is there a way to define class variables in the constructor or in a method rather than at the top of the document?
I have the following code in my custom library:
#include "DHT.h"

// DHT settings.
#define DHTPIN 7 // Digital pin connected to the DHT sensor.
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor.

void DhtLib::doSomeStuff() {
  dht.begin();
  float temp = dht.readTemperature();
  ...
}

I would like to be able to set the pins with a function. But for this to work I have to find a way to define the dht variable in a different place than at the top of the document within the // DHT settings.. Best would be in a method such as:
void DhtLib::begin(int dhtPin) {
  DHT dht(dhtPin, DHTTYPE);
}

This works, but only within this function. I need this to be accessible in the entire document, not just a single function.
How can I achieve that?
EDIT 1:
Entire code of the custom DhtLibrary.h file:
#ifndef DhtLibrary_h
#define DhtLibrary_h

#if (ARDUINO >= 100)
  #include "Arduino.h"
#else
  #include "WProgram.h"
#endif

class DhtLib {
  private:
    DHT dht;
    float readTemperatureFromDHT();
    float readHumidityFromDHT();
    float calculateHeatIndex(float temperature, float humidity);

  public:
    // Constructor.
    DhtLib(int dhtPin) : dht(dhtPin, DHT22) {}

    // Methods.
    void begin();
    String getHumiTempJson();
};

#endif

The error with this above code is:
In file included from /home/myuser/Documents/Codes/temperature-control/slave2-arduino/slave2-arduino.ino:2:0:
DhtLibrary.h:12:5: error: 'DHT' does not name a type
     DHT dht;


texts: Speeding up Girino gives strange readouts

texts:
I was reproducing the Girino (the Instructable by Caffeinomane) bundled with the Girinoscope (the Java GUI by Chatanga). The results worked well and I went on to see if the oscilloscope can go up to higher kS/s.

In short, originally only upto prescaler 8 works. I removed PWM pin and it works upto 4 but prescaler 2 strangely behaves. Here are the details:

I did a preliminary test on prescaler 32 (~38.5kHz). Settings as follows and the same in other tests.

The signal (the same hereafter) is generated by a 555 timer astable multivibrator running at 4.5V (3 AA batteries).
The circuitry was simply omitted. I just tied 3.3V of Arduino NANO / ATmega328 to digital pin 6 as the trigger level.
There is no +2.5V offset done by the original Girino. (The scale should be 0~5V and the signal is 0~4V)

So then I wanted to try if it can speed up more. The code optimization quoted by Chatanga allowed prescaler 8 and 16 (76.9kHz and 151.8 kHz).

In order to push it the poor Arduino to the limits, I disabled PWM pin in the original Girino which sets the trigger level with duty cycles (PWM from pin ~3 being fed into pin 6). It's because I simply used a fixed 3.3V trigger level.

Prescaler 4 is unlocked.

Ambitious I go on to test prescaler 2. The GUI did not provide this option so I simply set it in the Arduino code.

I thought it did not work. I noticed if the prescaler is exceeding the Arduino's capability, TXRX simply does not blink. But this time the TXRX is just blinking! To verify this, I shifted the wait duration.

In previous screenshots, the leftmost green line is dashed (probably because it's below fullscale deflection). But in the last two, be it offset or not, the line is solid.

The debug output is like this: (8bits 0~255 given by ADC)

many 0 then suddenly 255 thereafter. (matches the GUI output)

I suspect it's due to slow TXRX? How to solve this? Or anything I overlooked?

Hope that this overdetailed question does not sicken you.


texts: What does (byte*)variable_name mean in C++?

texts:
Gentlemen,
  I am a novice C++ programmer, When I was trying to learn how to use EEPROM with Arduino, I came across this statement

  i2c_eeprom_write_page(0x57, 0, (byte *)somedata, sizeof(somedata));

where I need to know what does (byte*) somedata mean?, please let me know if someone know the answer

Regards,

Mr.B


texts: HX711 Wemos D1 Weird Characters In Serial Monitor

texts:
I am using the HX711 with a load cell attached on my Wemos D1. I have the connections correctly as if I use the same setup on my Arduino Uno board and the same code it runs fine and prints to the serial log. If I comment out the HX711 scale(DOUT, CLK); in my code the serial print is fine. I am not sure if this is an issue with the board or something I am doing with it. I would use the Arduino Uno but it does not have Wifi whereas my Wemos board does. Attached is a screenshot of the serial print from the monitor.

#include "HX711.h"

#define DOUT  3
#define CLK  2

HX711 scale(DOUT, CLK);

float calibration_factor = -117441.00; //-7050 worked for my 440lb max scale setup

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

  Serial.println("HX711 calibration sketch");
  Serial.println("Remove all weight from scale");
  Serial.println("After readings begin, place known weight on scale");
  Serial.println("Press + or a to increase calibration factor");
  Serial.println("Press - or z to decrease calibration factor");
  scale.set_scale();
  scale.tare(); //Reset the scale to 0

  long zero_factor = scale.read_average(); //Get a baseline reading
  Serial.print("Zero factor: "); //This can be used to remove the need to tare the scale. Useful in permanent scale projects.
  Serial.println(zero_factor);
}

void loop() {

  scale.set_scale(calibration_factor); //Adjust to this calibration factor

  Serial.print("Reading: ");
  Serial.print(scale.get_units(), 1);
  Serial.print(" lbs"); //Change this to kg and re-adjust the calibration factor if you follow SI units like a sane person
  Serial.print(" calibration_factor: ");
  Serial.print(calibration_factor);
  Serial.println();

  if(Serial.available())
  {
    char temp = Serial.read();
    if(temp == '+' || temp == 'a')
      calibration_factor += 10;
    else if(temp == '-' || temp == 'z')
      calibration_factor -= 10;
  }
}


texts:
I am using an Arduino Uno and HX711 amplifier to collect data from a load cell. I previously had the load cell calibrated and functioning, but now the load cell will not read any values; only 0's are outputted, even when I apply a small load to the sensor. I have re-soldered and replaced the connecting wires. Are there any suggesting for getting a readout from my sensor?

I have been testing with 2 different load cells: Sparkfun's TAL220 Straight Bar 10kg load cell and an LFS 210-300 from Cooper Instruments (the latter is the one I want to use long term). My load cell is connected like the HX711 Breakout Guide (with an Arduino Uno instead of a RedBoard and a USB connection):

I have been using the HX711 Breakout Guide Calibration sketch to test my load cell:

#include <HX711.h>

#define DOUT 3
#define CLK 2

HX711 scale(DOUT, CLK);

float calibration_factor = 282650; //-7050 worked for my 440lb max scale setup

void setup() {
  Serial.begin(9600);
  Serial.println("HX711 calibration sketch");
  Serial.println("Remove all weight from scale");
  Serial.println("After readings begin, place known weight on scale");
  Serial.println("Press + or a to increase calibration factor");
  Serial.println("Press - or z to decrease calibration factor");

  scale.set_scale();
  scale.tare(); //Reset the scale to 0

  long zero_factor = scale.read_average(); //Get a baseline reading
  Serial.print("Zero factor: "); //This can be used to remove the need to tare the scale. Useful in permanent scale projects.
  Serial.println(zero_factor);
}

void loop() {

  scale.set_scale(calibration_factor); //Adjust to this calibration factor

  Serial.print("Reading: ");
  Serial.print(scale.get_units(), 1);
  Serial.print(" kgs"); //Change this to kg and re-adjust the calibration factor if you follow SI units like a sane person
  Serial.print(" calibration_factor: ");
  Serial.print(calibration_factor);
  Serial.println();

  if(Serial.available())
  {
    char temp = Serial.read();
    if(temp == '+' || temp == 'a')
      calibration_factor += 10;
    else if(temp == '-' || temp == 'z')
      calibration_factor -= 10;
  }
}

I am still new to Arduino and data acquisition in general, so any suggestions would be appreciated!


texts:
I am using OmniVision OV7076 camera (without FIFO) with Arduino Uno.

So I want to use Github code provided in ArduCAM repository. They have provided OV7076 FIFO version straightaway but it is using more memory.

I have used computer nerd code (provided in this tutorial Instructables OV7076 camera) and the camera had worked.

But I want to use the ArduCAM repository. It would be nice if any one could provided link for the guide or can give a little walk-through.

In the ArduCAM repository, they have make an ArduCAM class which have many methods. Thus we get rid of initialisation provided in computernerd code.

I want to use functions of the class directly. But i am unable to understand which method can be used for ov7076 camera. If you could write a starter code it would be very helpful.


texts: Problem reading an EEPROM chip using the I2C protocol

texts:
I am trying to read an EEPROM chip that supports the I2C protocol (cannot tell the IC model number as it is not printed). For sure it supports the I2C protocol, since I wrote a code to detect it using the I2C library and the device address I got it return is 0x51. Now I am trying to write a code that reads data from this IC chip. The code is as follows:

#include <Wire.h>

int addr = 0;

void setup() {
    Wire.begin(); // initialise the connection
    Serial.begin(9600);
    while (!Serial) {}
    delay(100);
}

void loop() {
  byte deviceAddress = 0x51;
  byte data = readData(addr, deviceAddress);
  Serial.print(data, HEX);
  Serial.print(" ");
  addr++;
  if(addr%16 == 0) {
     Serial.print('\n');
  }
  // check for 1Kbits first
  if (addr%128 == 0) {
     Serial.println("round complete");
     Serial.println();
     addr = 0;
  }
  delay(100);
}

byte readData(int address, int deviceAddress) {
  // sending device address
  Wire.beginTransmission(deviceAddress);
  Wire.write(address);
  Wire.endTransmission();
  Wire.requestFrom((short int)deviceAddress, 1);
  if(Wire.available()) {
    byte data = Wire.read();
    return data;
  }
  return 0xAA; // random data
}

The problem I am facing is, I get back the address (from which I want to read the data) as the data itself (For e.g. read(0) returns 0, read(1) returns 1 and so on). I even tried to debug the I2C communication using the logic analyzer (Saleae logic in this case). A screenshot is shown below.

The screenshot shows the logic for a read operation from a single address (0x78), but the story holds for each and every address i.e. I get back the address instead of the data from the address.

The output of the above code is as follows:

  0 1 2 3 4 5 6 7 8 9 A B C D E F
  10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
  20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
  30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
  40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
  50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
  60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
  70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
  round complete

Can you help me identifying what possibly I am doing wrong here?

Thanks.


texts: fob_init(void) code for interfacing the arduino with nrf24l01+

texts:
I found this code . I do not understand the fob_init(void) part of the code

It will be great if anyone could explain the entire code, if not at least the fob_init(void) part.

I am a novice at programming with arduino. any help will be much appretiated.

pasting the code for reference.

void fob_init (void)
{
    DDRA = (uint8_t)~(1<<5);
    DDRB = 0b00000110;
    PORTA = 0b10001111;
    cbi(PORTB, PIN_CE);
    TCCR0B = (1<<CS00);
    MCUCR = (1<<SM1)|(1<<SE);
    sei();
}


texts: Problem uploading the code into an Arduino Uno

texts:
I was trying to upload code for a blinking LED. It is a new Arduino Uno board. Any further help will be appreciated.I got the following error:

Info.: OS- Ubuntu 16.04
Software: Arduino IDE 1.8.5

I could not see any port.
I have tried dialout. But still it is not working.
I also have a confusion, i.e. the Programmer menu shows AVRISP mkll.

If anyone wants any information, please do comment.
Error:

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


texts: How to read/write a 125 kHz RFID tag or card?

texts:
Can someone tell me (I think not only I'm interested in it) how to write a 125 kHz tag or card?
There is a video on Youtube where this Russian guy makes his module from scratch, but I want ready-made one.
https://www.youtube.com/watch?v=2R7srk7E8I4
I know I've mentioned read also in the title, but read is fairly simple with modules available (e.g. RDM6300 and many others on eBay).


texts: I want to write some data (GPS) to a digital port on Arduino.  As far as I understand sending data via a pin as if it were USB is possible. But I don't know what function to use. digital.Write doesn't expect any data or strings. How do I write serial data on to a digital pin


texts:
I want to read a binary body datas from an HTTP POST request.

The context is that I'm making a LED strip controller and I'm currently using this code :

#include <WebServer.h>
#include <Adafruit_NeoPixel.h>

Adafruit_NeoPixel strip = Adafruit_NeoPixel(LED_COUNT, STRIP_PIN, NEO_GRB | NEO_KHZ800);
WebServer server(80);

void handleSimpleWrite()
{
    int r = 0, g = 0, b = 0;
    if (server.hasArg("red"))
        r = server.arg("red").toInt();
    if (server.hasArg("green"))
        g = server.arg("green").toInt();
    if (server.hasArg("blue"))
        b = server.arg("blue").toInt();
    strip.setPixelColor(id, r, g, b);
    strip.show()
    server.send(200,"Ok");
}

It works, but it's clearly innefficient. I want to make an API endpoint that get a binary buffer with RGB states along the request body and I can't figure out how to read this body.

Any ideas ?


texts: Lighting 5 leds...the last one lit is always dim

texts:
I have a simple project with a close deadline.

I am trying to light up 5 LEDs as part of the project. The first 4 light up in sequence fine, and if I light up just the last one it lights up fine, but if all 5 are lit at once the very last LED is very dim. I swapped out cables, the pin on the Arduino, resistor, LED.

What would explain that? Input amperage? Too strong a resistor?

I have a 330 ohm resistor in between each LED and ground. I am using one of the neat resistors from SparkFun that packages up the 5 330 ohm resistors together, with a common ground wire. I bought two and tried swapping it out with no change.

http://imgur.com/fE9t5ZI

Here is my code:

/* Blink without Delay
 http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
 */

const int startButtonPin = 6;
const int reedSwitchPin = 7;
const int ledPins[] = {8,9,10,11,13};
const int numLeds = 5;
const long interval = 1000;           // interval at which to blink (milliseconds)
const int revolutionsPerStage = 15;

int debounceDelay = 500; // for switches--interval to ignore short button presses/reed switch open/close
long lastDebounce = 0;
int buttonState = LOW;
int mapStage = 0;

unsigned long previousMillis = 0;        // will store last time LED was updated

void setup() {
  // set pin modes
  for (int thisPin = 0; thisPin < (sizeof(ledPins)/sizeof(int)) - 1; thisPin++)  {
    pinMode(ledPins[thisPin], OUTPUT);
  }
  pinMode(startButtonPin, INPUT);
  pinMode(reedSwitchPin,INPUT);

  digitalWrite(reedSwitchPin,HIGH); // activate the pull-up resistor
}

// Main program loop
void loop()
{
  buttonState = digitalRead(startButtonPin);
  //digitalWrite(8,HIGH);

  // wait for button press to begin program proper. we won't get back to this state except on first boot or if program finishes
  if (buttonState == HIGH) {
      digitalWrite(8,HIGH);
      chasingLEDs();
      //trackProgress();
  }
}

void trackProgress() {
  int blinkState = LOW;
  unsigned long currentMillis = millis();
  unsigned int numRevolutions = 0;

  do {
    digitalWrite(ledPins[mapStage], HIGH);

    // blink the current goal LED at constant interval specified earlier
    if(currentMillis - previousMillis >= interval) {
      // save the last time you blinked the LED
      previousMillis = currentMillis;
      blinkState = !blinkState;
      digitalWrite(ledPins[mapStage], blinkState);
    }
  } while (mapStage < numLeds);
}

// perform a simple welcome sequence to indicate we are ready to start pedalling
void chasingLEDs() {
   // turn LEDs on in sequence, then back off
   for (int i = 0; i < numLeds; i++){
     digitalWrite(ledPins[i], HIGH);
     delay(333);
   }

   for (int j = numLeds; j > 0; j--) {
     digitalWrite(ledPins[j], LOW);
     delay(333);
   }

   // flash the LEDs twice
   for (int k = 0; k < 2; k++) {
     for (int l = 0; l < numLeds; l++) {
         digitalWrite(ledPins[l], HIGH);
     }
     delay(500);
     for (int m = 0; m < numLeds; m++) {
         digitalWrite(ledPins[m], LOW);
     }
   }
}


texts:
the point of my code is to turn on a LED when the humidity level reaches a certain amount. However it reads the amount of humidity but the LED is not turning on. Why isn't it working??
#include <SimpleDHT.h>

// for DHT11,
//      VCC: 5V or 3V
//      GND: GND
//      DATA: 2
int pinDHT11 = 2;
SimpleDHT11 dht11;

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

void loop() {
  // start working...
  Serial.println("=================================");
  Serial.println("Sample DHT11...");

  // read without samples.
  byte temperature = 0;
  byte humidity = 0;
  int err = SimpleDHTErrSuccess;

  if (humidity > 70 ) {
     digitalWrite(9, HIGH);
  }
  else if ((err = dht11.read(pinDHT11, &temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    Serial.print("Read DHT11 failed, err="); Serial.println(err);delay(1000);
    return;
  }

  Serial.print("Sample OK: ");
  Serial.print((int)temperature); Serial.print(" *C, ");
  Serial.print((int)humidity); Serial.println(" H");

  // DHT11 sampling rate is 1HZ.
  delay(1500);
}


texts: RFID RC522 card reader project(servo, buzzer, two led) with FreeRTOS

texts:
So I wrote simple code which turns on led, buzzes and rotates servo motor when card readed. It works normally. But I want buzz, rotate and on off functions to work asynchorous. I will paste the code which I tried to apply freertos. Any help is appreciated!

void loop() {
 if (!mfrc522.PICC_IsNewCardPresent()) {
 return;
}

if (!mfrc522.PICC_ReadCardSerial()) {
    return;
}

for (byte i = 0; i < mfrc522.uid.size; i++) {
  card_ID += mfrc522.uid.uidByte[i];
}

if (card_ID == rfid) {

  //
  // I want to create async tasks here...
  //
  buzz(750, 1000); // task 1

  green_on();      //
  delay(1500);     // task 2
  off();           //

  rotate();        // task 3

}
//Serial.print(card_ID);
else {
  red_on();
  delay(700);
  off();
  red_on();
  delay(700);
  off();

  buzz();
}

card_ID = "";
}`

my freertos applied code is this. i will just paste the rotate function of all task functions for showing purposes:

void setup() {
// some code here  - inits and other things
  xTaskCreate(Main,(const portCHAR *) "Main", 128, NULL, 1, NULL );
  vTaskStartScheduler();
}

void Main(void *pvParameters) {
(void) pvParameters;

for(;;) {
  if ( ! mfrc522.PICC_IsNewCardPresent()) {
      return;
    }

    // Select one of the cards
    if ( ! mfrc522.PICC_ReadCardSerial()) {
      return;
    }

    //mfrc522.PICC_DumpToSerial(&(mfrc522.uid));

    for (byte i = 0; i < mfrc522.uid.size; i++) {
     card_ID += mfrc522.uid.uidByte[i];
   }

   if(card_ID==rfid){
    xTaskCreate(Buzz,(const portCHAR *) "Buzz", 128, NULL, 2, NULL );
    xTaskCreate(GreenLed,(const portCHAR *) "GreenLed", 128, NULL, 3, NULL );
    xTaskCreate(Rotate,(const portCHAR *) "Rotate", 128, NULL, 4, NULL );

   }
   //Serial.print(card_ID);

   else {
     xTaskCreate(RedLed,(const portCHAR *) "RedLed", 128, NULL, 2, NULL );
     xTaskCreate(Buzz,(const portCHAR *) "Buzz", 128, NULL, 3, NULL );
   }

   card_ID="";
 }
}

void Rotate(void *pvParameters) {
(void) pvParameters;

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

}


texts: How to use SPI to set/ read registers for a sensor (Avoiding need for Github Lib)

texts:
Ok so as some readers might have seen, my current project involves using MPU's. The idea is sending data via CAN bus to a controlling MCU to then send to a raspberry pi to perform the calculations required for my MATLAB/ Simulink model.

After a lot of searching i found this great post/ blog on how to set I2C registers.

Setting I2C Registers

With this, i was able to avoid using a library from Github. I do NOT think i am better than the people writing the libraries, just it's difficult to truly understand code/ a project with a downloaded library and it just stuffed at the top of a piece of butchered example code.

Using the above blog, i learnt how to control an MPU6050 myself in a very basic sense. I am now trying to use an MPU9250 for the sake of extra speed over SPI. However i am trying to understand how to set registers using the SPI interface. For example below for I2C you could write;

  Wire.begin();
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x6B);  // PWR_MGMT_1 register
  Wire.write(0);     // set to zero (wakes up the MPU-6050)
  Wire.endTransmission(true);

and then access the registers like below;

Wire.beginTransmission(MPU_addr);
  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
  Wire.endTransmission(false);
  Wire.requestFrom(MPU_addr,14,true);  // request a total of 14 registers
  AcX=Wire.read()<<8|Wire.read();  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
  AcY=Wire.read()<<8|Wire.read();  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
  AcZ=Wire.read()<<8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
  Tmp=Wire.read()<<8|Wire.read();  // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
  GyX=Wire.read()<<8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
  GyY=Wire.read()<<8|Wire.read();  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)

my question, is how do you read and write to registers in a similar way via SPI. I've found lots of info on using SPI, but not configuring sensors etc with it in a nice, "SPI configuration for Dummies" type of thing. Is my googling just terrible?

EDIT - My goal is learn the theory behind making a basic library for a sensor, not to make my own SPI library. For example, make a library that can be used to control an MPU9250 using SPI commands to change registers. The last part is what i am struggling with. Interfacing with a sensor to change register values or read registers with SPI.

The link above is almost a crash course in how to use the wire library to interface with a sensor. How do you use the SPI library to change/ read register values.

EDIT2 - Is this the usual format for communicating with registers using SPI on arduino? Thanks

digitalWrite(SS, LOW);
SPI.transfer(0xF1);  // Read, Sensor 1...
SPI.transfer(0x02);  // ... RESA register
highByteA = SPI.transfer(0x00);  // Read High Byte of RESA
lowByteA = SPI.transfer(0x00);  // Read Low Byte of RESA
highByteB = SPI.transfer(0x00);  // Read High Byte of RESB
lowByteB = SPI.transfer(0x00);  // Read Low Byte of RESB
.
.
.
digitalWrite(SS, HIGH);

thanks


texts: Can the atmega328 return remainder during integer division?

texts:
When I write code like this:
int a = 7
int b = 2
int c = a/b
int r = a%b

Does the chip use the remainder while calculating c or does it redo the entire calculation?


texts:
I've got a question regarding the use of Millis() on a Leonardo Arduino. I'm currently using it to time 4 seconds elapsed while sending a serial message every second. These messages play a sound. On the fourth message the sound is different to signify that the Arduino has started an event.

I'm running into an issue where the sounds are occasionally being played sporadically without a consistent 1 second between them. I'm wondering if there is a better way of doing what I'm doing? During the timing the Arduino is doing nothing else, and the receiving computer is also generally not doing anything taxing. Is this even an issue from the Arduino side? My receiving program is written in C# using System.IO.Ports.SerialPort.

The reason this is done through Arduino is because the event started by the Arduino needs to correspond exactly to the sounds, though if this remains unresolved I will need to rework this.

Edit: Code as requested.

void setup()
{
    //Setup Code
}

void loop()
{
    //Code that handles other serial messages and various states
    if (isSpecificState == true)
        onSpecificState();
}

void onSpecificState()
{
    //Setup to handle state

    long holdStart = millis();
    long holdDuration = 0;

    boolean print1 = false;
    boolean print2 = false;
    boolean print3 = false;
    boolean print4 = false;

    while(holdDuration <= 4000)
    {
        if (holdDuration >= 4000 && !print4)
        {
            Serial.println("tt_sound:2");
            print4 = true;
        }
        else if (holdDuration >= 3000 && !print3)
        {
            Serial.println("tt_sound:1");
            print3 = true;
        }
        else if (holdDuration >= 2000 && !print2)
        {
            Serial.println("tt_sound:1");
            print2 = true;
        }
        else if (holdDuration >= 1000 && !print1)
        {
            Serial.println("tt_sound:1");
            print1 = true;
        }
        holdDuration = millis() - holdStart;
    }

    //Handle state
}

As I mentioned in the comments, the Arduino is doing nothing else while the timing is happening.


texts: Arduino with NRF24L01. Getting correct data from unkown transmitter

texts:
I want to use my Arduino with this: VAC8010F measure unit. It communicates with NRF24L01. The problem is I simply don't know which band or information it is receiving. Can somebody help me with this?

Thanks for any suggestions!


texts: Create a 7 segment display out of controllable LED strips to display digits

texts:
Highschool newbie here
I'm trying to create a 7 segment two-digit display (88 shaped) to display the number of times a distance sensor detects something passing in front of it
Here's what I've done so far---

#define TRIG_PIN 5
#define ECHO_PIN 6
#define light 4

void setup() {

Serial.begin(9600);

 pinMode(TRIG_PIN, OUTPUT);
 pinMode(ECHO_PIN, INPUT);
 pinMode(light, OUTPUT);
 digitalWrite(TRIG_PIN, LOW);
}

float measureDistance() {

    unsigned long start_time, end_time, pulse_time;

    digitalWrite(TRIG_PIN, HIGH);
    delayMicroseconds(10);
    digitalWrite(TRIG_PIN, LOW);

    while (digitalRead(ECHO_PIN) == 0);

    start_time = micros();
    while (digitalRead(ECHO_PIN) == 1);
    end_time = micros();
    pulse_time = end_time - start_time;

    if (pulse_time > 23200) pulse_time = 23200;

    float dist_in = pulse_time / 148.0;
    float dist_cm = pulse_time / 58.0;

    delay(60);

    return dist_in;}

        int startScore = 0;

void loop() {

    float sensorDist = measureDistance();

    if (sensorDist<2){
       digitalWrite(light, HIGH);
       int currentScore = startScore++;
       delay(500);
       Serial.println(currentScore);
    }
    else
    {
      digitalWrite(light,LOW);
    }

    }

If I'm using controllable neopixel ws2812b led strips...how do I program them to display currentScore? I'll be using two led's per segment so 14 per digit and 28 in total for the two digit display.
I am not sure how to proceed with FastLED and neopixel stuff
I found this from a youtube channel:
https://github.com/leonvandenbeukel/7-Segment-Digital-Clock-V2/blob/master/7-Segment-Clock/7-Segment-Clock.ino
This is pretty close except it's a clock
What should I do? I have little programming knowledge, sorry for the stupid questions. Sorry for my bad English. Thank you for reading :)


texts:
I'm using Fedora_21_MATE.img on a Raspberry Pi. Installing the Arduino IDE 1.0.6 using these commands, taken from Arduino On Pi. Those instructions are for Raspbian, I assume, so changing for Fedora, apt-get to yum:

sudo yum install arduino

One waits and arduino installs. One can then run the Arduino IDE from the Fedora GUI menu, and it loads - after moaning about the user has to be a member of the dialout and lock groups. This is easily resolved by adding the user to the required groups, using the control panel.

However, trying to compile anything, i.e. blink, in the IDE, gives me the following error:

avr-g++: error trying to exec cc1plus: execvp: No such file or directory

In verbose mode, little additional information is offered.

Arduino: 1.0.6 (Linux), Board: "Arduino Uno"
avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard /tmp/build6314348775898760987.tmp/Blink.cpp -o /tmp/build6314348775898760987.tmp/Blink.cpp.o
avr-g++: error trying to exec 'cc1plus': execvp: No such file or directory

The file in question, cc1plus, is actually present in the filesystem:

[piebody@berrybody ~]$ locate cc1plus
/usr/libexec/gcc/armv7hl-redhat-linux-gnueabi/4.9.2/cc1plus
/usr/libexec/gcc/avr/4.9.2/cc1plus
[piebody@berrybody ~]$

Does anyone know why it doesn't run "out of the box"? Do I need to modify any environment variables, and if so, which ones and with what exactly? I assume my PATH environment variable needs fixing, but is there any environment variable specific to avr-g++ that needs changing?

I appreciate that this is probably a simple UNIX paths issue, and that the question may be more suited to SE: Unix & Linux.


texts: Computer to multiple arduino bluetooth modules

texts:
Im going to take part in a competition called IEEE Very Small Soccer and I need to set up a communication between my computer, that will run visual and strategy algorithms, and send some commands to 3 Arduinos, which will be the players. Most people use the Xbee module to send data to the Arduinos, so I was wondering why not use the Bluetooth module instead, once it is so much cheaper and the difference in power consumption isn't so big, the only drawback would be the working range, which is 10m, if Im correct... However, if the distance is really 10m, not 5m It will be ok, because the computer is always close to the robots.
Summing up, my questions are:

Can I use a computer to send data to 3 Arduinos at the same time?
What is the real working range of the Bluetooth module?
Any suggestions or tips? =D

?


texts:
I can't seem to be able to escape a while loop using a keypad button. I've tried the solution from this thread: https://forum.arduino.cc/index.php?topic=79932.0

Here's my code:

void alarm(){
  char customKey = customKeypad.getKey();

  while (customKey == NO_KEY){
    customKey = customKeypad.getKey();
    lcd.noDisplay();
    delay(750);// change for faster flash
    lcd.display();
    delay(750);// change for faster flash
  }
  lcd_home_screen();
}

I tried both == and != for the while (customKey == NO_KEY)

Additional info:
I am calling this alarm function from another function inside my Loop.
Here's the complete code:

void loop() {
  // keypad
  char customKey = customKeypad.getKey();
  if (customKey == 'A'){
    main_program(5);
  }
}

int main_program(int duration){
  timer(duration);
  alarm();
}


texts:
This part of my project is very hard for my brain to wrap around and comprehend. But basically I just need to go through every combination. For example:
If I have an array with 255 variables and I need to bruteforce all the combinations by 30's (0, 30, 60, 90) How would I go about doing that in a decently compact form? It's really brain hurting please help a noob out <3
Note: I'm making a universal IR Remote but if by chance I don't have the code then I can just change the mode to brute force it.
volatile uint16_t IRCode[]={384,171,43,21,21,21,21,21,21,64,21,21,21,21,21,21,21,21,21,64,21,21,21,64,21,21,21,64,21,64,21,64,21,64,21,64,21,21,21,21,21,21,21,64,21,21,21,21,21,21,21,21,21,64,21,64,21,64,21,21,21,64,21,64,21,64}; // ProntoHex to uint16_t delete first 4 array numbers.
volatile uint16_t MicrosPassed;
volatile uint8_t ArraySeq;
uint8_t LEDState;
uint8_t SetMode=0;

void setup() {
  Config();
  SendIRCode();
}

void loop() {

}

void SendIRCode() {
  if(LEDState==1) {
    TCCR1A&=63;
    LEDState=0;
  } else {
    TCCR1A|=192;
    LEDState=1;
  }
}

void Config() {
  DDRB|=10;
  ICR1=416;
  OCR1A=9983;
  TCCR1A=2;
  TCCR1B=24;
  TCCR1B|=1;
  TIMSK1=1;
}

ISR(TIMER1_OVF_vect) {
  MicrosPassed++;
  if(MicrosPassed==IRCode[ArraySeq]) {
    SendIRCode();
    MicrosPassed=0;
    ArraySeq++;
       }
}


texts: Connecting MicroSd Reader with arduino uno

texts:
I am working on a Project with
(a) Arduino Uno Clone (6 PWM Pins i.e, 3,5,6,9,10,11)
(b) 6 Servos
(c) MicroSD Reader Module
(d) Speaker

As We Know that MicroSD reader modules uses pins 10, 11, 12 of an Arduino board, but my pin 11 is already being used by a servo motor.
1. Then how can I connect the MicroSD reader in my project ?
2. Which pin can I use for the speaker in this case ?

Please help me plus Provide me some additional information if needed.


texts: In line following robot do this code work perfectly as iam unclear about the right and left moving programing lines

texts:
#define LS 2      // left sensor
#define RS 3      // right sensor

/*-------definning Outputs------*/
#define LM1 4       // left motor
#define LM2 5       // left motor
#define RM1 6       // right motor
#define RM2 7       // right motor

void setup()
{
  pinMode(LS, INPUT);
  pinMode(RS, INPUT);
  pinMode(LM1, OUTPUT);
  pinMode(LM2, OUTPUT);
  pinMode(RM1, OUTPUT);
  pinMode(RM2, OUTPUT);
}

void loop()
{
  if(digitalRead(LS) && digitalRead(RS))     // Move Forward
  {
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, LOW);
  }

  if(!(digitalRead(LS)) && digitalRead(RS))     // Turn right
  {
    digitalWrite(LM1, LOW);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, LOW);
  }

  if(digitalRead(LS) && !(digitalRead(RS)))     // turn left
  {
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, LOW);
    digitalWrite(RM2, LOW);
  }

  if(!(digitalRead(LS)) && !(digitalRead(RS)))     // stop
  {
    digitalWrite(LM1, LOW);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, LOW);
    digitalWrite(RM2, LOW);
  }
}

i got this code from a site.My doubt is if the left sensor is not reading means it has value of zero hence it is on black line and the right sensor is on white line.Then it should move to left side itself.BUt the program says it should moves to right.Iam a beginner.Please help me to clear my doubt


texts: Arduino wait for incomming data from blynk terminal

texts:
I need to add wait command in code where it waits the next input value from blynk terminal to arduino? How can I do that? please help, I will appreciate your help, Thank you.
Here is my code
BLYNK_WRITE(V0)
{

     String i = param.asStr(); //String Value from blynk

      if(i == "A"){
          Serial.println("Ready to enroll a fingerprint!");
          Serial.println("Please type in the ID # (from 1 to 127) you want to save this finger as...");

          Blynk.virtualWrite(V0, "Ready to enroll a fingerprint!");
          Blynk.virtualWrite(V0, "Please type in the ID # (from 1 to 127) you want to save this finger");

int numb = i.parseInt; //I need to add a command here to wait for the next blynk terminal value

  Serial.print("Enrolling ID #");
  Serial.print(numb);
}}


texts: Sending file from SD card to android using ESP8266

texts:
I came across this post

https://stackoverflow.com/questions/10327506/android-arduino-bluetooth-data-transfer

where the author sends files from the arduino to android platform over bluetooth.

I am wondering, is this possible to achieve with the ESP8266 SoC?

I have no experience with it, but i am willing to buy and experiment, if it hads that functionality.


texts:
I don't understand the following Debounce code. (The complete code is at the bottom.) From what I understand, when the pin reads something, we wait at least 50 milliseconds before performing anything. But doesn't the reading variable get reset every loop iteration, so reading equals zero in the inner if-condition in every iteration.
What I think is the sequence of events: loop(), loop(), loop(), "loop(), button press, reading=1, set lastDebounceTime, first if condition fails because we have to wait, set lastButtonState=1", loop(), loop(),loop(),"loop() enough time has passed, but since no button press at in this iteration and the last few, reading and lastButtonState equal zero", loop(), ... .
However, this code works.
Why do we save reading in a local variable? Won't the code virtually always be this, then:
if (reading != lastButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
  }

  if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer than the debounce
    // delay, so take it as the actual current state:

    // if the button state has changed:
    if 0 != buttonState) {
      buttonState = 0;

...

Entire code:
/*
  Debounce

  Each time the input pin goes from LOW to HIGH (e.g. because of a push-button
  press), the output pin is toggled from LOW to HIGH or HIGH to LOW. There's a
  minimum delay between toggles to debounce the circuit (i.e. to ignore noise).

  The circuit:
  - LED attached from pin 13 to ground
  - pushbutton attached from pin 2 to +5V
  - 10 kilohm resistor attached from pin 2 to ground

  - Note: On most Arduino boards, there is already an LED on the board connected
    to pin 13, so you don't need any extra components for this example.

  created 21 Nov 2006
  by David A. Mellis
  modified 30 Aug 2011
  by Limor Fried
  modified 28 Dec 2012
  by Mike Walters
  modified 30 Aug 2016
  by Arturo Guadalupi

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/Debounce
*/

// constants won't change. They're used here to set pin numbers:
const int buttonPin = 2;    // the number of the pushbutton pin
const int ledPin = 13;      // the number of the LED pin

// Variables will change:
int ledState = HIGH;         // the current state of the output pin
int buttonState;             // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin

// the following variables are unsigned longs because the time, measured in
// milliseconds, will quickly become a bigger number than can be stored in an int.
unsigned long lastDebounceTime = 0;  // the last time the output pin was toggled
unsigned long debounceDelay = 50;    // the debounce time; increase if the output flickers

void setup() {
  pinMode(buttonPin, INPUT);
  pinMode(ledPin, OUTPUT);

  // set initial LED state
  digitalWrite(ledPin, ledState);
}

void loop() {
  // read the state of the switch into a local variable:
  int reading = digitalRead(buttonPin);

  // check to see if you just pressed the button
  // (i.e. the input went from LOW to HIGH), and you've waited long enough
  // since the last press to ignore any noise:

  // If the switch changed, due to noise or pressing:
  if (reading != lastButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
  }

  if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer than the debounce
    // delay, so take it as the actual current state:

    // if the button state has changed:
    if (reading != buttonState) {
      buttonState = reading;

      // only toggle the LED if the new button state is HIGH
      if (buttonState == HIGH) {
        ledState = !ledState;
      }
    }
  }

  // set the LED:
  digitalWrite(ledPin, ledState);

  // save the reading. Next time through the loop, it'll be the lastButtonState:
  lastButtonState = reading;
}

(Debounce code taken from: https://www.arduino.cc/en/tutorial/debounce.)


texts: Using USB on a Leonardo to receive data from PC

texts:
I am new to the Leonardo, having only used a duemilanove before, and I am interested in using it's USB capabilities for a project.

Basically I need it to be an input and output device, communicating to an app on the PC (probably written in C#). I need to be able to handle button presses on the arduino and get data back from the PC to display on a display connected to the arduino.

I already have the basics done hardware wise (getting the keypad and displays working as I want them to), but now the tricky part is the USB communication. The only things I can find seem aimed at emulating a keyboard and mouse - I need 2 way communication data wise.

Are there any examples of something like this? I am sort of looking for the arduino equivalent of this: http://www.waitingforfriday.com/index.php/Building_a_PIC18F_USB_device

An alternative would be to just use serial, but I don't want to be fiddling with COM ports on the PC side - it just needs to be plugged in and work.

Would be grateful for any input on this subject, if it is even possible!


texts:
Folks,
I use the RCSwitch sketch to notify my WiFi alarm controller when a motion is detected.
Using the Receiver Code, I have got the following information related to the motion detection signal from the PIR (detector):
Decimal: 8876073 (24Bit)
Binary: 100001110111000000101001
Tri-State: not applicable
PulseLength: 311 microseconds
Protocol: 1
Raw data: 9700,1096,264,400,952,420,964,380,968,372,1012,1040,316,1028,324,1016,380,332,1008,1012,340,1040,344,1000,348,356,1024,324,1016,332,1012,372,1016,336,1012,372,1008,1016,336,328,1016,1008,380,324,1016,368,1012,1008,344,

My Transmitter Sketch is as follows:
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
 Serial.begin(9600);
 // Transmitter is connected to Arduino Pin #10
 mySwitch.enableTransmit(10);
 // Optional set pulse length.
 mySwitch.setPulseLength(312);
 // set protocol (default is 1, will work for most outlets)
 // mySwitch.setProtocol(2);
 // Optional set number of transmission repetitions.
 mySwitch.setRepeatTransmit(5);
 pinMode(13,OUTPUT);
}
void loop() {
 mySwitch.send("100001110111000000101001");//Detection Signal
 //mySwitch.send("100001110111000000101001");//Detection Signal
 //mySwitch.send("101110100000000011000010");//Panic Signal
 //mySwitch.send("101110100000000011000010");//Panic Signal
 Serial.print("Sent 100001110111000000101001 ");
 digitalWrite(13,HIGH);
 delay(500);
 digitalWrite(13,LOW);
 delay(10000);
}

While it appears the message is being sent, unfortunately my Alarm Control doesn't detect it.
Can anyone suggest a fix please?
Ranjith


texts:
I am working around with HX711 ADC and a 5kg load cell, it seems the HX711 library is some sort of mystery no one wants to reveal!
Please someone explain me, I promise to keep the secret ;)
Anyone here can suggest a coding trick to compensate drifting in the reading values?
Actually the slope is ok, but the offset is not stable, also I don't know the difference between these two:
scale.set_offset();
scale.get_offset();

How these two actually do the job and shall I use them in the void loop() function?
Also that would be really helpful to suggest me a code for averaging readings beside what the library pre-used, like scale.get_units()
Thanks


texts: Digital selection for gain control not working instead showing 0

texts:
I am making a device which will have a button to measure the input and another button to reset and the inputs are variable analog values(0 to 5v) and output is a ratio of two analog input voltages. It also has a selection keys(two buttons) for four selections(like gain eg. if key1 == LOW key 2 == LOW then J = 1 and likewise)
but the problem is when i am multiplying j with it the output shows zero if I multiply numbers like 1,2,3etc without using j then the ratio value gets multiplied.

here is the code

    void setup() // put your setup code here, to run once:
    {
      Serial.begin(9600);
      pinMode( K1, INPUT );
      pinMode( K2, INPUT );
      pinMode( MeasureButton, INPUT );
      pinMode( ResetButton, INPUT );
      dsp.begin(20, 4);
      current = millis();
    }

    void loop()
    {

      while(current < wait)
      {
      Serial.println("INITIALIZING");
      delay(1000);
      current = millis();
      }
      Serial.println("                   ");
      delay(1000);
      Serial.println(" READY TO MEASURE ");
      delay(2000);
      while (digitalRead(MeasureButton) == LOW)
      {
        if(K1 == LOW && K2 == LOW)
        {J = 1; // SOMETHING VALUE
        showMessage1();
        i = 0;
        delay(1000);
        }if(K1 == LOW && K2 == HIGH)
        J= 2; // SOMETHING VALUE
        showMessage1();
        i = 0;
        delay(1000);
        if(K1 == HIGH && K2 == LOW )
        J= 3; // SOMETHING VALUE
        showMessage1();
        i = 0;
        delay(1000);
        if(K1 == HIGH && K2 == HIGH )
        J= 4; // SOMETHING VALUE
        showMessage1();
        i = 0;
        delay(1000);

      }
      while (digitalRead(ResetButton) == HIGH)
      {
      dsp.setCursor(1,0);
      dsp.print("                   ");
      Serial.println("                   ");
      delay(1000);
      dsp.setCursor(1,0);
      dsp.print("RESETED");
      Serial.println("RESETED");
      delay(1000);
      }
while (digitalRead(ResetButton) == LOW)
      {
      dsp.setCursor(1,0);
      dsp.print("                   ");
      Serial.println("                   ");
      delay(1000);
      dsp.setCursor(1,0);
      dsp.print("PRESS MEASURE");
      Serial.println("PRESS MEASURE");
      delay(1000);
      }
    }

    void showMessage1()
    {
       while(i<5)
        {
        A = analogRead(A0);
        B = analogRead(A1);
        C = analogRead(A2);
        D = analogRead(A3);
        N = analogRead(A4);
        W1 = (A/N)*J;        // J is another variable whose value is dependent on K selection values
        W2 = (B/N)*J;        // J is another variable whose value is dependent on K selection values
        W3 = (C/N)*J;        // J is another variable whose value is dependent on K selection values
        W4 = (D/A)*J;        // J is another variable whose value is dependent on K selection values

        sumW1 = sumW1 + W1;
        sumW2 = sumW2 + W2;
        sumW3 = sumW3 + W3;
        sumW4 = sumW4 + W4;
        i++;
      }
        Serial.print("W1-");
        Serial.print(sumW1);
        Serial.print("W2-");
        Serial.println(sumW2);
        Serial.print("W3-");
        Serial.print(sumW2);
        Serial.print("W4-");
        Serial.println(sumW4);
        sumW1 = 0;
        sumW2 = 0;
        sumW3 = 0;
        sumW4 = 0;
    }


texts: Arduino interrupt not called using PinChangeInterrupt

texts:
I am new to Arduino and I was trying to figure out how to use an interrupt. When I ran this it would read my magnet but the interrupt would never be called and I couldn't figure out if anyone can help me that would be great.

Thanks.

Here is the code

#include <PinChangeInterrupt.h>

//#define INTERRUPT_PIN 12
#include <Math.h>

#define RADIUS 3
const int hallPin = 7; // the number of the hall effect sensor pin
const int ledPin =  13; // the number of the LED pin
// variables will change:
int hallState = 0; // variable for reading the hall sensor status
double inital_val = 0.0;
double distance = inital_val;

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  pinMode(hallPin, INPUT);
  //attachInterrupt(hallPin, calc_distance, HIGH);
  // initialize the hall effect sensor pin as an input:
  attachInterrupt(digitalPinToInterrupt(hallPin), calc_distance , HIGH);
  Serial.begin(9600);
}

void loop() {
  //read the state of the hall effect sensor:
  hallState = digitalRead(hallPin);
  if (hallState == LOW) {
    // turn LED on:
    Serial.print("Main Loop: HallState LOW\n");
    digitalWrite(ledPin, HIGH);
    Serial.print(distance, 2);
    Serial.print("\n");
  } else {
    Serial.print("Main Loop: HallState HIGH\n");
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}

void calc_distance() {
  Serial.print("INTERRUPT! \n");
  if (digitalRead(hallPin) == HIGH) {
    Serial.print("YES!\n");
    distance += PI * 2 * RADIUS;
  } else {
    Serial.print("NO!\n");
  }
}


texts: Sending a string to arduino and is not reacting to it

texts:
I am trying to move servos with a VR headset, I am using the Unreak 4 Arduino Plugin, but that is not the problem. I send the rotation Y and Z from the headset, convert them to int and then send them together as an int separated by commas. Here's what it does: It gets the rotation Z, it converts it to int, then it converts it to String, I add a comma at the end of the String, then I add the rotation Y after the comma, and it returns me: "rotationZ","rotationY" (the values between " are the numbers sent by Unreal to arduino), these results may come in negative or positive value.

Then inside arduino I have this code:

#include <Servo.h>
#include <SoftwareSerial.h>

Servo servo1;
Servo servo2;  // Crea un Objeto servo

int angle = 10;
int posicion = 10;    // Variable de la posicion del servo

String user_input1;

int r;
int g;

void setup()
{
  Serial.begin(9600);
  servo1.attach(2);  // Selecionamos el pin 2 como el pin de control para el servo
  servo2.attach(3);  // Selecionamos el pin 2 como el pin de control para el servo

  servo1.write(0);
  servo2.write(0);

  Serial.setTimeout(5);
}

void loop()
{
  if (Serial.available() > 0)
    {
  String firstValue  = Serial.readStringUntil(',');
 // String first = Serial.readString(); //next character is comma, so skip it using this
  String secondValue = Serial.readStringUntil(',');
//  String second =  Serial.readString();

   r = firstValue.toInt();
   g = secondValue.toInt();
    }
  if (r < 0)
  {
    r = r * -1;
  }

  if (g < 0)
  {
    g = g * -1;
  }

  Serial.println(r);
  Serial.println(g);

  servo1.write(r);
  servo2.write(g);

}

As you can see, it gets the numbers between the commas and then it converts them to int, and then it applies to the servos which are in pins number 2 and 3 (yes, everything is plugged in correctly), which it should then move them acordingly the position of the VR headset, I've also tried to make them always receive positive results but still doesn't work. I have searched over the internet on how to separate a string divided by commas and I still don't know if it's correctly done.

EDIT: I also tried to input the numbers in the console manually, and it gets them right and moves the servos but it still doesn't work with the VR. I also added Serial.setTimeout(5) to try if it works that way.

Thanks in advance for reading this bunch'o text about my problem.


texts: Problem activating HC-05 AT command mode with Arduino Uno Bluetooth shield

texts:
Please be gentle with me. I am attempting to modify the configurations of my HC-05 bluetooth module by using the AT command set. The method by which I'm trying to do this is by implementing the following connection:

HC-05 GND --> Arduino GND;
HC-05 3.3v --> Arduino 3.3V;
HC-05 TX --> Arduino Pin 10;
HC-05 RX --> Arduino Pin 11;
HC-05 KEY --> Arduino Pin 9

This is the code which I uploaded to my Arduino (btw my arduino uno is an SMD clone): (code's from http://www.instructables.com/id/Modify-The-HC-05-Bluetooth-Module-Defaults-Using-A/step2/The-Arduino-Code-for-HC-05-Command-Mode/)

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(10, 11); // RX | TX

void setup() {
  pinMode(9, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
  digitalWrite(9, HIGH);
  Serial.begin(9600);
  Serial.println("Enter AT commands:");
  BTSerial.begin(38400);  // HC-05 default speed in AT command more

 }

void loop() {
  // Keep reading from HC-05 and send to Arduino Serial Monitor
  if (BTSerial.available())
    Serial.write(BTSerial.read());

  // Keep reading from Arduino Serial Monitor and send to HC-05
  if (Serial.available())
    BTSerial.write(Serial.read());

}

The problem is I can't seem to activate the AT mode. I don't get any response from the Serial Monitor whatever AT command I try. I double-checked the wiring and it's all good. I can't figure out what the problem is.