texts: RePaper 2.7" eInk Display with Arduino Due

texts:
I got a RePaper 2.7' eInk display that unfortunately doesn't support Arduino Mega because of its limited SRAM capacity (8k bytes). I am porting the library to Arduino Due because of its sufficient RAM capacity (96 KB in two banks: 64KB and 32KB).

I am using the thread rePaper - 2.7" Graphic eInk Dev Board Headers  and I've done all the modifications.

Has anyone successfully ported the library to Arduino Due? Also, does anyone have a library for Dynamic Printing for this display?


texts: MP3 Shield stacked on DMX Shield - Arduino Uno

texts:
We are using Arduino Uno revision 3, with TinkerKit DMX Shield rev. 4 and Sparkfun Mp3 Shield.

We uploaded the Mp3 Shield example called FilePlayer and after we open the serial monitor, the interface is there and working. The problem is that it won't output the music from the SD card.

If we ONLY stack the Mp3 Shield onto Arduino, it works.

Is there some king od incompatibility between the DMX and Mp3 Shield, and if there is, what would be the solution, maybe some kind of bypass, since we aren't that familiar with what pins the DMX shield uses for it's purpose. ATM the Tinkerit site is down so we can't acess the TinkerKit DMX Shield datasheet.


texts:
hi I am using Arduino transmitter and receiver it works properly with sending and receiving username and password but I would include to check the username if its true open the led , I added this in the code but it seems that the code ignoring it ( the last part) as well as I want it to take the password and username at the same time

this is the recover code

#include <RH_ASK.h>//include radioHead ASK library
#include <SPI.h> // include dependant SPI libray

 RH_ASK rf_driver; // create ASK object
int ledon = 13;
String userid;
String password;
 //RH_ASK ID1; // create ASK object
//RH_ASK pass1; // create ASK object

void setup() {

  rf_driver.init(); //initialize ASK object

  Serial.begin(9600); //setup serial monitor to 9600

  //if(!rf_driver.init())
       //Serial.print("init failed");
}

void loop() {

  // set buffer to size of expected message
  uint8_t buf[9];
  uint8_t buflen =sizeof(buf);

  //check if recevied packet is correct size
  if (rf_driver.recv(buf,&buflen))
  {
    int i;
    // message received with valid checksum
    Serial.print("id: ");
    Serial.println((char*)buf);
      userid =(char*)buf;
        Serial.println(userid);

  }

delay(5000);

   uint8_t buf2[8];
  uint8_t buflen2 = sizeof(buf2);

   if (rf_driver.recv(buf,&buflen))

  {

    int i;
    // message received with valid checksum
    Serial.print("password: ");
    Serial.println((char*)buf);
      password = (char*)buf;
      Serial.println(password);

  }
  delay(5000);

while ( userid =="A00034732" && password == "123456789"){
digitalWrite(ledon, HIGH);
delay(2000);
digitalWrite(ledon, LOW);

}
}

transmitter code ----

//Include RadioHead Amplitidue shift keying library
#include <RH_ASK.h>
// Include dependatnt ISP library
#include <SPI.h>

//create Ampitude shift keying object
RH_ASK rf_driver;

void setup() {
 // intialize ASK objct
rf_driver.init();

Serial.begin(9600);

  //if(!rf_driver.init())
      //Serial.print("init failed");

}

void loop()
{

  const char *pass= "123456789";
rf_driver.send((uint8_t *)pass, strlen(pass));
rf_driver.waitPacketSent();
delay(5000);

const char *ID= "A00034732";

rf_driver.send((uint8_t *)ID, strlen(ID));
rf_driver.waitPacketSent();
delay(5000);

//const char *pass= "12345678";
//rf_driver.send((uint8_t *)pass, strlen(pass));
//rf_driver.waitPacketSent();
//delay(5000);

}


texts: Timer Countdown to control relay (multiple functions in void loop)

texts:
I'm trying to build this project with a simple code.
Object is to hit up button to increment minutes or down to decrement minutes then hit start to start countdown,
while its counting relay will turn On light till counting is done will turn light off and if I hit end button while counting it will end counting and turn off relay.

Here is my try I would appreciate if you could support me.
i can not move to countDown() function in the loop if i press start
I need help to figure out a good technique of declaring functions in void loop in arduino

#include <LiquidCrystal.h>

LiquidCrystal lcd(1,2,4,5,6,7);

#define numberOfSeconds(num) ((num/1000) % 60 )
#define numberOfMinutes(num) (((num/1000) / 60) % 60)

//unsigned long timeLimit = 3600000; // 1000 ms in 1sec, 60secs in 1min, 60mins in 1hr. so , 1000x60x60 = 3600000ms = 1hr

const int upBtn = 8;
const int downBtn = 9;
const int startBtn = 10;
const int endBtn = 11;

int btnPushCounter = 0;
int minutes;
int seconds;
unsigned long minutesGiven;
unsigned long timeLimit;
unsigned long timeRemaining;

int upBtnState = 0;
int lastUpBtnState = 0;

int downBtnState = 0;
int lastDownBtnState = 0;

int startBtnState = 0;
int lastStartBtnState = 0;

int endBtnState = 0;
int lastEndBtnState = 0;

bool bPress = false;

void setup() {

 lcd.begin(16,2);
 pinMode(upBtn, INPUT_PULLUP);
 pinMode(downBtn, INPUT_PULLUP);
 pinMode(startBtn, INPUT_PULLUP);
 pinMode(endBtn, INPUT_PULLUP);

 lcd.clear();
 lcd.setCursor(0,0);
 lcd.print("Minutes : ");
 lcd.print(btnPushCounter);
}
void loop() {

    checkUp();
    checkDown();
//    countDown();
    if(bPress){
      bPress = false;
      displayNumber();
    }
}

void displayNumber(){
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Minutes : ");
    lcd.print(btnPushCounter);
}

void checkUp(){
  upBtnState = digitalRead(upBtn);
  // compare the buttonState to its previous state
  if (upBtnState != lastUpBtnState) {
    // if the state has changed, increment the counter
    if (upBtnState == HIGH) {
        bPress = true;
      btnPushCounter++;
    }
    delay(50);
  }
  // save the current state as the last state, for next time through the loop
  lastUpBtnState = upBtnState;
}

void checkDown(){
  downBtnState = digitalRead(downBtn);

  // compare the buttonState to its previous state
  if (downBtnState != lastDownBtnState && btnPushCounter != 0 ) {
    // if the state has changed, increment the counter
    if (downBtnState == HIGH) {
        bPress = true;
      btnPushCounter--;
    }
    // Delay a little bit to avoid bouncing
    delay(50);
  }
  // save the current state as the last state, for next time through the loop
  lastDownBtnState = downBtnState;
}

void checkStart(){
  startBtnState = digitalRead(startBtn);
  if(startBtnState != lastStartBtnState){
    if(startBtnState == HIGH){
      bPress = true;
//      lcd.
    }
  }
}

void countDown() {
//  unsigned long timeLimit = 3600000;
  minutesGiven = btnPushCounter;
  timeLimit = minutesGiven * 1000 * 60;
  timeRemaining = timeLimit - millis();
  while(timeRemaining > 0){
    seconds = numberOfSeconds(timeRemaining);
    minutes = numberOfMinutes(timeRemaining);
    lcd.setCursor(2,7);
    lcd.print(minutes);
    lcd.print(" ");
    lcd.print(seconds);
    delay(50);
    timeRemaining = timeLimit - millis();
  }
}


texts: Remove hanging PS3 input via bluetooth to arduino

texts:
I am working on a remote controlled vehicle based project. I am using a PS3 bluetooth controller for this purpose & am facing the problem described below. Any help would be appreciated.

Basically, the motors are connected to the MEGA which is connected to a USB Host Shield. A bluetooth dongle is connected to the shield. This dongle & shield enable MEGA to communicate with PS3 wirelessly. I am using the USB Host 2.0 library available for Arduino on GitHub.

My code to take input from the PS3 is as follows:

USB.Task();
if ( PS3.PS3Connected || PS3.PS3NavigationConnected )
{
    if ( PS3.getAnalogButton(UP) )
        Serial.println("UP");
    if ( PS3.getAnalogButton(DOWN) )
        Serial.println("DOWN");
    if ( PS3.getAnalogButton(LEFT) )
        Serial.println("LEFT");
    if ( PS3.getAnalogButton(RIGHT) )
        Serial.println("RIGHT");
}

This is the code inside loop(). If anyone is wondering why getAnalogButton is used instead of getButtonClick, the reason is to enable the vehicle to move ahead as long as UP is pressed & so on. This was an improvisation on our part.

As can be seen, the function prints UP, DOWN, LEFT or RIGHT as long as they are pressed continuously. The problem is that it works perfect for a while. But then, it enters an infinite loop & stops taking input from the PS3.

Basically, the input is like

UP
UP
UP
UP
UP
UP
UP
.....
LEFT
LEFT
LEFT
// At this point it hangs without printing any further inputs.

Can someone help tackle this problem? It is essential for us to move the vehicle as long as the buttons are pressed & stop when button is released. Unfortunately, there is no feature to detect PRESSED or RELEASED state for PS3. Any help would mean a lot.

Also, we initially thought that the hang was because of overflowing the serial input. So, we removed all Serial messages & tested with LEDs. But, the same problem is still faced.


texts: What's the most direct way to assign Serial.read() bytes to an array?

texts:
I'm trying to send NMEA 0183 sentences through LoRa.
Every dinstict NMEA message looks like several char arrays (sentences) followed by '\n'.
In the below picture we see one NMEA distinct message:

This message arrives in the Arduino input buffer every 1 second with differentiated values (numbers) and it has to be sent over LoRa as fast as possible.
In order to send it over LoRa I need to read all bytes on the input buffer and assign them to an array and send them as an array, not one by one. I know that Serial.read() reads only one byte, and that's the problem.
How can I read all bytes and send them as a whole?
This is my code:
  if (Serial.available()) {
     c = Serial.read();
     rf95.send((char *)c, sizeof(c));
     rf95.waitPacketSent();

I use RadioHead library, and the definition of rf.95.send is:
RH_RF95::send  (const uint8_t * data, uint8_t len)
c is of char type.


texts: Matrix keyboard and 7segment display countdown combination

texts:
I'm working on an escape room for my university with an Arduino Mega.
The last part consists of a 7segment display representing a time countdown, and the participants have to introduce the correct number in a matrix keyboard before it reaches zero.

My problem comes when for representing the seconds in the countdown, I have to use a delay, and this stops the matrix keyboard from getting the numbers.

The code I have so far:

char keys[4][4] =
{
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};

byte rowPins[4] = { 5, 4, 3, 2 };
byte colPins[4] = { 9, 8, 7, 6 };

int pinA = 26; //2
int pinB = 34; //3
int pinC = 31; //4
int pinD = 27; //5
int pinE = 25; //6
int pinF = 28; //7
int pinG = 33; //8
int D1 = 24; //9
int D2 = 30; //10
int D3 = 32; //11
int D4 = 35; //12

Keypad mykeypad = Keypad( makeKeymap(keys), colPins, rowPins, 4, 4);

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

pinMode(pinA, OUTPUT);
pinMode(pinB, OUTPUT);
pinMode(pinC, OUTPUT);
pinMode(pinD, OUTPUT);
pinMode(pinE, OUTPUT);
pinMode(pinF, OUTPUT);
pinMode(pinG, OUTPUT);
pinMode(D1, OUTPUT);  //Turns the first digit on.
pinMode(D2, OUTPUT);  //Turns the second digit on.
pinMode(D3, OUTPUT);  //Turns the third digit on.
pinMode(D4, OUTPUT);  //Turns the forth digit on.
}

//
void showTime(){

  digitalWrite(D1, LOW);
  digitalWrite(D2, LOW);
  digitalWrite(D3, LOW);
  digitalWrite(D4, LOW);

 //3
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, LOW);
  digitalWrite(pinG, HIGH);
  delay(1000);

//2
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, LOW);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, HIGH);
  digitalWrite(pinF, LOW);
  digitalWrite(pinG, HIGH);
  delay(1000);

  //1
  digitalWrite(pinA, LOW);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, LOW);
  digitalWrite(pinE, LOW);
  digitalWrite(pinF, LOW);
  digitalWrite(pinG, LOW);
  delay(1000);

  //0
  digitalWrite(pinA, HIGH);
  digitalWrite(pinB, HIGH);
  digitalWrite(pinC, HIGH);
  digitalWrite(pinD, HIGH);
  digitalWrite(pinE, HIGH);
  digitalWrite(pinF, HIGH);
  digitalWrite(pinG, LOW);
  delay(1000);

}

//Receives the chars from the matrix keyboard.
void getCode(){
   char key = mykeypad.getKey();
  if(key){
     Serial.print(key);
  }
}

void loop()
{

  showTime();

}

Any idea on how can I archieve this combination? Have been trying to find something similiar to a Thread, but Arduino doesn't support it.

Thanks in advance.


texts: Pass changing analog value from void loop to library .h file

texts:
How would I go about passing a void loop analog read value to a library .h file?
I've tried it but it only reads the pot position as soon as I plug the arduino in and does not change once booted up.

arduino main sketch file code;

#include "Arduino.h"
#include "common.h"
#include "synth.h"
#include "serial-in.h"
#include "audio-out.h"

void setup() {
  Synth<0>::initialize();
  SerialIn<0>::open();
  AudioOut<0>::open();
}

void loop() {
  int val = analogRead(A0);
  int val1 = analogRead(A1);
  int val2 = analogRead(A2);
  int val3 = analogRead(A3);
  int val4 = analogRead(A4);
  while (true) {
    if (SerialIn<0>::available()) {
      uint8_t b = SerialIn<0>::read();
      Synth<0>::receive_midi_byte(b);
    }

    int8_t level = Synth<0>::clock();
    AudioOut<0>::write(level);
  }
}

.h file code

#pragma once

// #define private public  // for tests

#include "common.h"

// associations of units
#define IOsc        Osc
#define IFilter     Filter
#define IAmp        Amp
#define IEG         EG
#define IVoice      Voice
#define ISynthCore  SynthCore

#include "osc.h"
#include "filter.h"
#include "amp.h"
#include "eg.h"
#include "voice.h"
#include "synth-core.h"

template <uint8_t T>
class Synth {
public:
  INLINE static void initialize() {
    ISynthCore<0>::initialize();
    int val = analogRead(A0);
    int val1 = analogRead(A1);
    int val2 = analogRead(A2);
    int val3 = analogRead(A3);
    int val4 = analogRead(A4);
    // Preset
    ISynthCore<0>::control_change(OSC_MODE      , 0  );
    ISynthCore<0>::control_change(OSC_COLOR     , val);
    ISynthCore<0>::control_change(MOD_RATE      , 8  );
    ISynthCore<0>::control_change(MOD_DEPTH     , val1);
    ISynthCore<0>::control_change(LPF_CUTOFF_ENV, val2);
    ISynthCore<0>::control_change(LPF_RESONANCE , val3);
    ISynthCore<0>::control_change(ENV_A         , val4 );
    ISynthCore<0>::control_change(ENV_D_R       , 1 );
  }

  INLINE static void receive_midi_byte(uint8_t b) {
    ISynthCore<0>::receive_midi_byte(b);
  }

  INLINE static int8_t clock() {
    return ISynthCore<0>::clock();
  }
};


texts: FastLED fill_rainbow - Unexpected red pixel

texts:
I'm using FastLEDs builtin fill_rainbow function for generating a rainbow spectrum on an LED strip. The issue is, I get a random red pixel midway through the yellow region. I've tried it on 3 different Arduino nano's, and two different LED-strips. Here's the code:

#include <FastLED.h>

#define DATA_PIN 2
#define NUM_LEDS 114
CRGB leds[NUM_LEDS];

uint8_t hue = 0;

void setup() {
  Serial.begin(115200);
  FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);

  fill_rainbow( leds, NUM_LEDS, hue, 1);
  for(int i=0; i<NUM_LEDS; i++) {
    Serial.print(i);
    Serial.print(' ');
    Serial.print(leds[i].r);
    Serial.print(' ');
    Serial.print(leds[i].g);
    Serial.print(' ');
    Serial.println(leds[i].b);
  }

  CHSV hsv;
  CRGB rgb;
  //rgb = hsv;
}

void loop() {
  fill_rainbow( leds, NUM_LEDS, hue, 1);
  FastLED.show();
}

Here pixel number 60 gets the rgb code 160, 0, 0. When it should have something like 160, 150, 0.

The strangest part of all is that I can get rid of the problem in two ways, either by uncommenting the line rgb = hsv;, or by commenting out the fill_rainbow function in the loop function. This strange behavior leads me to believe im somehow messing up a pointer or misusing a FastLED feature. Additionally the fill_rainbow function is very simple and relies on FastLEDs hsv to rgb typecasting, which is another reason to believe I'm doing something wrong.

So help me out here, am i doing something silly, or have I discovered a bug with FastLEDs hsv to rgb converter?


texts: Instead of a float, a displayed is question in sprintf

texts:
I need to collect a message like: "Temperature: 15.8" to send to UART. For this, I want to use sprintf. I know that this is not supported, but people solved a similar problem by converting the float to another type. I tried several options and as a result, instead of a float, I get "?". Testing at Tinkerkad.

My code:

char msg_buffer[60];
float temperature = 10.5;

void setup()
{
 Serial.begin(9600);
 //snprintf(msg_buffer, sizeof(msg_buffer), "%f", 3.333333);
 //dtostrf(temperature, 4, 3, charVal);
 sprintf(msg_buffer, "Temperature: %.0f", temperature);
 Serial.println(msg_buffer);
 pinMode(13, OUTPUT);
}

void loop() {}


texts: Arduino RTC - getting the time from RTC after the power is cut off

texts:
I have a new DS1307 (original, not a Chinese rip off), with a new battery. It is working great, but when I turn the Arduino off (it is currently connected to laptop) and then turn it back on, it resets the time.

The line that sets the time is (in setup part of code):

setDS1307time(30, 42, 21, 4, 26, 11, 14);

So, when the Arduino gets the power back it runs the program again and it overrides the correct current time.

How can I avoid this?


texts:
I would like to use the DS1302, as a count up timer.
My goal is to have the arduino time the amount of me driving my car.
So it DS1302 will be used a count-up timer ie accumulate time. however when the car is switched off, I don't want to lose the value, and when I use my car again I would like to the time to continue accumulating. The resolution can be in minutes, as this will probably be the best.

I would like something like an odometer of a car, except its going to be the time, instead of distance.

Q: Can this be done with the DS1302 Module? and also how can I do this? Is there a sample code for a count-up timer?


texts: Programming Leonardo with TTL to USB cable

texts:
I have wired my Arduino as seen in the picture, with the RX of the cable plugged into the TX (D1) of the Leonardo and the TX of the cable plugged into the RX(D0) of the Leonardo. I then have the ground plugged into GND and the power into 5V. The driver is installed correctly and the IDE recognizes the port, however, whenever I try and upload any sketch, I get the error:

Programmer Type : butterfly
         Description     : Atmel AppNote AVR109 Boot Loader

Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding

avrdude: butterfly_recv(): programmer is not responding

I can upload sketches fine via usb, is it just unable to do so via a USB to TTL cable?

Thanks in advance


texts: ArduinoJSON v6 - Passing buffer as function parameter

texts:
I'm new to ArduinoJSON - so perhaps it is a newbie's question.... but I wish to pass a StaticJsonDocument into a function as a parameter ( later on it should be implemented in a library ).

exmaple below shows test_1 what I wish to obtain, but by duplicating StaticJsonDocument, which I don't want to do.

How can test_1 should be written (as I tried in test_2)?

#include <ArduinoJson.h>

StaticJsonDocument<200> doc;

void createJSON() {
        doc["sensor"] = "gps";
        doc["time"] = 1351824120;

        JsonArray data = doc.createNestedArray("data");
        data.add(48.756080);
        data.add(2.302038);

        // Generate the minified JSON and send it to the Serial port.
        serializeJson(doc, Serial);
        Serial.println("JSON is created:");

        // Generate the prettified JSON and send it to the Serial port.
        serializeJsonPretty(doc, Serial);

}

bool test_1(StaticJsonDocument<100> _doc){
        serializeJson(_doc, Serial);
        return true;
}

bool test2(const JsonObject& _doc){
        Serial.println("HI");
        serializeJson(_doc, Serial);
}

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

        createJSON();
        test_1(doc);

}

void loop() {
        // not used in this example
}


texts: How to use a non-adafruit BMP280 sensor for continuous data outflow

texts:
please I need help with the arduino BMP280 breakout board I got from  AliExpress. I’m pretty new to the arduino world, I need it for my rocket datalogger, I downloaded the adafruit BMP280 library but I don’t know how or where to change the data rate and what does the “default standby time” mean in the library sensor code? I want to get at least 10-20points of data per second as the rocket will be traveling very fast. Can someone please help me with a solution, or if there’s another library that solves my problem. I’m really stuck. Also, I don’t want my code to stop while waiting for temp, pressure and altitude values and also get the altitude before launch so that I can now the approximate height of the rocket above see level. Any help would be appreciated.
Details
Connection type: 12c
Application : Water rocket altimeter/datalogger and flightcomputer.
Brand: Unknown
Microcontroller: Arduino Nano


texts: datalogging sampling frequency bottleneck

texts:
My datalogging system which consits of the Flora, RTC, SD card breakout board, LSM9DS0 sensor is shown in the picture below;

https://www.dropbox.com/s/d8pwcn59nq11lzs/2014-11-25%2012.26.56.jpg?dl=0

The sampling rate/s is capped at 30 when writing into the sd card. If I disable the sensor and only save the time it goes up to 65. Writing into the serial interface rather than the sd card makes the rate goes up even higher at 127. for my application I need at least 100 samples/s. I am thinking the sd card is the problem after making the tests mentioned. The flora clock at 16Mhz is surely able to provide a higher sampling frequency. After checking the sensor datasheet and library I haven't found any limitation either. any input on this issue?


texts: Can the ATTINYx5 use its universal serial interface for a better UART than the Sofware Serial library alone? If so, is there a library or tutorial for this?


texts:
I'm a little bit confused. I'm running the same code on a ESP32 (Adafruit Huzzah32) and an Arduino (SparkFun Pro Micro). It works on the ESP32 but not on the Arduino.
Are there different API implementations?
It seems that the timings are not the same. The Arduino does not have the gaps between the bytes.


texts: Receive multiple data from arduino using String builder

texts:
I am working on a small project where I have to read data from different hardware and display it on android app. I am using arduino Uno to get the values from a sensor and a motor and I use a bluetooth module to send the data to the android device. I know how to read data from motor only but not from motor AND sensor. The data displayed on the arduino can be assumed as follows:

Motor: 132

Sensor: 258

Motor: 259

Sensor: 992

So first, we will read the value of the motor then the sensor then the motor and so on. Here is part of the code where I used handler and string builder to read data from the motor. How to modify the code in order to read from BOTH the motor and sensor and keep the updating the values?

Code:

Handler mHandler = new Handler()
    {
        public void handleMessage(android.os.Message msg) {
            switch (msg.what) {
                case 1:
                    byte[] readBuf = (byte[]) msg.obj;
                    String strIncom = new String(readBuf, 0, msg.arg1);
                    sb.append(strIncom);
                    int endOfLineIndex = sb.indexOf("\r\n");
                    if (endOfLineIndex > 0) {
                        String sbprint = sb.substring(0, endOfLineIndex);
                        sb.delete(0, sb.length());
                        motor.setText(sbprint);             // update TextView
                    }

                    break;
            }
        };
    };


texts: 127v/220v AC sensor - What's the role of this particular resistor?

texts:
After searching for a very long time for a 127v/220v (AC) sensor without using any kind of transformers, I found this very nice idea (image below):

I'd like to understand how this module works because I'll have to replicate it in my project without actually using it. I can already tell what's the role of every component, except for both resistors. The first resistor (10k) is placed between the capacitor's legs and, therefore, I'm assuming it's just a bleeding resistor. Am I right? The second resistor (220k), between the AC source and the optocoupler, I have no clue. I was also thinking whether I can improve this sensor by adding a rectifier bridge between the AC source and the optocoupler, allowing me to use a smaller capacitor to normalize the signal. Does that make sense? Thanks!


texts: Do I need to use the PWM pins in order to control brushless motors Arduino Uno?

texts:
I am building a quadcopter with this schematic:

It works very good but i have the pins on 3,5,6,9 = PWM pins. Is it possible to use "regular" pins instead? I will add more modules later on so i will most likely run out of PWM pins.

I could of course try it right now but i want to ask first so i could potentially avoid to destroy any items!


texts:
I need to display measurements of a sensor which need to be presented on a precise time-scale.
Since the loop function is not quite precise, how can i make sure that i can measure at say for example exactly 1ms?
( I am using an ADXL345 sensor )
Thanks a lot!


texts: How do you figure out an efficient battery setup for a project?

texts:
I have a project where I need an Arduino Uno and 4 DC motors to run on batteries. My first thought was that I'll just hook up 3 or 4 AAs to the Arduino and a 9V to the motor drivers.

I googled to be safe and the internet consensus seemed like that method would be very inefficient. Voltage wasn't the problem, but apparently 9V have very low current and I'd be wasting money, and the Arduino wastes current like a madman. Most solutions involved buying additional hardware.

Is there a way I can efficiently power my project without buying more chips?


texts: Fail to retrieve the value from gsm sim 900A by using AT Command to PHP script

texts:
I am currently trying to establish a connection between my gsm sim900A to one of my test server. The connection seems pretty good so far, though I'm a little bit confused why there are no values retrieved by my php file. Even so, the insert query works although it insert empty value into the database. So my question is how to retrieve it properly? I already change the method in php script to POST, both of it doesn't return any good signs.

Arduino Code:

void postData()
{
  sim900a.println("AT+HTTPINIT");
  delay(1000);
  printSerialData();

  sim900a.println("AT+HTTPPARA=\"CID\",1");
  delay(1000);
  printSerialData();

  sim900a.println("AT+HTTPPARA=\"URL\",\"test.my/demo/writedata.php\"");
  delay(1000);
  printSerialData();

  sim900a.println("AT+HTTPDATA=12,10000");
  delay(1000);
  printSerialData();

  sim900a.println("strBoton=999");
  delay(1000);
  printSerialData();

  sim900a.println("AT+HTTPACTION=1");
  delay(1000);
  printSerialData();

  sim900a.println("AT+HTTPREAD");
  delay(1000);
  printSerialData();

  sim900a.println("AT+HTTPTERM");
  delay(1000);
  printSerialData();
}

PHP Code:

<?php
$servername = "test.my";
$username = "****";
$password = "****";
$dbname = "test";

$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$Boton = $_GET["strBoton"];

$sql = "INSERT INTO test VALUES ('$Boton')";

if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>

Output:

AT+HTTPINIT
OK

AT+HTTPPARA="CID",1
OK

AT+HTTPPARA="URL","test.my/demo/writedata.php"
OK

AT+HTTPDATA=12,10000
DOWNLOAD
OK

AT+HTTPACTION=1
OK

AT+HTTPREAD
OK

AT+HTTPTERM
+CME ERROR: operation not allowed

AT+SAPBR=0,1
OK


texts: Arduino with DS18b20 and ENC28J60 to thingspeak

texts:
Can anyone help me to make this work? I have been trying for a couple of days to make this work, but no luck. I use a DS18b20 Temperature sensor and an ENC28J60 Ethernet module. The last code that I find like close to work is:

/*
| Post temp. values from a DS18B20 to ThingSpeak using the Ethercard interface based on the
| ENC28J60 chip.
| Based on the Ethercard example from www.jeelabs.org
| Phil Grant Jan 2014
*/
#include <EtherCard.h>
// change these settings to match your own setup
#define APIKEY  "xxxx"

//DHT Setup
//#include "DHT.h"
//#define DHTPIN 2     // what pin we're connected to
// Uncomment whatever type you're using!
//#define DHTTYPE DHT11   // DHT 11
//#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)
//DHT dht(DHTPIN, DHTTYPE);

// ethernet interface mac address, must be unique on the LAN
byte mymac[] = { 0x12,0x11,0x22,0x12,0x21,0x11 };
char website[] = "api.thingspeak.com";
byte Ethernet::buffer[700];
uint32_t timer;
Stash stash;

void setup () {
Serial.begin(57600);
//dht.begin(); //Initializate DHT
  Serial.println("\n[webClient]");
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");
  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip);
  ether.printIp("DNS: ", ether.dnsip);
  if (!ether.dnsLookup(website))
    Serial.println("DNS failed");
  ether.printIp("SRV: ", ether.hisip);
}

void loop () {
  ether.packetLoop(ether.packetReceive());
  if (millis() > timer) {
    timer = millis() + 60000; //Transmit every minute
    delay(2000);  // Wait a few seconds between measurements.
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  char h_buffer[10];
  String Hstring = dtostrf(h,0,5,h_buffer);
  //Convert Humidity value to String
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  //float f = dht.readTemperature(true);
  char t_buffer[10];
  String Tstring = dtostrf(t,0,5,t_buffer);
  //Convert Temperature value to String
  byte sd = stash.create();
  stash.print("field1=");
  stash.println(Hstring);
  stash.print("&field2=");
  stash.println(Tstring);
  stash.save();
  // generate the header with payload - note that the stash size is used,
  // and that a "stash descriptor" is passed in as argument using "$H"
  Stash::prepare(PSTR(
    "POST /update HTTP/1.1" "\r\n"
    "Host: $F" "\r\n"
    "Connection: close" "\r\n"
    "X-THINGSPEAKAPIKEY: $F" "\r\n"
    "Content-Type: application/x-www-form-urlencoded" "\r\n"
    "Content-Length: $D" "\r\n"
    "\r\n"
    "$H"),
    website, PSTR(APIKEY), stash.size(), sd);
    // send the packet - this also releases all stash buffers once done
    ether.tcpSend();
  }
}

But on the serial monitor I get this message:

[webClient]
IP:  192.168.88.252
GW:  192.168.88.1
DNS: 8.8.8.8
DNS failed
SRV: 0.0.0.0

I have try all of this network configurations and I am sure that arduino have access to internet from my home router. I can ping arduino IP address from other computers in my network and all computers have access to Internet from same router and same subnet with same DNS.
Any more ideas?


texts: Is there a Sensor capable of meausring circumference of an object that is compatible with Arduino?

texts:
I have been working on a project that requires the use of a sensor that can measure an object's circumference and then return that data. However, I do not know which sensor would be able to do what was mentioned previously and that is, at the same time, compatible with an Arduino board. On the other hand, if this sensor does exist but is not compatible with an Arduino, I would be open to using a Raspberry Pi for this project. Yet, a sensor that is compatible with an Arduino board would be prefferred.

If any one knows, thanks in advance.


texts: Teensy 3.1 no overclock option for 168 MHz

texts:
I'm sorry if this isn't the right area. Teensy uses the arduino ide.

I've seen some people show off the 144 mhz and 168 mhz option in their ide. I read in the Teensyduino 1.19 release notes that the options were added but not enabled. I would like to know how to enable it or if I somehow downloaded an older version.

P.S I get the 96 mhz option.

Thanks ahead of time!


texts: How can Arduino control with a servo with only one wire?

texts:
I was playing with getting my servos to be on dedicated power, separate form the Arduino entirely, but obviously controlled by the Arduino. I originally had the ground of the Arduino joined with the - of the battery, but to my surprise my Arduino continued to control the servos when I remove the ground wire entirely from the Arduino.

I was under the impression that all electricity must form a complete circuit, and be a closed loop. But my Arduino can obviously send a signal to a component that has no return path to itself.

I feel like I'm missing something fundamental about a electricity. So my question is:

Why does this work?


texts: Will 5V to input pin damage the Arduino board?

texts: I am fairly new to Arduino. When I am experimenting with circuits, do i need to worry about shorting out a pin if I accidentally connect the +5V pin on Arduino to an input pin on Arduino without a resistor? I just want to make sure I avoid destroying the board when learning how to create circuits.


texts:
I am having trouble getting this module to work using the tmrh20 lib. I am using these modules with two arduino mega and a 3.3V external power supply. I also placed 10 uF in parallel with the modules power pin. I would really appreciate any comments or suggustions.

In the code below all I am trying to do is turn on a led.
Here are my pin assignment for both arduinos
CE -> 7
CSN -> 8
SCK -> 52
MOSI -> 51
MISO -> 50
IRQ -> unconnected

Transmitter

//#include <DigitalIO.h>
#include <SPI.h>
#include "RF24.h"
#include <printf.h>
RF24 radio(7,8);
const uint64_t pipe = 0xE8E8F0F0E1LL;
unsigned long msg = 375983;

void setup() {
    Serial.begin(115200);
    printf_begin();
    Serial.println("Transmitter");
    pinMode(9, INPUT);
    radio.begin();
    radio.setChannel(108);
    radio.openWritingPipe(pipe);
    radio.startListening();
    radio.printDetails();
}

void loop() {
  radio.stopListening();
  if (digitalRead(9) == HIGH)
  {
    while (!radio.write(&msg, sizeof(msg))){
      radio.write(&msg, sizeof(msg));
}
  Serial.println("Sending.....");
  }
  else {
    Serial.println("Awaiting Input....");
  }
  delay(500);

}

print detail report

STATUS = 0xff RX_DR=1 TX_DS=1 MAX_RT=1 RX_P_NO=7 TX_FULL=1
RX_ADDR_P0-1 = 0xffffffffff 0xffffffffff
RX_ADDR_P2-5 = 0x7f 0xff 0x7f 0xff
TX_ADDR = 0x0000000000
RX_PW_P0-6 = 0xff 0x7f 0xff 0x7f 0xff 0xff
EN_AA = 0xff
EN_RXADDR = 0xff
RF_CH = 0xff
RF_SETUP = 0xff
CONFIG = 0xff
DYNPD/FEATURE = 0x7f 0xff
Data Rate = 1MBPS
Model = nRF24L01
CRC Length = Disabled
PA Power = PA_MAX

Receiver

//#include <DigitalIO.h>
#include <SPI.h>
#include "RF24.h"
#include <printf.h>
RF24 radio(7,8);
const uint64_t pipe = 0xE8E8F0F0E1LL;
unsigned long msg;

void setup() {
    Serial.begin(115200);
    printf_begin();
    Serial.println("Receiver");
    pinMode(9, OUTPUT);
    radio.begin();
    radio.setChannel(108);
    radio.openReadingPipe(0,pipe);
    radio.printDetails();

}

void loop() {
   radio.startListening();
   digitalWrite(9, LOW);
  if(radio.available()){
    while(radio.available())
    {
    radio.read(&msg, sizeof(msg));
    Serial.println("Incoming...");
    delay(500);
    Serial.println(msg);
    }
  }
  else{
    Serial.println("No Msg");
  }
  radio.stopListening();
  Serial.println(msg);
  if (msg == 375983){
    digitalWrite(9, HIGH);
    Serial.println(msg);
  }
  delay(500);
}

print detail report

STATUS = 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0
RX_ADDR_P0-1 = 0x0000000000 0x0000000000
RX_ADDR_P2-5 = 0x00 0x00 0x00 0x00
TX_ADDR = 0x0000000000
RX_PW_P0-6 = 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA = 0x00
EN_RXADDR = 0x00
RF_CH = 0x00
RF_SETUP = 0x00
CONFIG = 0x00
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01
CRC Length = Disabled
PA Power = PA_MIN

UPDATE:
Transmitter PrintDetail

STATUS       = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1     = 0x00000000e1 0xc2c2c2c2c2
RX_ADDR_P2-5     = 0xc3 0xc4 0xc5 0xc6
TX_ADDR      = 0x00000000e1
RX_PW_P0-6   = 0x20 0x00 0x00 0x00 0x00 0x00
EN_AA        = 0x3f
EN_RXADDR    = 0x02
RF_CH        = 0x6c
RF_SETUP     = 0x07
CONFIG       = 0x0f
DYNPD/FEATURE    = 0x00 0x00
Data Rate    = 1MBPS
Model        = nRF24L01+
CRC Length   = 16 bits
PA Power     = PA_MAX

Results form tmrh20 Getting Started Example

First Arduino

Sent 8340224, Got response 0, Round-trip delay 547172 microseconds
Now sending
Sent 9889124, Got response 0, Round-trip delay 511072 microseconds
Now sending
Sent 11401920, Got response 0, Round-trip delay 43348 microseconds
Now sending
Sent 12446992, Got response 0, Round-trip delay 635580 microseconds
Now sending
Sent 14084352, Got response 0, Round-trip delay 1620788 microseconds
Now sending
Sent 16706968, Got response 0, Round-trip delay 1227548 microseconds
Now sending
Sent 18936340, Got response 0, Round-trip delay 145372 microseconds

Second Arduino

*** PRESS 'T' to begin transmitting to the other node

The second arduino is not printing anything on the serial monitor, no matter what I enter.


texts: Sending large structs via nrf24l01 leads to cliping of some structs members

texts:
I started with building of the wireless temp/hygro/other values probes. I use 2 arduinos, both with nf24l01+ wireless transceivers, library used is rf24.h (https://github.com/maniacbug/RF24). Basically ping/pong test works for me - so each arduino communicates properly via nrf24l01+.
I added dht22 temperature sensor and just for testing I started with sending structure:

typedef struct{
  int A; // just counter to see if receiving new data
  float B; // temperature
} data;

data payload;

I send it from Arduino1 like this:

radio.write( &payload, sizeof(payload) );

Other Arduino2 receives the payload:

radio.read( &payload, sizeof(payload) );

This works perfectly and I am able to print the counter value as well as the temperature value on the oled display o Arduino2. The problem is when I add float C to the struct for sending/receiving hygrometer values. Then Arduino2 does not receive/display any valid hygro value, but there is just value of 0.00.

I think I know where my problem is - nrf24.h has possibility to set payload size for nrf24l01+ - both Arduinos have to use the same payload size (default is 16, min is 8, max is 32). I use 8 - as this looks to be the most reliable value when using larger distances between Arduinos.
When I tried to set payload size to 32 on both Arduinos:

radio.setPayloadSize(32);

Then it works and I can receive and display counter, temp, hygro values.
So it looks the nrf24l01+ sends a payload of either 8 or 32 bytes and when sending struct with INT, FLOAT, FLOAT - 8 bytes is not sufficient and 32 bytes of payload is needed. But when I will use many other values, I can reach also limit of 32 bytes payload.

I do not have much skills in C programming and also I do not fully understand how data packets are being transferred between nrf24l01+ modules- maybe I just need to adapt my send/receive code to handle sending of the larger structures. Maybe somebody could give me a hint.


texts:
I get stuck at a few points in my project that I am planning to do and even moving forward and I need your help. I would be very happy if you could help me with the sample codes, explaining it step by step and showing the source.
I have an entrance and exit door project that works with the Rfid card system. I prepared the local version of this project. In other words, I can make the cards that I write in the code I have determined open the door, so that the others cannot open the door. I can show this visually with the buzzer, lcd screen and leds. But it is very difficult and skillful to insert the card I can give to newcomers to open the door every time and to process it in the code. So I want it to read this data from a database using esp8266. For example, I want to inquire whether there is a new person in the database where I will define a new person and a card, and on the internet with arduino esp8266, but I do not know how to do it. Other than that, if the internet goes out, I want the cards inside the sd card to open the door by using the sd card and reader. If you can help me on this subject, I would be very happy.


texts:
I wanted to tinker around more with the 8-bit shift register (74HC595) so I tried to make a simple LED display and after reading about some shift commands I got lost and didn't understand much...

Let's start simple...

from what I read -- you can send out Binary data 1s and 0s --- does the shift regsiter read it as on and off? the shift register I'm using which is probably the same thing with others but it has 8 pins that can be used as output --- how does it output the data? --- does it output (example) 10100110 which shifts to the right as if 00000000 -> 10000000 -> 11000000 -> 01100000 -> 00110000 -> 10011000 -> 0100110 -> 10100110 through the pins one by one? like pin 1 would get 0 first then 0 will move to pin 2 and pin 1 will get a 1? (still using 10100110 by example above ^ )

Also what would the code look like? how does shiftOut() and shiftIn() work exactly? does all of this have something to do with pulseIn()? what do the bitwise operators like >> and << or ~ to name a few exactly do?

let's say I made 8 leds hooked up to one of each output pin of the shift-register --- how do I give data to the register? what commands should I use to give data? --- from what I understood I can output 01011011 right? if so, how does the shift-register output it? and if (Assumingly) it does output it like on and off would it eventually turn out as if LED1 = OFF LED2 = ON LED3 = OFF LED4 = ON LED5 = ON LED6 = OFF LED7 = ON LED8 = ON as if I entered in 01011011?

tl;dr

how do 8-bit shift registers work and how do you make codes work with them xP


texts:
I am new I took a code of keypad in arduino. Arduino code is not working in setup area but if I place the same code in loop are it works why? Kindly guide me.
Here is the code.

#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'0','1','2','3'},
  {'4','5','6','7'},
  {'8','9','A','B'},
  {'C','D','E','F'}
};
byte rowPins[ROWS] = {2, 3, 4,5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6, 7, 8, 9}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup(){
  Serial.begin(9600);
  char customKey = customKeypad.getKey();

  if (customKey){
    Serial.println(customKey);
  }
}

void loop(){

}


texts: Problem with incrementing values of an RGB LED

texts:
I'm trying to use a remote control to control the red/green/blue values of an RGB LED using an Arduino Uno. Here's what I've got so far:

#include <IRremote.h>
#define IRPin 7
#define bluePin 9
#define greenPin 10
#define redPin 11

int blueValue = 0;
int greenValue = 0;
int redValue = 0;

IRrecv irrecv(7);
decode_results results;

void RGBLED(int blue, int green, int red)
{
  analogWrite(redPin, red);
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue);
}

void setup(){
  irrecv.enableIRIn();
  pinMode(sensorPin, INPUT);
  Serial.begin(9600);
}

void loop(){
if (irrecv.decode(&results)){
  switch(results.value)
  {
    case 0xFF6897:
      Serial.println("Red+16");
      redValue = redValue + 16;
      if(redValue >= 256)
      {
        redValue = 255;
      }
    break;
    case 0xFF9867:
      Serial.println("Green+16");
      greenValue = greenValue + 16;
      if(greenValue >= 256)
      {
        greenValue = 255;
      }
    break;
    case 0xFFB04F:
      Serial.println("Blue+16");
      blueValue = blueValue + 16;
      if(blueValue >= 256)
      {
        blueValue = 255;
      }
    break;
    case 0xFF30CF:
      Serial.println("Red-16");
      redValue = redValue - 16;
      if(redValue < 0)
      {
        redValue = 0;
      }
    break;
    case 0xFF18E7:
      Serial.println("Green-16");
      greenValue = greenValue - 16;
      if(greenValue < 0)
      {
        greenValue = 0;
      }
    break;
    case 0xFF7A85:
      Serial.println("Blue-16");
      blueValue = blueValue - 16;
      if(blueValue < 0)
      {
        blueValue = 0;
      }
    break;
  }
irrecv.resume();
RGBLED(blueValue, greenValue, redValue);
}

Everything works fine, except the adding up to redValue. It's the same exact code that is used for greenValue and blueValue. The substraction from redValue works fine too. Everytime the problematic function gets called, the serial monitor prints Re and the whole thing just stops working.
I have tried rewriting that code from scratch, copying the other code, but nothing worked. I have switched up the codes from my IR remote but that had nothing to do with it either.
Can anyone spot the mistakes or tell me what I'm doing wrong?

Thanks in advance


texts: Solar powered ESP8266. WiFi module usage optimizations

texts:
Above all, I am quite new to the ESP8266 and micro controllers development as a whole. I am now working on a project which is quite simple for now. It basically looks like this:

As you can see, I have an ESP8266 and some input peripheral. Everything works perfectly fine for the moment, I can read the inputs from the motion sensor and 4x3 keypad. And, respectively I can output on the relay and the 5mm LED. In order to make it a real IOT, I have connected it to the internet via Thinger.IO. So, I have my ESP8266 constantly connected to this platform and I can track it anytime, from anywhere.

This is great. But, my optimal goal is to power my configuration from a solar panel and make it independent of the electricity distribution network.

The average working current of the whole system is about 313mA (10000 mAh battery gets completely drained for 32 hours. Its output is 5V, 2.1A).

So, I am now in a search of the best solar panel to fit my needs. An ultimate one would have the following maximal dimensions: 30x35 cm. I am not sure there's a single panel that I can use but I am interested to hear your opinion in this.

Another aspect, that I'd like to optimize is the constant internet connectivity. Basically, I need to have my configuration connected to the internet only when keypad input was made or motion sensor detected something. During the rest of the time, I don't need to be connected to the internet and I assume WiFi module could be suspended somehow. Currently, my code uses SmartConfig and is looks like this:

#include <ESP8266WIFI.h>

void connectToWifi() {
  WiFi.mode(WIFI_STA);
  WiFi.beginSmartConfig();

  while(!WiFi.smartConfigDone()){
    delay(500);
  }
}

void setup() {
  connectToWifi();

}

void loop() {

}

Everything works well. But, as I said, I'd like to be able to start/stop the WiFi module. I tried using the following API:

void toggleWifi(bool isWakeUpCall) {
  if(isWakeUpCall)
    WiFi.forceSleepWake();
  else
    WiFi.forceSleepBegin(30000000);

  delay(500);
}

but without much of a success. Once it gets into this portion of code, it gets completely disconnected and doesn't get connected anymore. I am now struggling with it.

I've read about the sleep modes offered by the ESP8266 but I don't think they are suitable for my case because I can not simulate external interrupt (or maybe I can?).

I am really curious to hear your opinion on this. :)


texts: what the benefit uploading hex file merely to arduino board?

texts: What the benefit of uploading merely hex file to avr based board like arduino uno Since the arduino ide it self will send intel hex file to the board after compile .ino file to hex file by the avrdude compiler (https://github.com/arduino/Arduino/wiki/Build-Process)?


texts: Trouble understanding connection diagram

texts:
The image shows a way of connecting an optocoupler.
My problem comes from how the emitter (Q1 in the image) is connected. The emmiter goes to a resistance going to ground and to v_out. When i try to add this to my circuit the pin that is suppost to be receiving data, the v_out pin goes silent. If i remove the resistance going from the emitter to ground and just have vout to the emitter everything works fine.


texts:
I need four Fast PWM signals for four different transistors.

I want to use timers 1+2 (pins 3, 11, 9, 10) so it wouldn't interfere with delay(...).

I tried setting the timers to Fast PWM mode, and applied different OCRnA/OCRnB values, but nothing really worked - at most, I managed to get two good PWM signals, one from each timer.

How should I deal with TCCRnA/TCCRnB, OCRnA/OCRnB to achieve 4 parallel PWM signals?

My latest attempt:

// Timer 1 Fast PWM setup: TOP=0x00FF, Update of OCRx at BOTTOM (0), TOV Flag Set on TOP
pinMode(9, OUTPUT); pinMode(10, OUTPUT);
TCCR1A = _BV(COM1A1) | _BV(COM1B1) | _BV(WGM10);
TCCR1B = _BV(WGM12) | _BV(CS11) | _BV(CS10); // Divisor 64
// Timer 2 Fast PWM setup: TOP=0xFF, Update of OCRx at BOTTOM (0), TOV Flag Set on MAX (0xFF)
pinMode(3, OUTPUT); pinMode(11, OUTPUT);
TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
TCCR2B = _BV(CS22); // Divisor 64
// ...
int val = 200; // Desired PWM output
OCR1A = val;
OCR1B = val;
OCR2A = val;
OCR2B = val;


texts:
I have a Funduino Joystick Shield (See here Funduino on Gearbeast store) which has some Bluetooth pins.

Does anyone know what pins they are connected to, and has anyone successfully connected to a BT HC-05 device using SoftwareSerial?


texts: Uploading/Flashing different programs to two different Arduino uCs, using one USB

texts:
I'm designing a custom dual-uC board, where I want there to be two Arduinos both running different programs - kind of dual core arduino. In order to load new programs onto the uCs, yes, I could have two USB ports each connected to one of the uCs (say a ATmega32u4). But I'm trying to work out strategies with just one USB port (and no usb-hub).

Also, I don't need the USB functionality for general use, only for program updates.

Option 1:

Switch access to each USB capable Arduino (e.g. ATmega32U). Program one uC, toggle switch, program other uC

EDIT: this is fine, however I ideally want to use zero additional end-user buttons - I want the end-user to do as little as possible.

Option 2:

The arduino UNO has two devices, ATmega16U2 and a ATmega328. During normal operation the 16U operates as a usb-to-serial. However, I'm aware that there are custom firmwares that allow different functionality (such as USB-Joystick etc) - it is possible to switch firmawares between a custom-firmware and default firmware, to allow the ATmega328 to be programmed normally but also to run the custom program. But it seems that Arduino.h doesn't support the ATmega16U2, so I would have to program this device using the AVR or another framework.

Alternatively, the ATmega32U4 is supported by Arduino.h but there doesn't seem to be Arduino usb-serial 'firmware' for the 32U (only the 8U & 16U)

Option 3:

Can I use a ATmega32u4 with Arduino-ISP programming an ATmega328p?

EDIT: above seems valid:
https://petervanhoyweghen.wordpress.com/2012/09/16/arduinoisp-on-the-leonardo/

Other simple recommended approaches?

EDIT: the firmware update should be physically as hands off as possible, as to be used by end-user, and preference for solutions that require zero additional buttons/etc

UPDATE:

I tried the Arduino as ISP method (option 3), and it works


texts: Reading and Writing RS232 in Digtial Pins 3 and 4

texts:
I have an arduino that is connected to a sensor with tx on pin 3 and rx on pin 4. I wrote some code to write a message to the sensor that consists of 4 bytes

 byte code[] = {0x31,0x05,0x06,0xFF};

The response should be an 8 byte response with this format

However Im not able to see anythin at the serial monitor on the arduino IDE.

Here is the code Im using:

#include <SoftwareSerial.h>

int rx_gas = 3;
int tx_gas = 4;
int code = 6;
// the setup routine runs once when you press reset:
// software serial #1: RX = digital pin 10, TX = digital pin 11
SoftwareSerial gasMeterPort(rx_gas, tx_gas);
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(115200);
  gasMeterPort.begin(115200);
}

String readString;

void loop() {

  gasMeterPort.listen();
  Serial.println("Data From Gas Meter Port:");
  byte code[] = {0x31,0x05,0x06,0xFF};
  Serial.write(code,4);
  // While there is data coming to the gas port, read it
  while(gasMeterPort.available() > 0){
    Serial.println("in while");
    char incoming_byte = gasMeterPort.read();
  }
  delay(1000);        // delay in between reads for stability
}


texts: Running a servo and tone() won't compile? "multiple definition of `__vector_32'"?

texts:
Im using Spark fun pro micro:https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/hardware-overview-pro-micro

I am controlling a servo motor which reads its data from a pot connected to A0, and then writes to the servo on D9.

A speaker is connected to A5. Im using tone()

If I comment out the servo part of it, the tone() works out just fine and vise versa..
The error message I get is "multiple definition of `__vector_32'"

Got a clue??!
Thanks!


texts:
I have arduino , upon arduino I have Arduino GSM shield (Tx-2, Rx-3, Modem reset-7) and upon it, I have the Adafruit GPS Logger shield. I am trying to send sms of Latitude  from the GPS Logger shield to my numer through GSM shield. I am getting a error ..

SoftwareSerial/SoftwareSerial.cpp.o: In function `SoftwareSerial::SoftwareSerial(unsigned char, unsigned char, bool)':
/home/thiyagu/Downloads/arduino/arduino-1.0.5/libraries/SoftwareSerial/SoftwareSerial.cpp:335: multiple definition of `__vector_3'

GSM/GSM3SoftSerial.cpp.o:/home/thiyagu/Downloads/arduino/arduino-1.0.5/libraries/GSM/GSM3SoftSerial.cpp:148: first defined here
SoftwareSerial/SoftwareSerial.cpp.o: In function `SoftwareSerial::SoftwareSerial(unsigned char, unsigned char, bool)':
/home/thiyagu/Downloads/arduino/arduino-1.0.5/libraries/SoftwareSerial/SoftwareSerial.cpp:335: multiple definition of `__vector_4'

GSM/GSM3SoftSerial.cpp.o:/home/thiyagu/Downloads/arduino/arduino-1.0.5/libraries/GSM/GSM3SoftSerial.cpp:148: first defined here
SoftwareSerial/SoftwareSerial.cpp.o: In function `SoftwareSerial::SoftwareSerial(unsigned char, unsigned char, bool)':
/home/thiyagu/Downloads/arduino/arduino-1.0.5/libraries/SoftwareSerial/SoftwareSerial.cpp:335: multiple definition of `__vector_5'

GSM/GSM3SoftSerial.cpp.o:/home/thiyagu/Downloads/arduino/arduino-1.0.5/libraries/GSM/GSM3SoftSerial.cpp:148: first defined here

What is the meaning of this error ? what should I do to solve it?


texts: How do I measure the analog PPG signals from my Arduino Nano that's wired up to the Heart Rate 3 Clicker

texts:
I'm trying to find a code that would take the PPG signals from the MIKROE-2036 Heart Rate 3 Clicker and process the information through the Arduino Nano to find a person's Oxygen Saturation. Basically, by using this code how do I measure Oxygen Saturation from the given analog inputs from the LEDs?
This is the test code that the Arduino Nano could use, but it's more of a template:
/*
 * AFE4404 Basic Read library example.
 * https://github.com/rakshithbk/AFE4404-Library
 *
 * On Arduino Uno -  | AFE4404 | Uno Pin
 *                   | I2C_Dat | A4
 *                   | I2C_Clk | A5
 * get_led_val() will return uint32_t values.
 *
 * Advanced - you can modify the sample period and other
 * parameters in the library files (refer AFE4404 datasheet)
 */

#include <Wire.h>
#include <AFE_connect.h>

AFE A;

void setup() {
  Serial.begin(115200);
  Serial.println("AFE4404 basic readings -\n");
  A.init();
}

void loop() {
  Serial.print("LED 1 Val = ");
  Serial.print(A.get_led1_val());
  Serial.print("\t LED 2 Val = ");
  Serial.print(A.get_led2_val());
  Serial.print("\t LED 3 Val = ");
  Serial.print(A.get_led3_val());
  Serial.println();
}

This is the library I found that uses the Heart Rate 3 Clickers LEDs: https://github.com/rakshithbk/AFE4404-Library


texts: Arduino - "expected primary-expression before '.' token" Error

texts:
#include "Ultrasonic.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  // put your setup code here, to run once:
  lcd.begin();
  Serial.begin(9600);
}
Ultrasonic ultrasonic(11, 12); //Ultrasonic ultrasonic(Trig,Echo);
void loop()
{
  int a = (Ultrasonic.Ranging(CM));
  if (a >= 15 && a < 20)
  { Serial.println("guvenli");
    lcd.print("guvenli");
    delay(500);
    lcd.clear();
    tone(3, 2000, 100);
    delay(500);
    noTone(3);
  }
  if (a >= 10 && a < 15) {
    Serial.println("guvenli dikkat");
    lcd.print("guvenli dikkat");
    delay(500);
    lcd.clear();
    tone(3, 2000, 50);
    delay(250);
    noTone(3);
  }
  if (a < 5)
  {
    Serial.println("vurdun");
    lcd.print("vurdun");
    delay(500);
    lcd.clear();**uıhhf
    tone(3, 2000, 50);
    delay(50);
    noTone(3);
  }
}

In this code i'm getting an error like this:

   C:\Users\*\AppData\Local\Temp\arduino_modified_sketch_113625\sketch_apr29a.ino: In function 'void loop()':

sketch_apr29a:19:22: error: expected primary-expression before '.' token

   int a = (Ultrasonic.Ranging(CM));

                      ^

exit status 1
expected primary-expression before '.' token


texts: Any help is greatly appreciated! Trying to build a small door lock that is controlled by a finger print sensor, (I know it will not be very practical). My issue is with putting the hardware together, I have the sensor connected to the Arduno uno with the green and yellow to pins 2 and 3 respectively, then the red and black to the ground and 5V rail. My issue is not knowing how to go about connecting the adafruit chip to the breadboard as I am going to try to use wifi for this project. Secondly I noticed most people use the adafruit Fingerprint sensor which has the module and mine is just a cheap sensor from amazon and was wondering if it will still be able to work the same? Sorry for all the questions I am very new to this and I apologize for sounding so lost haha, anything helps.


texts: What's the smallest (cheap) USB Host solution for Arduino?

texts:
I'm building a project that will connect to users' phones (Android at first, but iPhone too, if there's enough interest) via USB. Of course, this means that I need a USB host in the project. The total size of the device has to be about the size of the phone, so answers that seriously suggest shields aren't going to be helpful - they'd put me over my size budget by at least a factor of 3.

I'd also rather not require an adapter to go from the USB Mini B connector type to the Micro B connector type.

Gravitech has a USB Host board for the Nano 3 that has a USB Type A connector, and the combination of a Nano and Gravitech Host is about the right size (maybe a little thick, once the whole thing is soldered to my own board), but the USB host is $25. I can get the Nano for about $4 each and would like to keep the USB host in the neighborhood of $8 each. Are the solder fumes getting to me, or is there such a specimen out there and I'm just not finding it?


texts:
I'm getting a bit tripped up on const char pointers lately.
I'm getting a message from a server that comes through as either a c style string, a standard library string, or a WString:

I'm sending down a buffer of 32bit values from my server that aren't ascii or utf text, they're just bit values I want to parse and read on the esp32 side:

I thought "oh, I'll just mask the bit values 32 bits at a time and right shift the data to get the message (in reverse order, but still I can work with that). The problem that I'm running into is that I can shift numbers but not strings or byte arrays.
I wrote out a function to allow me to grab a piece of the string 32 bits at a time and convert that into a number while using an offset:
uint_fast32_t get32BitInt(const char *data, int offset = 0)
{

  uint32_t payload = 0;
  for (uint8_t i = 0; i < 8; i++)
  {
    payload <<= 0;
    payload += data[i + offset];
  }
  return payload;
}

But when I try to grab the first couple of 32 bit chunks the data isn't what I expected:
void handleGameFrame(const char *data, uint32_t length)
{

  uint8_t phaseAndColission = get32BitInt(data, 32);
  uint8_t player = getByte(data, 32 * 2);

  Serial.print("data: ");
  Serial.println(data);
  Serial.print("phaseAndColission: ");
  Serial.println(phaseAndColission, DEC);
  Serial.print("player: ");
  Serial.println(player, DEC);

}

yields:

I know the Serial.println(data); isn't going to output anything b/c it's a c-string of non-printable values, but the other chunk grabbing isn't giving me the same output from my server. It's hard to verify everything without being able to see all of the bits in the overall data pointer and I think I tied myself in (another) knot.
Is there a good way to parse 32 bit values out of a const c-string?


texts: UART Software Serial - Syncing two different sensors with start and stop bytes

texts:
I'm using 2 SRF02 sensors on the same Arduino board to attempt to have the transmitter only pulse the 40 KHz wave, while the receiver will be only taking a fake range, i.e. picking up a reading based on another transmission.

I've been using SoftwareSerial and need to know how to synchronize the time for the receiver to know when the transmitter sent the data. What I found is that I'm going to have to do this using start and stop bytes to set them in the same cycle.

How can I do this?

This is my current code:

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10,11); // RX, TX

void SendCmd(unsigned char address,unsigned char cmd) {
  mySerial.write(address);
  //set the address of SRF02(factory default is 0)
  delayMicroseconds(100);
  //serial data is fixed at 9600,N,8,2,so we need some time to create the second stop bit
  mySerial.write(cmd);
  //send the command to SRF02
  delayMicroseconds(100);
  //serial data is fixed at 9600,N,8,2,so we need some time to create the second stop bit
}
void setup(void) {
  Serial.begin(9600);
  mySerial.begin(9600);
  Serial.println("SRF02 TEST!");
}

void loop(void) {
  unsigned int reading;
  SendCmd(0x00,0x5C);
  //Transmit 8 cycle 40khz pulse from address 0x00 - transmitter
  delay(70);
  //time for SRF02 to measure the range
  SendCmd(0x02,0x57);
  //Get Fake Range at Address 0x02 - receiver
  delay(10);
  //wait for some time,let the Arduino receive 2 bytes data from the TX pin of SRF02
  if(mySerial.available()>=2) {
    //if two bytes were received
    reading = mySerial.read()<<8;
    //receive high byte (overwrites previous reading) and shift high byte to be high 8 bits
    reading |= mySerial.read();
    // receive low byte as lower 8 bits
    Serial.print(reading);
    // print the reading
    Serial.println("cm");
    //Serial.println("Time Sent: ");
    //Serial.print(T_sent);
  }
  delay(250);
  // wait a bit since people have to read the output :)
}


texts: Storing latitude and longitude floats as chars with specified precision

texts:
I am receiving lat and long data from a GPS and want to store these numbers in the middle of a sequence of chars.

E.g. lat = -23.123456

long = 135.123456

I am after something like "Your coordinates are -23.123456,135.123456" as an array of chars.

I have tried:

float latitude = -23.123456;
float longitude = 135.123456;

String one = "Your coordinates are ";
String two = ","
String message = one + latitude + two + longitude;

// Convert String to char array
int str_len = message.length() + 1;
char textmessage[str_len];
message.toCharArray(textmessage,str_len);

Serial.println(textmessage);

but the result is: Your coordinates are -023.12,0135.12

How can I correct this?

Thanks in advance!


texts: Store & retrieve parameters after sketch update

texts:
I have a Generic code for some IOT devices which vary in some parameters ( lets say it is only its MQTT name and subscriptions).
Since I use OTA to update sketch, I'm looking for a way to A) write those parameters into the ESP32/ ESP8266 FS, and B) They will survive an update.
My only solution come into mind is using an SD card which does not get erased after OTA, and I'm looking for a way doing it not involving SD or external memory.
Guy


texts:
Here is my code. The incoming string is "*CRB12344,Temp25,Humidity55,CC5#"

I am unable to get value of Temp which is 25 and Humidity which is 55 and CC which 5. It only display the value of CR i.e B12344 (in this case). May be issue with strtok function?

String inputString = "";
boolean stringComplete = false, StartCapturing = false;

char inData[50];
char inChar, IncomingWeight;
char IncomingString[50];
const int httpPort = 80;

char *i, *k,*p;
String CardID;
int Temprature, Humidity, TC, CC;
byte SendData = 0;

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

void loop()
{
  serialEvent();

  if (stringComplete)
  {
    inputString.toCharArray(IncomingString, 50);
    Serial.println();
    Serial.println(IncomingString);

    i = strstr(IncomingString, "CR");
    {
      if (i)
      {
        p = i+2;
        CardID = strtok(p, ",");

        Serial.print("Card Number :");
        Serial.print(CardID);
        Serial.println();
      }
    }

    i = strstr(IncomingString, "Temp");
    {
      if (i)
      {
        Temprature = strtoul(i + 4 , NULL, 10);
        Serial.print("Temprature :");
        Serial.print(Temprature);
        Serial.println();
      }
    }

    i = strstr(IncomingString, "Humidity");
    {
      if (i)
      {
        Humidity = strtoul(i + 8 , NULL, 10);
        Serial.print("Humidity :");
        Serial.print(Humidity);
        Serial.println();
      }
    }

    i = strstr(IncomingString, "TC");
    {
      if (i)
      {
        TC = strtoul(i + 2 , NULL, 10);
        Serial.print("Total Count :");
        Serial.print(TC);
        Serial.println();
      }
    }

    i = strstr(IncomingString, "CC");
    {
      if (i)
      {
        CC = strtoul(i + 2 , NULL, 10);
        Serial.print("Current Count :");
        Serial.print(CC);
        Serial.println();

      }
    }

    stringComplete = false;
    inputString = "";
    delay(10);
  }


texts: Using an Arduino for a Diorama Controller

texts:
Kind of new to the whole DIY electronics scene.

I'm building a diorama for my son.  It will include a length of track, a station, some other buildings, and scenery.  It will be HO scale.  The buildings came with these cool little LED lights and I've bought additional ones as well.  I want it to be of the period of the late 1800s to early 1900s.  So the additional LEDs I bought give off a more "yellow" light to simulate candle/lantern light.  The track is not a circuit and is not powered.  It is just "static" to sit a train so it appears to be at the station.

I have the following questions:

Could I hook up the LEDs to a Arduino and have the different buildings (or floors within a building) be controlled separately?
Could I make the LEDs "flicker" to simulate candle/lantern light?
Could I maybe hook up a little speaker inside the train station to give off train noises, whistles, conductor calls, etc?
Could this setup (Arduino with LEDs/speaker) be run off of batter power (not a custom battery, just off the shelf AAs, AAAs, or Cs, etc.)?
Is an Arduino instead the appropriate controller for this kind of project?

I think this is a great opportunity to teach my kids not only modeling but also electronics (myself as well on the electronics).

Thanks in advance for any help/suggestions.

EDIT:

A little more about the setup.  The LEDs are made specifically for this type of application (model buildings/railroads).  Hence, they already have an 1800 ohm resistor attached to the input side of the LED.  There will indeed be multiple LEDs per building (even per floor).  I would like to at least isolate the circuits by building and even better if I could isolate them by floor.  I think it would be cool to have the software cycle the buildings/floors on and off at different times.

A smaller form factor for the Arduino would be ideal as it will have to fit into one of the scale buildings.  I've never really worked with the Arduino so I don't know all my options.  I've done a little with the Raspberry Pi and originally posted this question there and was told the Raspberry Pi would be overkill for this type of application.


texts:
I am trying to make a project where each item in a rack has its fixed spot. When picked/misplaced from this spot a LED will glow indicating the item is missing from its place also time of pickup, item name and time of re-keeping are to be recorded.
The best possible hardware I can think of is Arduino UNO and RFID tagging each item and placing a RFID MFRC522 Scanner on each item's place but I'm not being able to scale it.
I mean I can't use many scanners.
I need your help regarding this project about how to use multiple RFID scanners and glowing an LED for each item picked(separate light for all items).
By items I mean -

Files/Folders
Cylindrical chemical bottles(like in a chemistry lab)
Books


texts: SIM900 GRPS Shield Power down over issue AT+CIICR cmd(Bring Wireless Coms)

texts:
I'm trying to get the TinySine SIM900 GPRS Shield working to get data over the GPRS network, using Arduino MEGA.

I'm Able to register my SIM with this Shield and even , but as soon as I sent the command AT+CIICR to Bring up the Wireless Coms, the Shiled powers down, all LEDs are OFF except the Red one.

What is the source of the Problem?

Thanks


texts: Is it possible to move a servo without knowing it's current position?

texts:
My Servo has already been built into my project, and I can't remove it without damaging many other things. During the process of inserting it, it was turned by hand. So I don't know at what position it is in. It turns a potentiometer that doesn't rotate fully. So I'm worried that if I just set a degree it could turn too far and damage the potentiometer or the servo.

What should I do to find the current position? Is it even possible?


texts:
I'm working on a very big project and want to upload this to GitHub for people to use (flight controller software) and I'm using libraries from other people to make the process in the beginning easier and faster, but I'm modifying them sometimes to improve performance and plan on replacing some of them by ones I will work on in the future.
Now I'm getting kinda worried about the legality or what I need to do in order to use other peoples work and all the different licences for GitHub and also where and what comments need to be in what files.
Can someone recommend a good ressource in this subject?
I want to respect other people's work, give credit where it's do and save myself legally. What do I need to do?
Thanks in advance!


texts: What is the best way to configure a bidirectional, open collector data pin?

texts:
I want to communicate with an old keyboard asynchronously through a single open collector, bidirectional data pin. As part of the protocol, the timing will be controlled entirely by pulse width.

I've seen some code examples where the pin is switched from input to output depending on the direction. Without knowing the particular low-level MCU details, however, the approach seems a bit naive. There may be hidden penalties in switching and or calling a function.

Could I share the data line between two pins and set one pin as input and the other as output? Could this work? Are there better methods?


texts:
Alright. This is what I wanted to do:

Make a circuit and code the arduino such that there are 2 tactile switches, each with a predefined pwm value.
 Whenever any one button is pressed the led should run at that pwm value, until the button is released. There is
 also an ultrasonic sensor on the same arduino that triggers an interrupt at a threshold distance that
 stops the led. When no button is pressed or the ultrasonic isnt active, the led should run at another pwm value.

Here is the code:(updated)

const int trig = 9;
const int echo = 10;
const int redswitch = 2;
const int yellowswitch = 3;
int redled = 6;
int greenled = 5;
volatile int pwm = 50;

volatile bool rs = LOW;      //RS - RED SWITCH
volatile bool ys = LOW;      //YS - YELLOWSWITCH
bool last_rs = LOW;
bool last_ys =  LOW;
volatile long distance=0;
long duration=0;
long temp=0;

void setup(){
  pinMode(trig,OUTPUT);
  pinMode(echo,INPUT);
  pinMode(redled,OUTPUT);
  pinMode(greenled,OUTPUT);
  pinMode(redswitch,INPUT);
  pinMode(yellowswitch,INPUT);
  Serial.begin(9600);

  attachInterrupt(digitalPinToInterrupt(redswitch), red,CHANGE);
  attachInterrupt(digitalPinToInterrupt(yellowswitch), green,CHANGE);

  digitalWrite(greenled,LOW);
  digitalWrite(redled,LOW);
}

boolean debounce(boolean temp,int switchPin)
{
  boolean current = digitalRead(switchPin);
  if (temp != current)
  {
    delay(5);
    current = digitalRead(switchPin);
  }
  return current;
}

void loop(){

  //Ultrasonic sensor's distance calculation
  digitalWrite(trig,LOW);
  delayMicroseconds(5);

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

  duration = pulseIn(echo, HIGH);
  temp = duration * 0.0343 / 2;
  noInterrupts();
  distance = temp;
  rs = debounce(last_rs,redswitch);
  ys = debounce(last_ys,yellowswitch);
  last_rs = rs;
  last_ys = ys;
  if(distance>8)interrupts();

  Serial.println(distance);
  analogWrite(redled,pwm);
  analogWrite(greenled,pwm);
}

void red(){

  if(rs == HIGH) pwm = 150;
  else pwm = 0;

}

void green(){

  if(ys == HIGH) pwm = 250;
  else pwm = 0;

}

Now, when the arduino is connected to my laptop, led runs at the a particular value. But whenever I press a button they go off. Can you help me find out what's wrong here?


texts: Programing other Atmel ARM chips using Arduino

texts:
Ok, i know professionals generally hate Arduinos, but I would like to know if it would be possible to program Atmel ARM chips using the Arduino IDE. By which I mean, not needing to modify the source code, just add another entry into the "hardware" folder and that's it.

We already know the Atmel ATSAM3X8EA (Arduino DUE) is compattible, but how about a similar chip, like the Atmel ATSAM3X8CA. Or maybe a Cortex-M4 one, like the Atmel ATSAM4E16EA or the Atmel ATSAM4S8CA.

The Atmel ATSAM3X8CA is the closest one to the Atmel ATSAM3X8EA the Arduino Due uses, a bit smaller and with less I/O.

If it isn't possible without much source code modding, I would like to know what would it take to make it work.

Thanks for your answers.


texts: Is it ok to power a Wemos D1 R2 placed outside with a smartphone charger?

texts:
I'm currently playing with a wemos D1 R2 for some simple temperature / humidity logging on my balcony. For the moment the board is powered via its micro-USB entry by a small smartphone charger.

I've got two questions about this :

is there any "risk" (fire, explosion...) to let such a charger outside and plugged in continuously ?
will the charger use exactly the amount of current used by the board, or will it consume more energy than needed ?

Sorry, I realize these are really basic questions. Thanks in advance for any hint.


texts:
I'm using a SIM800L module, and I am checking the status of my network with the AT+CREG? command.

However, it always returns the same 0,2:

0 -> disable network registration unsolicited result code

2 -> not registered, but ME is currently searching a new operator to register to

How do I activate 2G or 3G network?


texts:
im new to arduino and thinking to create a LED project.

im creating a LED project and i want to control 12 LED's. so i use two 7HC595 but problem i face is how can i only control 12 outputs ?

and i want to create multiple blink patterns with 12 LED, please be kind enough to provide blink patterns that i can modify and create different partners.

i have found many shift-out programs but i do not understand how to limit it to 12 outputs and create multiple blink patterns.

thanks


texts: Can an ATtiny print results to a console?

texts:
I'm trying to port some Arduino code that I wrote for the Arduino Mega to an ATtiny and I'm having trouble figuring out how to do output. Here is what I have:

char foo;
#include <SoftwareSerial.h>
const int rx=3;
const int tx=4;

SoftwareSerial mySerial(rx,tx);

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

void loop() {
 if (mySerial.available()) {
   char data = mySerial.read();
   mySerial.write(data);
 }

 mySerial.println("hello");
}

To my understanding this should print "hello" to the console over and over again but for some reason it uploads successfully but then it doesn't do anything.

Here is the programmer that I am using to connect my ATtiny to my computer: https://learn.sparkfun.com/tutorials/tiny-avr-programmer-hookup-guide/programming-in-arduino


texts:
I'm trying to read a string like this one:

2;12;42;43;34

over a serial connection and split this string afterwards by a ";".
So the output would be this array:

(2,12,42,34)

All the stuff runs on an arduino uno. So I made some code:

String read_input;
char read_input_char[20];
char *read_values;

void setup() {

  Serial.begin(9600);
  Serial.setTimeout(10);

}

void loop() {
  if(Serial.available()){
    read_input = Serial.readString();
    read_input.toCharArray(read_input_char, 20);

    read_values = strtok(read_input_char, ";");
    Serial.println(read_values[2]);
  }
}

However now instead of outputting the 3rd array element it outputs only an '1'. What's wrong?


texts: ATMega328P not running sketch in standalone (works in Uno R3 Board though)

texts:
I bought an ATMega328P-PU and burned OptiBoot onto it using a second Arduino Uno R3 with great success.

I then put the microcontroller back on the (empty) Uno R3 (DIP) Board for programming, connected USB and uploaded the blink sketch successfully.

Now to the weird stuff:

Blink works on the Arduino Board itself, but if I pull it out and stick it into my breadboard, the program seems to not start. Here are some facts:

happens with or without external crystal 16.000 (Pin 9-10)
happens with or without the 22pF capacitors from crystal to GND (9-GND, 10-GND)
happens with Fuses set to internal OSC or to external clock (Uno default)
happens with or without the ADC VCC (Pin 20) and REFERENCE (Pin 21) Pins @ 5V
happens on 5V and on 3V3
happens with or without external Pullup on RESET Pin (1)
Most of the output Pins sit at 0.8 V


texts: Is there a working combination of Arduino IDE + Ardublock?

texts:
I'm trying to set up Ardublock, but the last release they have is from 2014 and in a recent Arduino IDE it fails when I try to upload the program to the Arduino board:
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: processing.app.Editor.setText(Ljava/lang/String;)V
    at com.ardublock.ArduBlockTool.didGenerate(ArduBlockTool.java:72)
   ....

I assume there is a different API in the recent Arduio IDE for copying the generated code into the editor. This is the block diagram I'm trying to upload. As you can see there are no libraries involved:

Is there a known combination of Arduino IDE and Ardublock which works? Or perhaps an addon similar to Ardublock which is maintained?


texts:
I suspect this is a very Naive question.
But the answer will teach me a lot.

Why does this circuit work when I connect the Digital Input (Digial Pin 2) to Pin 4 of the push button. But does not when I connect the push button to Pin 3. I missing something about how power flows when the button is pushed.

Ray K


texts: What happens if I connect an external power supply, plus to GND and minus to VIN?

texts:
So far, I have connected plus to VIN and minus to GND, but I am curious what would happen if I do it the other way around. And I am not going to try in case I break someting.

So, what will happen?


texts:
I'm using arduino for the first time and don't really understand what am I suppose to plug to the ADC refernce PIN... or if I even have to use it while plugging analog sensor to the arduino,
thanks!


texts:
I'm new to the operation and applications of the arduino and have a question. I would like to run 6 x 4 bit seven segment displays from an arduino controller. How do I connect an external supply to the displays to ensure I don't overload the arduino please?

Regards


texts: Capturing interrupt on both edges when it's set on RISING or FALLING

texts:
I've been trying to capture rising edge of an IR sensor output. This sensor's Vcc connected to Arduino 5V and it has a digital output pin. I've observed the digital output pin on an Oscilloscope. It's not noisy.

When I attach a rising edge interrupt on digital pin 2. It somehow captures both rising and falling edges. This response is the same for when it's set for FALLING or CHANGE.

I've tried code at below both on Arduino Uno and

volatile bool caughtAnInterrupt = false;

void setup() {

  Serial.begin (19200);

  pinMode(2, INPUT);

  attachInterrupt(digitalPinToInterrupt(2), test, RISING);
}

void loop() {

  if (caughtAnInterrupt){

    Serial.println("Rising edge detected");

    caughtAnInterrupt = false;
  }
}

void test() {

  caughtAnInterrupt = true;
}


texts:
I have a WS2812b addressable RGB led ribbon that is 5m (150 RGB leds). I purchased a 5v 10amp power supply to power it; however, whenever I try to use it to power the LED strip the leds start flashing colors like crazy. Is there a reason I would be seeing this behavior or is this a sign of a bad power supply?
The setup is very simple, the data line is coming from an Arduino Uno, the voltage and ground are from the power supply. The program is just one of the sample ones with FastLED library and works "fine" when just powered by the arudino's 5V pin.
Thank you


texts: Cannot connect device with nRF8001 Bluetooth LE to Windows 10 PC

texts:
I've built a device using an IMUduino board, which is supposed to be similar to Arduino Leonardo board with a nRF8001 bluetooth. I was able to connect my device to an Android phone using the nRF UART v2.0 app, I tested some examples and it worked with success.

I would like to connect the device to a Windows 10 PC via bluetooth. I have installed the driver of the nRF8001, and I am able to pair both PC-UART. However, when I open the Master control Panel, I cannot find any Master emulator, the menu is empty. Master control panel version is 3.10.0.14.

Is there any way to connect a device with nRF8001 to a Windows 10 PC?

Thanks.


texts: UNO Timer 1 CTC mode not resetting TCNT1

texts:
I'm trying to set up timer 1 to run an isr in CTC mode. no matter what i set OCR1A to it always executes at the same frequency and if i print out TCNT1 I get values higher than OCR1A.

here is my Code

    void timer1_init()
    {
    // set up timer with prescaler = 8 and CTC mode
    TCCR1B |= (1 << WGM12)|(0 << CS12)|(1 << CS11)|(0 << CS10);

    // initialize counter
    TCNT1 = 0;

    // initialize compare value
    OCR1A = 100;

    // enable compare interrupt
    TIMSK1 |= (1 << OCIE1A);

      // enable global interrupts
        sei();
    }

ISR(TIMER1_COMPA_vect){
    SET(MOTOR_PORT,LEFT_MOTOR_STEP); //set the pin high
    delayMicroseconds(3); //keep high for a bit
    CLR(MOTOR_PORT,LEFT_MOTOR_STEP); //set it low
}

I'm using this to drive a stepper motor so using PWM mode wont work.


texts: Error while uploading code to ESP8266 through Arduino Mega 2560

texts:
I am sorry for posting this question for the nth time but I am still not able to find a solution for this error.

I am trying to upload the WiFiScan(Arduino IDE example program)program code to ESP8266 using Arduino Mega 2560. I followed the procedure given here. And I tried uploading it with "Generic ESP8266 Module" and "Adafruit HUZZAH ESP8266" selected as the Board. But I am still getting the following error.

trying to connect
  espcomm_send_command: sending command header
  espcomm_send_command: sending command payload
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed

Edited to add:

Connections-

ESP8266 - Arduino Mega2560

Tx - Tx1(Pin 18)

Rx - Rx1(Pin 19)

Gnd - Gnd

Vcc - 3.3V (Directly from Arduino's 3.3V pin)

CH_PD - 3.3V (Directly from Arduino's 3.3V pin)

GPIO0 - Push button K2 (refer photo)

RST - Push button K1

While pressing the K2 button(Flash button - GPIO0), I clicked the K1 button(Reset button - RST) and then released K2. According to the document, this should bring the ESP8266 to flash mode. Now when I upload the code, it throws the above error.


texts: How to connect an Arduino to WIFI using an ESP8266

texts:
Hi I am trying to make Arduino Uno on local network with the help of ESP8266 wifi module.

I tried to search on internet, found mostly they are making ESP8266 as web server.http://circuits4you.com/2016/12/16/esp8266-web-server-html/

Can anyone help me how to add Arduino Uno on network with the help of ESP8266.


texts:
It's been done, but the the tutorials I find seems incomplete. What I'm trying to do is make the ATTiny84 talk to the 2.4 GHz NRF24L01+ radio. I understand that in order to do that I need the MCU to talk to the radio by serial. Attiny84 (and 85) does not have serial, hardware any ways.

But as I understand it you can do software serial by USI, but in order to do so the core for the board has to have this modification?

I've searched far and wide. I bump into the cores on Google Code (https://code.google.com/archive/p/arduino-tiny/downloads). I've installed them but SPI is not listed in the list of libraries.
I've got another tinycore (from where I dont know), when I use this one SPI is a library I can reference, but compiling causes

error: 'SPIE' was not declared in this scope

So, could anyone point me to a known good source of cores to Attiny85 and 84 so I can enable SPI?


texts:
I'm using a Texas Instruments DRV2605 haptic controller in my project to drive a LRA vibration motor. I would like to calculate the LRA rated voltage during run time using the formula below as provided in the datasheet:

I'm successfully calculating the rated voltage, but the calculation requires floating point calculations and I would like to avoid that because I'm low on available flash space on my ATTiny85 micro controller. Here is how I'm currently calculating the rated voltage value:

uint8_t LRA_closed_loop_rated_voltage( uint16_t voltage ) {
   float RatedVoltage;
   uint16_t SampleTime = 300;
   uint16_t frequency = 175;

   RatedVoltage = ( (float) voltage ) * sqrt( 1 - ( ( 4 * SampleTime + 300 ) * 0.000001 ) * frequency );
   RatedVoltage = ( RatedVoltage * 255 ) / 5300;

   return RatedVoltage;
}

The function above is just a simplified version showing the calculation and the SampleTime and frequency variables are set to their defaults values here. The voltage argument is the actuator's rated voltage in millivolt.

EDIT: Even though SampleTime and frequency have fixed values in the function above, their values will be determined by reading the relevant registers in the final implementation. SampleTime may have one of the following values: 150, 200, 250, 300 and the frequency will depend on the manufacturers specifications for the actuator.

It was easy to overcome the floating point issue on the other calculations by simply scaling up the values by 1000 (fixed point arithmetic):

  ODClamp = ( Vpeak * 255) / 5.6 /* Vpeak in volts */

TO:

  ODClamp = ( Vpeak * 255) / 5600 /* Vpeak in millivolts */

How can I do the calculation in question without having to use floating point?


texts: Standalone ATMEGA328: Verification mismatch on random byte on -subsequent- uploads only

texts:
I have an Arduino Pro Mini as an ISP programmer with the ArduinoISP sketch running on it (19200 baud), and an addition in boards.txt that has a 'Standalone ATMEGA328 8MHz Internal' entry that specifies 8MHz and a bootloader file, along with some other things.

I'm trying to upload a simple blink sketch to an ATMEGA328 (not 328p, though the issue persists with that board as well) with no external components (internal clock)

The Problem

I can flash the bootloader no problem. I can also upload code the first time just fine. The problem is when I try to upload any different code after the first time, it gives a verification mismatch error at a seemingly random byte, complaining that 0xsomebody != 0xsomeotherbyte (also seemingly always different). This usually causes the sketch the stop working, and the LED to behave erratically.

IDE Verbose Outputs

Verbose output for burning the bootloader

Verbose output for first upload of simple sketch: basically Blink.ino

Verbose output for second upload of modified sketch: changed first delay to 1200 (side note: uploading an identical sketch doesn't give the verification mismatch error)

Verbose output for sufficiently different sketch (four digital writes, ie heartbeat example)

The Sketch

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

void loop() {
  digitalWrite(6, HIGH);
  delay(1100);
  digitalWrite(6, LOW);
  delay(400);
}

Bootloader Files

This is the boards.txt entry that I'm using:

##############################################################

atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.protocol=arduino
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=19200

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05

atmega328bb.bootloader.file=atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F

atmega328bb.build.mcu=atmega328
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino
atmega328bb.build.variant=arduino:standard

atmega328bb.bootloader.tool=arduino:avrdude
atmega328bb.upload.tool=arduino:avrdude

I've added this entry to Users/me/Local/Arduino/packages/arduino/hardware/avr/1.6.17 as well as Program Files(x86)/hardware/arduino/avr

Here's the HEX file for the bootloader incase that's useful as well

The Programmer

Here's a schematic of the programmer:

The solder jumper 'CAP1' is soldered closed.

And the connections to the ATMEGA328

simulate this circuit – Schematic created using CircuitLab

And lastly, a photo of the setup:

Thanks in advance


texts:
Here's a schematic of my project:

The purpose is to make laptop work as keyboard for desktop PC. Nano uses Serial.read() to get keystrokes from laptop and forwards key press and release data to Leonardo (using I2C) acting as USB-HID keyboard.
Nano's setup looks like:
void setup() {
  Wire.begin();
  Serial.begin(14400);
  Serial.write("Hello");  // https://serialport.io/docs/api-stream#serialpor|
  pinMode(LED_BUILTIN, OUTPUT);
}

Leonardo's setup looks like:
void setup() {
  Keyboard.begin();
  Wire.begin(4);
  Wire.onReceive(cbfunc);
}

I have tested both boards individually, but not the whole setup. Whenever either board connects to USB port it powers up due to +5 volt from USB. Now that I have i2c wires in place, I am confused -
if I connect leonardo & desktop first [and i2c-master (Nano) isn't powered on yet], what will happen at Wire.begin(4)? Will it wait (1s, 5s, forever) until i2c-master comes online?


texts:
I am getting error for uploading code to esp8266 module. I have installed cp2109 drivers also but at the time of uploading getting follwing error message:

Sketch uses 344,292 bytes (32%) of program storage space. Maximum is 1,044,464 bytes.
Global variables use 32,276 bytes (39%) of dynamic memory, leaving 49,644 bytes for local variables. Maximum is 81,920 bytes.
warning: espcomm_send_command: wrong direction/command: 0x00 0x08, expected 0x01 0x08
warning: espcomm_send_command: wrong direction/command: 0x00 0x08, expected 0x01 0x08
warning: espcomm_send_command: wrong direction/command: 0x00 0x08, expected 0x01 0x08
warning: espcomm_send_command: wrong direction/command: 0x00 0x08, expected 0x01 0x08
warning: espcomm_send_command: wrong direction/command: 0x00 0x08, expected 0x01 0x08
warning: espcomm_send_command: wrong direction/command: 0x00 0x08, expected 0x01 0x08
warning: espcomm_send_command: wrong direction/command: 0x00 0x08, expected 0x01 0x08
warning: espcomm_send_command: wrong direction/command: 0x00 0x08, expected 0x01 0x08
warning: espcomm_send_command: wrong direction/command: 0x00 0x08, expected 0x01 0x08
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed

Please help me to solve this problem


texts: I am brand new to electronics. I am trying to use a seven segment display breakout module with my arduino uno. My problem is that the display has a common positive instead of negative common. How do I make this work? As far as I am aware, all the arduino pins output positive with the exception of the ground, which is the negative common.


texts:
i have old chinese old hotair station that controls by atmega8l 8ua chip..
and the board designer are clever enough to put 2 identical dc plug, 1 is 5v supply cable.. the other one is on off switch that connect ground pin to sck pin..

i was mistaken plug power cable to the on off side that supply 5v+  to sck.. now the station not powering up anymore..

is there anyway to copy the firmware to new chip?
it cannot be detected by usbasp since i believes the sck are toasted..

i'm just a beginners and English are not my native language. sorry if the word are hard to understand..


texts: How to operate a brushless motor & ESC with an Arduino

texts:
I have recently bought two brushless motors (Brushless-300w-6-5-Wheel-Tyre-Motor-Hoverboard-Swegway-Board-Replacement-Part) along with two ESC (https://hobbyking.com/en_us/hobbyking-40a-esc-4a-ubec.html).

I have connected the hardware accordingly (photo attached, the potentiometer throttle included is not included in the photo).

And I try run the following code:

#include <Servo.h> //Using servo library to control ESC

Servo esc; //Creating a servo class with name as esc

void setup()

{

esc.attach(10); //Specify the esc signal pin,Here as D10

esc.writeMicroseconds(2000); //initialize the signal to 1000

delay(1000);

esc.writeMicroseconds(1000); //initialize the signal to 1000

delay(1000);

//Serial.begin(9600);

}

void loop()

{

int val; //Creating a variable val

val= analogRead(A0); //Read input from analog pin a0 and store in val

val= map(val, 0, 1023,1000,2000); //mapping val to minimum and maximum(Change if needed)
esc.writeMicroseconds(val); //using val as the signal to esc
}

The motors seem to vibrate and turn only when the potentiometer is at a specific point, and are then inert for all the subsequent positions.

Does anyone have any advice on how to overcome this issue?

Thanks!]1


texts: Why are the Do While loops not stopping?

texts:
Ive been staring at this for a while now and I am going cross-eyed.  I am writing a simply program to change colors of a 3 color LED.  It is working, but then I noticed the LED would sometimes flash.  I did a variety of tests and eventually, using the serial monitor, found out the issue.  The brightness should count down to a brightness level of 0 and up to a level of 255.  However, sometimes it counts below 0 to -1 and sometimes it continues infinitely past 255.  I cant figure out why.  Below is the code and the serial monitor outputs.  The only way I can stop is by manually setting the value outside the loop.  You can see those lines commented out to allow for the error.
int randLeg;  // var to pick a random leg

// set all 3 legs to max brightness at start
int legThreeBrightness = 255;
int legFiveBrightness = 255;
int legSixBrightness = 255;
int delayTime = 15;
int increment = 1;

void setup() {

    Serial.begin(9600);

    // set pins as output
    pinMode(3, OUTPUT);
    pinMode(5, OUTPUT);
    pinMode(6, OUTPUT);

    // turn all the LEDs on
    analogWrite(3, legThreeBrightness);
    analogWrite(5, legFiveBrightness);
    analogWrite(6, legSixBrightness);

    randomSeed(analogRead(0));  // seed rand num generator

}

void loop() {

    randLeg = random(4, 7);  // pick a random leg

    switch (randLeg) {
    case 4:  //-1 for pin 3
        if (legThreeBrightness == 255){
          do {
                Serial.println(legThreeBrightness);
                analogWrite(3, legThreeBrightness);
                delay(delayTime);
                legThreeBrightness = legThreeBrightness - increment;
             } while (legThreeBrightness >= 0);
             //legThreeBrightness = 0;
        }
        else {
         do {
                Serial.println(legThreeBrightness);
                analogWrite(3, legThreeBrightness);
                delay(delayTime);
                legThreeBrightness = legThreeBrightness + increment;
             } while (legThreeBrightness <= 255);
             //legThreeBrightness = 255;
        }
      break;

    case 5:
        if (legFiveBrightness == 255){
          do {
                ////Serial.println(legFiveBrightness);
                analogWrite(5, legFiveBrightness);
                delay(delayTime);
                legFiveBrightness = legFiveBrightness - increment;
             } while (legFiveBrightness >= 0);
             //legFiveBrightness = 0;
        }
        else {
         do {
                ////Serial.println(legFiveBrightness);
                analogWrite(5, legFiveBrightness);
                delay(delayTime);
                legFiveBrightness = legFiveBrightness + increment;
             } while (legFiveBrightness <= 255);
             //legFiveBrightness = 255;
        }
      break;
    case 6:
        if (legSixBrightness == 255){
          do {
                ////Serial.println(legSixBrightness);
                analogWrite(6, legSixBrightness);
                delay(delayTime);
                legSixBrightness = legSixBrightness - increment;
             } while (legSixBrightness >= 0);
             //legSixBrightness = 0;
        }
        else {
         do {
                ////Serial.println(legSixBrightness);
                analogWrite(6, legSixBrightness);
                delay(delayTime);
                legSixBrightness = legSixBrightness + increment;
             } while (legSixBrightness <= 255);
             //legSixBrightness = 255;
        }
      break;
   }

}

10 9 8 7 6 5 4 3 2 1 0 -1

and

250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265