texts:
Today I tried to display some text with my Arduino UNO and a LCD 1602A screen. I did find some schemas online, but I cannot get any character or "black boxes" on the display.

I connect wires like that :
Pin 1 : GND
Pin 2 : +5V
Pin 3 : 50K Pot.
Pin 4 : Pin 7 from Arduino
Pin 5 : GND
Pin 6 : Pin 6 from Arduino
Pin 11 : Pin 5 from Arduino
Pin 12 : Pin 4 from Arduino
Pin 13 : Pin 3 from Arduino
Pin 14 : Pin 2 from Arduino
Pin 15 : +5V
Pin 16 : GND

You can see my setup here : http://imgur.com/a/QkI4z

The LCD screen is lighten up, but nothing else appears. Pot. is working (increase or decrease light). I tried to change the LCD with another, but both are not working. I tested some many code, here an example :

/*
  LiquidCrystal Library - Hello World

 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.

 This sketch prints "Hello World!" to the LCD
 and shows the time.

  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe

 This example code is in the public domain.

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

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);
}

Do you have an idea ? Thanks !


texts: Uploading code to custom SAMD20G15B board through Atmel ICEand Arduino IDE

texts:
This is my setup:

SAMD21G15B with no external crystal (Addon possible with Epson MC-146 32.768Khz )
SWD connector

I'm trying to upload code with the Arduino IDE via the Atmel ICE. But when I choose

Arduino Zero Native programming port.
Programmer Atmel ICE
Upload using programmer

I get this error:

Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Zero (Programming Port)"

Sketch uses 10464 bytes (3%) of program storage space. Maximum is 262144 bytes.
Open On-Chip Debugger 0.9.0-g932ec70 (2017-02-15-12:34)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
debug_level: 0
adapter speed: 500 kHz
adapter_nsrst_delay: 100
cortex_m reset_config sysresetreq
Error: at91samd21g18.cpu -- clearing lockup after double fault
Polling target at91samd21g18.cpu failed, trying to reexamine
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000614 msp: 0x20007ffc
** Programming Started **
auto erase enabled
the selected serial port auto erase enabled
 does not exist or your board is not connected
Error: Couldn't find part correspoding to DID 10011424
Error: auto_probe failed
Runtime Error: embedded:startup.tcl:454: ** Programming Failed **
in procedure 'program'
in procedure 'program_error' called at file "embedded:startup.tcl", line 510
at file "embedded:startup.tcl", line 454

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

.

What could I be doing wrong?

This is my schematic.


texts:
Why does the following code return this error?  How can I make this work?

  Error: exit status 1 invalid conversion from 'const char*' to 'char'
  [-fpermissive]

#include "FS.h"
#include "SD.h"
#include "SPI.h"

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

  if (!SD.begin(33)) {
    Serial.println("Card Mount Failed");
  } else {
    Serial.println("Card Mount Succeeded");
  }

  File offline = SD.open("/offlineLog.txt", FILE_READ);

  while (offline.available()) {
    String line = offline.readStringUntil("\n");
    Serial.println(line);
  }
}

The docs say that stream.readStringUntil returns a string...


texts:
Alright, there is something missing in the question, I was able to hear one sound of the files and the others apply to the question I asked and that is why I am wondering. what is happening!

Here is the code:

   #include <SD.h>                      // need to include the SD library
#define SD_ChipSelectPin 4  //using digital pin 4 on arduino nano 328, can use other pins
#include <TMRpcm.h>           //  also need to include this library...
#include <SPI.h>

TMRpcm tmrpcm;   // create an object for use in this sketch

void setup(){

  tmrpcm.speakerPin = 9; //5,6,11 or 46 on Mega, 9 on Uno, Nano, etc

  Serial.begin(9600);
  if (!SD.begin(SD_ChipSelectPin)) {  // see if the card is present and can be initialized:
    Serial.println("SD fail");
    return;   // don't do anything more if not
  }
  tmrpcm.play("music.mp3"); //the sound file "music" will play each time the arduino powers up, or is reset
}

void loop(){

  if(Serial.available()){

    if(Serial.read() == 'p'){ //send the letter p over the serial monitor to start playback

      /* These are spkean Numbers */

     // tmrpcm.play("1-24bit.wav");
     // tmrpcm.play("1-16bit.wav");
     // tmrpcm.play("200-insane.mp3");
     // tmrpcm.play("music.mp3")       // Strangely this is the working perfectly with good sound
     // tmrpcm.play("200-standard.mp3");
        tmrpcm.play("200.wav");        // from https://evolution.voxeo.com/library/audio/prompts/numbers/index.jsp
    }
  }

}

Everything is good when I play this tmrpcm.play("music.mp3"); but the others I hear aliens sounds expect this tmrpcm.play("200.wav"); which I can hear the number two hundred but I feel the sound is 4-bit depth which very noisy. The files used in the code are here

For clarification previously, I thought it was amplifying issues which then I had to used LM386 but the sound was the same noise with tmrpcm.play("200.wav"); and later when I tried this tmrpcm.play("music.mp3"); I was shocked it worked perfectly like what I need it to be!  so I was curious I removed the LM386 and played this tmrpcm.play("music.mp3"); again and worked alright just maybe less volume.


texts:
I am working on code where I am able to manually enter the value in the URL to let the PHP code save it in the database, but I'm unsure how to do it with a variable in a loop running. This is the URL:

student.cs.hioa.no/~s180343/updatedb.php?verdi=25

Code:

void setup() {
  // Initialize Bridge
  Bridge.begin();

  // Initialize Serial
  Serial.begin(9600);

  // Wait until a Serial Monitor is connected.
  while (!Serial);
  Serial.println("Ready");

  // run various example processes

}

void loop() {
   runCurl();
   delay(10000);
}

void runCurl() {
  // Launch "curl" command and get Arduino ascii art logo from the network
  // curl is command line program for transferring data using different internet protocols
  Process p;        // Create a process and call it "p"
  p.begin("curl");  // Process that launch the "curl" command
  p.addParameter("student.cs.hioa.no/~s180343/updatedb.php?verdi=25"); // Add the URL parameter to "curl"
  p.run();      // Run the process and wait for its termination

  // A process output can be read with the stream methods
  while (p.available()>0) {
    char c = p.read();
    Serial.print(c);
  }
  // Ensure the last bit of data is sent.
  Serial.flush();
}


texts:
I use an MQTT to communicate with an ESP8266. I'm using cloudmqtt.com and PubSubClient. Sometimes the ESP disconnects from the MQTT and reconnects.
I checked the log from cloud and I got this data

2019-02-18 20:11:18: New connection from 89.64.15.184 on port 18127.

2019-02-18 20:11:22: New connection from 89.64.15.184 on port 18127.

2019-02-18 20:11:35: New connection from 89.64.15.184 on port 18127.

2019-02-18 20:11:35: New client connected from 89.64.15.184 as ESP8266Client-80:7D:3A:69:6C:2E (c1, k15, u'userName').

2019-02-18 20:11:53: Client <unknown> has exceeded timeout, disconnecting.

2019-02-18 20:11:53: Socket error on client <unknown>, disconnecting.

2019-02-18 20:11:56: Saving in-memory database to /var/lib/mosquitto/18127/db.

2019-02-18 20:11:58: Client ESP8266Client-80:7D:3A:69:6C:2E has exceeded timeout, disconnecting.

in setup I have this method:

void setupMQTT() {

  while (!client.connected()) {
    Serial.println("Connecting to MQTT...");
    String clientId = "ESP8266Client-";
    clientId += WiFi.macAddress();
    if (client.connect(clientId.c_str(), mqttUser, mqttPassword )) {

      Serial.println("connected");

    } else {

      Serial.print("failed with state ");
      Serial.print(client.state());
      delay(2000);

    }
  }
  client.publish("esp/blind/out", "hello world");
  client.subscribe("esp/blind/in");
}

and in loop I have

client.loop();

without any delay.

I think that the ESP id in MQTT cloud is unique, because I use the MAC address.


texts: 6 wire 3 digits 7 segment display and arduino question

texts:
Here's a brain teaser for you:

I have the following 3 digit 7 segment display that has only 6 wires

Experimentally I found out how it works, even though I don't understand it, but anyways every segment is lit by a combination of HIGH and LOW of certain two pins, the combinations are below:

So I tried to make it work, but encountered the following problem (as you can see in the first picture): if, for example, I want to activate the segment that requires pin 5 high and pin 6 low, it also activates the other segments that require 5 to high, because apparently if a digital output is not high, it's automatically pulled to ground, and that's a problem.
I tried by setting the other pins I don't use in a segment to high, but then the segments that require 6 low are being activated, so that didn't work.

Other option I have would be transistors or a tri-state buffer, but for that I need all 12 digital inputs of arduino for the two states of each pin of the display.

Hope you understand what my problem is and maybe you have some advice on how to solve it.

Thanks in advance!

Edit: I managed to drive every segment individually using a small delay, and it works if the sketch has only the code for the display, but as soon as I add more code (for the temperature sensor I want to use) it starts to malfunction. You can find the code below.

LE: I managed to make it work by leaving only the display function in the loop and calling every 5 seconds the function for the temperature sensor. It still refreshes the display when it is called, but that doesn't bother me.

Here's the code: http://www.mediafire.com/file/2bs5r8u5rkzpu8g/6w_3D_7S_display.rar


texts:
I would like to make a countdown with arduino.
To do this I'm using the millis () function, but I have a problem, I can not reset this.
Reading on the internet I read that it is not possible to do this.
So how can I find an alternative for this?
In practice, when I pressed the button I started the countdown, while if I put it back, I went into the pause mode.

void inizio(){
  Serial.println("INIZIO");

  currentMillis1_general = millis();
  total_1 = currentMillis1_general - currentMillis_general;
  Serial.println(total_1);

  buttonState = digitalRead(buttonPin);
  if(buttonState == HIGH){
    step_funzione = 1;
    delay(200);
  }
}

void countdown(){
  Serial.println("COUNTDOWN");

  display.setBrightness(7);

  currentMillis_general = millis();
  total_general = currentMillis_general - total_1;

  if(total_general - previousMillis_general >= interval_general){
    previousMillis_general += interval_general;
    //previousMillis_general = currentMillis_general;
    m = new_tempo/60;
    s = new_tempo%60;
    new_tempo--;
  }

  display.showNumberDec(m, true,2,0);
  display.showNumberDec(s, true,2,2);

  Serial.println(total_general);

  buttonState = digitalRead(buttonPin);
  if(buttonState == HIGH){
    step_funzione = 0;
    delay(200);
  }
}


texts: Atmega328 component library for Protel 99 SE

texts: Any one know a component library for Arduino UNO (Atmega328, etc) for Protel 99 SE PCB design software?


texts: ATmega168a Breadboard - can't load via Arduino IDE

texts:
I have ATmega168a on a breadboard. I am programming it via the Arduino IDE and a FT232RL USB adapter. When I select my board for 168 and upload, I get the following error:

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

Normally this error means that either:

My wiring is not correct
I choose the wrong board

So to double check my wiring, I replace the 168 with a 328p. I am able to program the 328, so I think its the board selection.

I have tried Ardiono Diecimila or Duemilanove w/ ATmega168 and I also have a custom board entry:

atmega168bb.name=ATmega168 breadboard (16 MHz internal clock)
atmega168bb.upload.protocol=stk500
atmega168bb.upload.maximum_size=14336
atmega168bb.upload.speed=57600

atmega168bb.bootloader.low_fuses=0x62
atmega168bb.bootloader.high_fuses=0xDF
atmega168bb.bootloader.extended_fuses=0xF9
atmega168bb.bootloader.path=arduino:atmega
atmega168bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_16MHz.hex
atmega168bb.bootloader.unlock_bits=0x3F
atmega168bb.bootloader.lock_bits=0x0F

atmega168bb.build.mcu=atmega168
atmega168bb.build.f_cpu=16000000L
atmega168bb.build.core=arduino:arduino
atmega168bb.build.variant=arduino:standard

Also, I am able to program the 168 via my AVR Programmer/Debugger. If you are wondering why I should just use the AVR Dragon, there reason is that I a sometimes don't want to remove the chip from the bread board while developing and programming.

Any suggestions I can try?


texts:
i want to convert string for example
"68976543210" to unsigned long long(64 bit) in mega2560,
 do is possible?

String x="68976543210";
unsigned long long y=?;


texts:
I am using the following code to send an IR signal:

#include <IRremote.h>
 IRsend irsend;

void setup() {

}

void loop() {

    unsigned int IRsignal[] = {86,88,86,88,174,86,88,88,86,88,86,86,88,86,88,86,88,174,86,88,174,86,88,2336,90,86,88,86,174,88,86,88,86,88,86,88,86,88,86,88,86,174,88,86,174,88,86,0};

    irsend.sendRaw(IRsignal, 48, 40);

    delay(3000);

}

However, when I attach an IR receiver to another Arduino and take a look at the signal that is produced by the code above, I see this:

Received:

OFF     ON
332 usec, 460 usec
1040 usec, 280 usec
2680 usec, 260 usec
820 usec, 80 usec
400 usec, 260 usec
int IRsignal[] = {
// ON, OFF (in 10's of microseconds)
    46, 104,
    28, 268,
    26, 82,
    8, 40,
    26, 0};

Received:

OFF     ON
39228 usec, 280 usec
1160 usec, 340 usec
2460 usec, 480 usec
440 usec, 500 usec
340 usec, 260 usec
int IRsignal[] = {
// ON, OFF (in 10's of microseconds)
    28, 116,
    34, 246,
    48, 44,
    50, 34,
    26, 0};

These numbers are not even close to the ones that are going in.  There are far few pulses recorded, the duration is very inconsistent (the original code is almost entirely made up of 880-860um pulses) and even close to the original values.  I must have made a serious mistake here.  What happened?

UPDATE ==========================

I multiplied all of the values in the array by 10 and attempted to play/read the values using another Adruino with an IR sensor.  I started to see better results.  each pulse time was close to 88, 86, or 174 but they are still off by up to 10%.  The related IR device is still unresponsive.  Is there any other way to improve this?

Received:

OFF     ON
29828 usec, 860 usec
900 usec, 820 usec
880 usec, 1700 usec
880 usec, 860 usec
880 usec, 840 usec
940 usec, 760 usec
840 usec, 880 usec
860 usec, 880 usec
860 usec, 860 usec
1740 usec, 840 usec
880 usec, 1700 usec
880 usec, 840 usec
6920 usec, 880 usec
860 usec, 860 usec
880 usec, 1680 usec
880 usec, 860 usec
900 usec, 820 usec
900 usec, 820 usec
880 usec, 840 usec
860 usec, 840 usec
960 usec, 740 usec
1760 usec, 880 usec
920 usec, 1620 usec
900 usec, 10680 usec
13580 usec, 8580 usec
8820 usec, 8680 usec
int IRsignal[] = {
// ON, OFF (in 10's of microseconds)
    86, 90,
    82, 88,
    170, 88,
    86, 88,
    84, 94,
    76, 84,
    88, 86,
    88, 86,
    86, 174,
    84, 88,
    170, 88,
    84, 692,
    88, 86,
    86, 88,
    168, 88,
    86, 90,
    82, 90,
    82, 88,
    84, 86,
    84, 96,
    74, 176,
    88, 92,
    162, 90,
    1068, 1358,
    858, 882,
    868, 0};


texts: Effective Controlling of Continous Servo Motor

texts:
I have difficulty in controlling a MG995 continuous motor. For I know I can control the speed of the motor as writing servo1.write(p) , where the value of p changes the speed of the motor. When the value of p is set to 90 then the motor stops ,whereas 0 and 180 values allows it to move in the top speed in C.W and Anti C.W direction respectively.
...........** I had difficulty in writing a code where I can rotate the servo motor for 180 degrees then rotating back again to 0 and whenever my ultrasonic sensor finds any object the servo should stop at that point for further action. ** ........
(I think this value could be useful :Operating speed: 0.2 s/60º (4.8 V), 0.16 s/60º (6 V))


texts: Valid options for output port on Mega 2560

texts:
I would like to adopt this library on an Arduino Mega2560:
https://github.com/gueei/DShot-Arduino
However, the macro DSHOT_PORT needs defined for the Mega2560 here:
https://github.com/gueei/DShot-Arduino/blob/master/src/DShot.h
So I need to add a #if defined(__AVR_ATmega2560__) macro to that DShot.h header, however, it is not clear to me where to lookup the port mapping on a 2560 mega.  I'm looking directly at the schematic itself here:
https://www.arduino.cc/en/uploads/Main/arduino-mega2560-schematic.pdf
And understand that the 'ports' are groupings of IO where the pins are described as P?#, ? being the port letter and # being 0-7.
So what are my valid options?  It appears that some ports (A,C,L) aren't pinned at all, some (D,J) only a few pins, and just about none of them (except K/F) have all port pins utilized.  Also, I can see most of these pins are reserved for some type of functionality (analog, SPI, etc).  I'm assuming I'm looking for a port with available pins reserved for PWM, such as Port B (pins 10-13 are PWM).  Would this be correct?


texts:
I'm attempting to drive 300 TM1803 RGB LEDs from an Arduino Uno using the FastLED library. My code works fine for 100 LEDs, but when I go to 150, the arrays that store LED values and my sensor data get corrupted, causing the LEDs to flash colors randomly every few seconds. From what I've read these are exactly the symptoms of running out of RAM, leading to something overwriting the RAM that contains my arrays.

However, with 150 LEDs, the MemoryFree library says I'm only using 920 bytes of RAM, no matter where in my code I measure, and the IDE says 880. Does anybody know what's going on? Is there something using 1100 bytes of RAM for a very short amount of time, so that I can't measure it?

My code:

#include "FastLED.h"
#include <MemoryFree.h>

const byte ledsPin = 3;
const byte sensorPin = A1;

const int numLeds = 300;
const int ledTime = 1000;

const int sensorMin = 0;
const int sensorMax = 512;

const CRGB correction = CRGB(80,255,70); // Cool white
//const CRGB correction = CRGB(160,255,20); // Warm white
const byte hOffset = 170; // baseline hue value
const int8_t hDirection = -1; // 1 or -1, direction of rainbow
const byte s = 255; // saturation (colorfulness)
const byte v = 255; // value (brightness)

const unsigned int arrayLength = numLeds+1;
byte hues[arrayLength];

CRGB leds[numLeds];
byte h = 0; // hue (color)

unsigned long sensorSum;
unsigned int loopCounter;
unsigned int arrayCounterLed;
unsigned int updatesPerLed;
char sp = ' ';
int arrayCounter;

unsigned long time;
unsigned long timeNextLed;
unsigned long timeLeft;
unsigned long time1;
byte route;

void setup() {
  FastLED.addLeds<TM1803, ledsPin, RBG>(leds, numLeds).setCorrection(correction);
  FastLED.setDither(0);
  pinMode(ledsPin, OUTPUT);
  Serial.begin(115200);
}

void loop() {
  delay(10);
  time=millis();
  sensorSum += analogRead(sensorPin);
  loopCounter++;
  if(time >= timeNextLed) {
    timeNextLed = (time/ledTime+1)*ledTime;
    arrayCounter = (arrayCounter +1) % (arrayLength);
    hues[arrayCounter] = (constrain(map(hDirection*sensorSum/loopCounter, sensorMin, sensorMax, 0, 239), 0, 239)+hOffset)%256;
    updatesPerLed = loopCounter;
    loopCounter=0;
    sensorSum = 0;
  }
  for(int led = 0; led < numLeds; led++) {
    time1=micros();
    arrayCounterLed = pseudoMod(arrayCounter - led -1, arrayLength);
    timeLeft = timeNextLed-time;
    byte dist = abs(hues[arrayCounterLed]-hues[(arrayCounterLed+1)%(arrayLength)]);
    if(abs(hues[arrayCounterLed]-hues[(arrayCounterLed+1)%(arrayLength)])<=128) { // if it doesn't cross through 0
      h = (hues[arrayCounterLed]*timeLeft + hues[(arrayCounterLed+1)%(arrayLength)]*(ledTime-timeLeft))/ledTime;
    }
    else if(hues[arrayCounterLed] > hues[(arrayCounterLed+1)%(arrayLength)]) { // if it crosses through 0 forwards
      h = ((hues[arrayCounterLed]*timeLeft + (hues[(arrayCounterLed+1)%(arrayLength)]+256)*(ledTime-timeLeft))/ledTime)%256; // Causing flashing on red pixels?
    }
    else { // if it crosses through 0 backwards
      h = (((hues[arrayCounterLed]+256)*timeLeft + hues[(arrayCounterLed+1)%(arrayLength)]*(ledTime-timeLeft))/ledTime)%256;
    }
    time1 = micros() - time1;
    if(led == 0) {
      Serial.print(dist);
      Serial.print(sp);
      Serial.print(route);
      Serial.print(sp);
      Serial.print(timeLeft);
      Serial.print(sp);
      Serial.print(hues[arrayCounterLed]);
      Serial.print(sp);
      Serial.print(hues[(arrayCounterLed+1)%(arrayLength)]);
      Serial.print(sp);
      Serial.print(hues[arrayCounterLed]*timeLeft);
      Serial.print(sp);
      Serial.print(hues[(arrayCounterLed+1)%(arrayLength)]*(ledTime-timeLeft));
      Serial.print(sp);
      Serial.println(h);
    }
    leds[led] = CHSV(h, s, v);
  }
  FastLED.show();
  Serial.print(updatesPerLed);
  Serial.print(time1);
  Serial.println();
}

int pseudoMod(int a, int b) {
  if(a<0) {
    return a+b;
  }
  else {
    return a;
  }
}


texts: Having an issue running an Arduino sketch

texts:
I just got my USB host shield attached to my Arduino Uno, opened the program sketch for USBDESC.ino and I'm getting an error. It says "usbhub.h not found". It won't compile. How did I go wrong?

I am using the Mac version of the Arduino IDE and downloaded the USB host shield Master v 2.0 file directly into /Arduino/java/examples. This was how I have added every previous library download. Please help. Thanks.


texts:
I currently have a barebone arduino built from just an Atmega 328P and a 16Mhz external crystal.

I planning to move this system down to 3-3.6V but I have read that on low voltage I have to use 8Mhz crytstal so my only question is that because of this change do I have to take the chip out to reflash with the programmer again or it will work as it did before?

What will happen if I do not change the oscillator and leave it on 16MHZ ceramic?


texts: Will this sketch eventually fail because of integer limit issue?

texts:
I am a novice in Arduino programming and I'm setting up an Arduino controlled, underwater time-lapse camera to take a picture every 2 hours.  It's going in the ocean for a month and I want to be sure that the code will not fail because of the upper limit that normal integers can go.
The Arduino simply switches on a relay (connected to the LED_PIN 11) and the camera does the rest, using a script from the awesome Canon Hackers Development Kit C.H.D.K.

I've tried several variations of sketch, some using simple delay, some with millis and some with counters that print what increment the loop it up to.

One of my fast running test sketches, that used a counter, stopped prematurely, I suspect due to hitting the integer limit but I'm not sure if this only occurred due to the fact that it had a counter in the sketch.  So I've gone back to the simplest sketch I can find hoping it will not have this issue.

I think I read that once the integer limit is reached, the sketch will simply restart.  Or maybe it will become unpredictable.  I'd rather the  former than the latter.

Any suggestions would be welcome.

I am sure there are many ways to go about this but I'm looking for the simplest and most robust one I can find, so that I can adjust the async timing easily ie.
loop starts
CameraOn for 10 seconds
CameraOff for 2 hours
Loop repeats

thanks in advance for your consideration

Here's the sketch I'm testing right now.

#define LED_PIN 11
#define LED_OFF 7200000     // 2 hours in millis
#define LED_ON  8000       // 6 seconds in millis

unsigned long ms;        //time from millis()
unsigned long msLast;    //last time the LED changed state
boolean ledState;        //current LED state

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

void loop(void)
{
    ms = millis();
    blinkLED();
}

void blinkLED(void)
{
    if (ms - msLast > (ledState ? LED_OFF : LED_ON)) {
        digitalWrite(LED_PIN, ledState = !ledState);
        msLast = ms;
    }
}

==================================================================

Okay, I've come up with a new, much simpler sketch based on delay.
Can someone please tell me if this is more robust in terms of continued looping for weeks on end?

#define LED_PIN 11

void setup()
{
   Serial.begin(9600);
   pinMode(LED_PIN, OUTPUT);
   digitalWrite(LED_PIN, HIGH);
}

void loop()
   {
       delay(7200000);                 // 2 hours in millis
       digitalWrite(LED_PIN, LOW);
       delay(8000);                    // 8 seconds in millis
       digitalWrite(LED_PIN, HIGH);

   }


texts:
I have this book here about Arduino. What kind of Kit should I purchase to get started? Would this work?

I'm not yet sure about what I'd like to do with Arduino, so I may prefer a pretty Universal Kit in order to cover a pretty wide range of projects.

Except this, I won't need any advanced stuff, at the moment, as a beginner I may want to understand the fundamentals, so will surely need LEDs, maybe screens, and other basic stuff like that.

Later on I may try to go for Wireless modules, but not at the moment as a beginner.

Any ideas? Hope to have clarified more or less what projects I'm aiming to, yeah the range is wide, but restricted to basic beginner projects.


texts:
I want to make 2 LEDs blink back and forth continuously, but they only do so once, and the second one is very dim.

code:

int ledone = 12;
int ledtwo = 10;
int keepgoing = 1;

void setup() {
pinMode(ledone, OUTPUT);
pinMode(ledtwo, OUTPUT);
}

void loop() {
 while (keepgoing == 1) {
  digitalWrite(ledone, HIGH);
  delay(80);
  digitalWrite(ledone, LOW);
  digitalWrite(ledtwo, HIGH);
  delay(80);
  digitalWrite(ledtwo, LOW);
  delay(500);
 }
}

I am using an Arduino Uno and one 220 ohm resistor for each LED.


texts:
I'm using EEPROM to store long term data for use in sketches (thanks to DarthRubik for the guidance).  I store stuff like a location ("Garden") and a device name ("Greenhouse Monitor 02") plus whatever else I'd need to store to help filter through data.

When this information is stored in the sketch itself it is recalled quickly and accurately, is passed via wifi to my PHP, that then posts the data to the relevant fields in my AWS db.  Piece o' cake!  When I store it in the EEPROM, the extra time required to find it in EEPROM, pull it through the sketch, and then push it through to the db corrupts the data sourced from EEPROM and posts a jumbled mess of characters...if it even makes it to the db at all.

My question is actually simple (I think):
Is it possible to "stage" strings from EEPROM in flash or SRAM vs. pulling cold from EEPROM?

I think PROGMEM plays a role here and I'm looking at examples oh how other sketched employ PROGMEM to better understand how to use it.

I am withholding the code for now because I want to try to implement concepts people may describe before I am just shown the solution...although that would be easier.  If I can't figure it out I'll post the code for more direct answers.


texts: w5100 and nrf24l01 - SoftSPI - Radio not starting

texts:
I had posted some questions about this project earlier this week. Arduino uno + w5100 ethernet shield + nrf24l01 transeiver.

The w5100 is running a webserver to accept GET requests and parse out the variables - Works all the time

The nrf24l01 is acting as a transmitter and sending data out to other nodes - Only works with no Ethernet code.

What doesn't work is both at the same time. With everything hooked up it parses get fine, gets the variable but I can't transmit it since the radio never seems to fire up. Remove all the ethernet code and leave just the radio code it sends fine.

Code here. http://pastebin.com/SMWC9x4F it errors at 146. Which I assume is the radio never starting since the:

radio.printDetails();

does nothing.

I'm using manicbug's library.

I use the EXACT same send bits in that file to test wireless communication, it works. I only need it to transmit wirelessly when it get data from the network.

Pinouts:

CSN -> 10
CE   ->  9
MISO -> 12
MOSI -> 11
SCK   -> 13
VCC   ->  Separate 3.3 source, not the arduino
GND  -> GND

My guess is this is because both are using SPI.

Tried the softspi method http://pastebin.com/4mv612B7 .

Same thing. I can post GET to it, parse out variables but nothing on the radio side. And I still get no output from radio.printDetails() so it just must not be starting. Commence hair pulling..

EDIT: Bloody hell, printDetails() relies on printf...... that would have been handy to figure out an hour or two ago.  I can get details now. still having communication issues.  Will post more debugging information in a bit.


texts: Can I switch from Arduino IDE to Atmel studio or Visual Micro but still use Arduino library?

texts:
If switch from Arduino IDE to Atmel studio or Visual Micro, how to use existing Arduino library?

Library serves important function of 'packaging' real and complex hardware (like NRF24L01 radio board) into functions of 'relatively standard format', like radio.init, radio.write, radio.read, radio.on, etc.

This allows user to easily use the hardware without reading the data sheet.

How can the same be achieved under Atmel studio?


texts: Serial Print, String And Variable On Same Line

texts: How can I print to the serial monitor a string or just single character followed by a variable like "L 55"


texts:
I am pairing an Arduino Uno along with both a HC-05 bluetooth module and a sensor circuit.

Show below is the circuit conditions as well as the circuit.

As far as powering up the system, I am planning to use a 9 Volt battery(550 ampere) to connect to the Arduino which draws in 45 mA and the sensor circuit which takes in a total of 28 mA. I calculated the total life of one of the batteries to be 7.53 hours by (550/(28+45)). Can someone help me with the total power consumed by the system?

UPDATE:
I read on the sensor data sheet that there are two parameters which heater power as well as sensor consumption. Heater Power consumers approximately 140 mW and the sensor consumes approximately 10 mW. I believe the Arduino will consume 405 mW because of (9 volts * 45 mA)  and the bluetooth module will consume 26.5 mW because (3.3 volts * 8). Therefore, the total power consumption is 571.5 mW. Is this correct??? Also will the 9 volt battery be able to support the total power?


texts: How can I tell if sketch is really uploaded

texts:
I am trying to figure out how to tell if my sketch upload was really successful.  My Arduino UNO with AVR ISP example loaded and a Chinese AVR ISP programmer board inserted tells me that my sketch was successful but because the memory used in the ATMega328P is lower than I think it should be I can't tell if my sketch really did upload and dumping the file and doing a Windows FC (file compare) just tells me they are different.  The ATMega328P should only have the bootloader prior to my sketch upload.  Looking at the file with an editor tells me nothing other than there are things loaded in memory.

The operating system is Windows 7 using the Arduino 1.8.7 IDE and an Arduino Uno via usb.

Thank you.


texts: Creation of multiple power cells to be controlled by Arduino

texts:
I'm fairly new to the Arduino world, but have a history of good working knowledge of computers and software (I'm a software engineer), but I've only had the opportunity so far to create a few simple successful play-around projects.

I've decided to embark on a fairly ambitious project to build my son a ride on battery powered car for Christmas and trying to put all the pieces together.

An integral part of this plan is to develop what I call a couple of 'Power cells', which is simply a battery enclosure that has:

Updated:

An input from the Arduino to control the motor speed/voltage.
An input from either the Arduino or forward reverse switch to control the direction of polarity (make motor spin forwards or backwards)
Has a output to power the motor: 20V, drawing about 1-1.5 Amps
Has a output to power the 9x 12V LED lights on it, about upto 50W total (the LED lights will be controlled by the Arduino outside of the power bank, seeing there are a few of them).

I've drawn up a schematic that works with the components I've bought to help put the system together and was wondering if I am missing anything, critical or not?

Info about the battery I'm using can be found here: Aldi Xfinity 20V Li-Ion Battery teardown.

More Specifically:

Are there any errors with the cabling, I'm assuming no additional earth is required in a DC Circuit.
What size cables will i need to adequately service my power requirements?
Would I be able to control the reverse polarity switch directly from the Arduino? As I would like to also trigger a beeper when it is switched in reverse mode. Keep in mind the arduino would need to control 2-4 power cells.
I assume the controlling the potentiometer from the arduino I would need to use junction boxes between the arduino and the power cells to distribute the signal across each power cell, would this be the best way to do this?
The Li-Ion Battery also seems to have T output pin, i assume this is temperature monitoring, is there a way to utilize this input into the arduino for safety monitoring?
I was thinking of splitting the lighting power load between 2 power banks, would this be recommended / possible? (left power cell would power left side leds and right power bank would power right cell leds, with the exception of them both powering the center led).
Are there any additional safety precautions I should be following, especially working with a Li-Ion battery, ie. Fuse etc ?

I'm planning to make 2x of these Power cells to put in the car (each powers its own motor) (with the ability to add another 2 down the track).

Would really appreciate your feedback (please let me know if this is not the right place to ask this sort of question).


texts: Is there a way to combine a 3-axis accelerometer/gyroscope into one value?

texts:
I have a three-axis accelerometer that reads me its x, y, and z components.  This results in three graphs.  Is there a way to "combine" these components into one reading, hence, one graph?   Same question holds for a gyroscope.

The datasheet for my device is here:


texts: Mkr1010 disconnects and reconnects normally until it reaches a point where it never reconnects again

texts:
The board does reconnect from time to time, but there are times where it just disconnects and never reconnects again and I can't replicate the error because while I run it with Serial open and turn ON and OFF my WiFis he always reconnects as it should.

#include <ArduinoHttpClient.h>
#include <WiFiNINA.h>
#include <EmonLib.h>

EnergyMonitor emon1;
EnergyMonitor emon2;
EnergyMonitor emon3;
int INTERVAL = 60;
int last_code = 0;

char ssid[] = "MySSID";
char pass[] = "MyPW";

String ID = "Garden_Pump_Sensor";

int sequence = 0;
double kWh = 0.0;

char serverAddress[] = "192.168.1.108";  // server address
int port = 5005;

WiFiClient wifi;
HttpClient client = HttpClient(wifi, serverAddress, port);

int status = WL_IDLE_STATUS;

void setup() {
  Serial.begin(9600);
  analogReadResolution(9);
  emon1.current(0, 100);
  emon2.current(5, 100);
  emon3.current(6, 100);
  Connecting();

}
void Connecting() {
  int tries = 4;
  while ( (WiFi.status() != WL_CONNECTED && tries > 0) || last_code != 200) {
    Serial.print("Status #1: ");
    Serial.println(WiFi.status());
    WiFi.begin(ssid, pass);
    Serial.print("Status #2: ");
    Serial.println(WiFi.status());
    tries--;
    last_code = 200;
  }

  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);
}

void reconnecting() {
  if  (WiFi.status() != 3  || (WiFi.RSSI() <= -90) || (WiFi.RSSI() == 0) || last_code != 200) {
    WiFi.end();
    Connecting();
  }
}

void loop() {
  unsigned long delayTime = INTERVAL * 1000;
  unsigned long time_start = millis();

  DataMonitorAndSend();

  unsigned long time_final = millis() - time_start;
  unsigned long delay_value = delayTime - time_final;
  Serial.println(delay_value);
  if (delay_value < 1  || delay_value > delayTime) {
    return;
  } else {
    delay(delay_value);
  }

}
void DataMonitorAndSend() {
  reconnecting();

  Serial.println("making POST request");
  String contentType = "application/json";
  kWh = kWh + getKWH();
  String postData = "{\"ID\": \""+ID+"\",\"seq\": " + String(sequence) + ",\"kWh\": " + String(kWh, 6) + "}";
  Serial.print("data: ");
  Serial.println(postData);

  client.setHttpResponseTimeout(5 * 1000);
  client.post("/receivedata/", contentType, postData);

  // read the status code and body of the response
  int statusCode = client.responseStatusCode();
  String response = client.responseBody();

  Serial.print("Status code: ");
  Serial.println(statusCode);
  if (statusCode == 200) {
    kWh = 0;
    sequence++;
  }
  last_code = statusCode;
  Serial.print("Response: ");
  Serial.println(response);

}

double getKWH() {
  int LOOPS = 15;
  double kWh_Total = 0.0;
  unsigned long delayTime_kwh = 2 * 1000;
  for (int i = 0; i < LOOPS; i++) {
    unsigned long time_start_kwh = millis();

    double Irms1 = emon1.calcIrms(600);
    if (Irms1 < 0.3) Irms1 = 0;
    double Watt1 = (Irms1 * 230) / 1000;

    double Irms2 = emon2.calcIrms(600);
    if (Irms2 < 0.3) Irms2 = 0;
    double Watt2 = (Irms2 * 230) / 1000;

    double Irms3 = emon3.calcIrms(600);
    if (Irms3 < 0.3) Irms3 = 0;
    double Watt3 = (Irms3 * 230) / 1000;

    kWh_Total = kWh_Total + ((Watt1 + Watt2 + Watt3) / 60);

    unsigned long time_final_kwh = millis() - time_start_kwh;
    unsigned long delay_value_kwh = delayTime_kwh - time_final_kwh;
    if (delay_value_kwh < 0  || delay_value_kwh > delayTime_kwh) {
      delay(0);
    } else {
      delay(delay_value_kwh);
    }

  }

  return kWh_Total / LOOPS;
}

Feel free to ignore the getkWH(), it's code related to power consumption. Also the firmware is up to date and the server is running in a static IP.


texts: Can external power supply above current limit lead to errors/shutdown arduino?

texts:
I have an Arduino Due that is connected both over native USB to PC and a 12v power supply in the Jack.
Mounted on the Arduino I have a custom PCB that drives 3 motor drivers. The Motor drivers are powered via the arduinos VIN Pin with 12v.

As Ive read elsewhere the arduino automatically chooses the 12v powersupply in this case. My question is: If the 3 motor drivers exceed the 1amp that the powersupply can supply, will the arduino encounter errors/shutdown or automatically switch back to USB for power supply?

If so, is there a way I can force the arduino to take the USB 5v even though 12v are connected through the Jack?

Also, how much current can I safely drive through the VIN Pin?

Thanks!


texts: Arduino - Getting error - 'TCCR2' was not declared in this scope

texts:
This code below:

void setup() {
  #if defined(__AVR_ATmega168__)
    // 62.5KHz PWM for the ATMega168 -> only on Arduino pins 9 and 10

    // set prescaler to 1
    // (sbi means "set bit register", cbi means "clear bit register")
    cbi(TCCR1B, CS12);
    cbi(TCCR1B, CS11);
    sbi(TCCR1B, CS10);

    // set fast PWM
    cbi(TCCR1B, WGM13);
    sbi(TCCR1B, WGM12);
    // with fast PWM, the frequency is (CLK/256*prescaler) = 16MHz/256 = 62.5KHz
    // with slow PWM, it is half that speed (31KHz)
  #else
    // 22KHz for the ATMega8 (this is a low frequency)
    TCCR2 = ((TCCR2 & ~0x07) | 0x01); //<ERROR POINTS HERE!
    TCCR1B = ((TCCR1B & ~0x07) | 0x01);
  #endif
}

when verify, generates an error:

In function 'void setup()':
pwm-control-1:185: error: 'TCCR2' was not declared in this scope
TCCR2 = ((TCCR2 & ~0x07) | 0x01);
^
exit status 1
'TCCR2' was not declared in this scope

So far i know this code generates pwm at pin 9 or 10, and designed for ATmega168 or ATmega8. The code came with a .pde extension and I opened it on 'Arduino: 1.8.3' and saved as an .ino file.

Can any one please tell me how to convert this code to work with 'ATmega328P-PU' and for the latest Arduino IDE. And also if there anything else to consider running with this code

I'm not an expert in pwm and timer/controls in micros... just started to learn..

Note: I've only shown the necessary part of the code


texts: Arduino DUE samples per second with the DAC

texts: I want to know how many samples per second the arduino due DAC can generate, I need to generate an ultrasonic signal (40Khz), the arduino due is not going to do anything else that generate this signail for a very short period of time.


texts:
Can someone help me what is the meaning of this sketch? It always outputs in the serial monitor:

Firmware Version: 0x1C = (unknown)
Scan PICC to see UID, SAK, type, and data blocks...

This is the code of the MFRC522 library I use:

#include <SPI.h>
#include <MFRC522.h>

constexpr uint8_t RST_PIN = 9;          // Configurable, see typical pin layout above
constexpr uint8_t SS_PIN = 10;         // Configurable, see typical pin layout above

MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance

void setup() {
   Serial.begin(9600);   // Initialize serial communications with the PC
   while (!Serial);    // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
   SPI.begin();      // Init SPI bus
   mfrc522.PCD_Init();   // Init MFRC522
   mfrc522.PCD_DumpVersionToSerial();  // Show details of PCD - MFRC522 Card Reader details
   Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
}

void loop() {
   // Look for new cards
   if ( ! mfrc522.PICC_IsNewCardPresent()) {
     return;
   }

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

   // Dump debug info about the card; PICC_HaltA() is automatically called
   mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}


texts:
I am using an Arduino Uno R3.

It is not clear on the schematic whether there are pullups on the A4 and A5 I2C pins.

Are there hardwired pullups or do I have to add them myself?


texts:
I would like to know how Arduino allocate memory for pointers in function arguments.

For instance. I have this code that use 192 bytes (Arduino IDE compiler:
Global variables use 192 bytes (9%) of dynamic memory).

char alph [] = {'a', 'b', 'c','\0'}; // 4 bytes
int numb [] = {1, 2, 3, 4}; // 8 bytes
float flo [] = {1.1, 2.2, 3.3}; // 12 bytes

void fn(){
  Serial.println(alph);
  Serial.println(numb[1]);
  Serial.println(flo[1]);
}

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

void loop(){}

The following code is the same of above, but I'm using pointer to variables in arguments, that use 234 bytes (Arduino IDE compiller: Global variables use 234 bytes (11%) of dynamic memory).

char alph [] = {'a', 'b', 'c','\0'}; // 4 bytes
int numb [] = {1, 2, 3, 4}; // 8 bytes
float flo [] = {1.1, 2.2, 3.3}; // 12 bytes

void fn(char * _alph, int * _numb, float * _flo){
  Serial.println(_alph);
  Serial.println(_numb[1]);
  Serial.println(_flo[1]);
}

void setup()
  Serial.begin(9600);
  fn(alph, numb, flo);
}

void loop(){}

There is a difference of 42 bytes to use three pointers. Why? A char pointer is 1 byte, a int pointer is 2 bytes and a float pointer is 4 byte length. Do the difference must be 7 bytes?


texts: How can i send data to phpmyadmin database? using esp8266 nodemcu and max30100

texts:
i want to send data from my sensor to database phpmyadmin. but i only get zero values. please help me thank you.

void loop()
{
  pox.update();
  BPM = pox.getHeartRate();
  SpO2 = pox.getSpO2();
 // Sending_To_phpmyadmindatabase(BPM);

  if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
    Serial.print("BPM: ");
    Serial.println(BPM);
    Serial.print("SpO2: ");
    Serial.print(SpO2);
    Serial.println("%");
    Serial.println("*********************************");
    Serial.println();
    tsLastReport = millis();
    delay(0);
    }
    Sending_To_phpmyadmindatabase(BPM);
}

void Sending_To_phpmyadmindatabase(float BPM){
  if (client.connect(server_addr,80)) {
    Serial.println("connected");
    Serial.print("GET /pulse.php?BPM=12");
    client.print("GET /pulse.php?pox.getHeartRate="+String(BPM,1));
    Serial.println("pox.getHeartRate!");
    client.println("pulse=");
    client.println(BPM);
   // Serial.print("GET /vsmonitor/connect.php?SpO2=12");
   // client.print("GET /vsmonitor/connect.php?SpO2="+String(SpO2,1));
   // Serial.println("SpO2!");
    //client.println("o2_sat=");
    //client.println(SpO2);
    client.print(" ");
    client.println(" HTTP/1.1");
    client.println("Host: 192.168.15.4");
    client.println(server_addr);
    client.println("Connection: close");
    client.println();
  }
  else {
    Serial.println("--> connection failed\n");
  }
  Serial.println();
  delay(5000);
}


texts:
I am trying to play a tone with a buzzer connected on an arduino nano pin. I have also connected a reed switch with INPUT_PULLUP on INT0 and a led. The program loops continuously (it's an environmental monitor and alarm personal project) until the reed switch is set on HIGH where a function is called and the buzzer should play an one-second high pitch tone.

void doorStateChange() {
  static unsigned long last_interrupt_time = 0;
  unsigned long interrupt_time = millis();
  if (interrupt_time - last_interrupt_time > 1000)
  {
    led_B_state   = !led_B_state;
    digitalWrite(buzzPin, HIGH);
    digitalWrite(led_A_Pin, HIGH);

    if (millis() - interrupt_time <= 1000 ){
        digitalWrite(buzzPin, LOW);
        digitalWrite(led_A_Pin, LOW);
    }

  }
  last_interrupt_time = interrupt_time;
}

The interrupt is called, the Led lights up but I can't make the buzzer sound right. I 've tried with tone(buzzPin, 5000, 1000); but seems that the delay does not work - The sound is heard but after the 1000ms it continuous to work in a different tone (strange?).

The only way I could make it work is with buzzPin_state = ! buzzPin_state; where the buzzer beeps as long as the reed switch is HIGH.

I also need to say that attachInterrupt(0, doorStateChange, CHANGE);.

The information I get from googling this issue is gibberish: some say that delays don't run in interrupts, others call external functions etc.

What is the proper way to achieve this ?


texts:
So basically I'm working on a project that uses an Atmega328 like on the Arduino Uno. I need to receive both DMX (with max485) and E131 (Not both at the same time, I'll decide which with a boolean in the sketch) and then use that to control 16 channels. I need the TX and RX pins (UART) for the max485 (DMX), 16 outputs for the triacs, and 1 pin for zero-cross detection. If I use the Analog pins as digital outputs, that lets 3 pins to connect the ethernet module. Most of them use 4 pins, I believe it's SPI. I only have 3 available. Is this possible? Also, I may need a second zero-cross detector, so is it possible with 2 pins then?
Thanks!


texts: Are there any commonly available and supported backlit, monochrome graphic LCDs with more than 128x64 pixels?

texts:
I am currently using a ST7565 graphic LCD for display in a heat pump system.

This LCD has the following characteristics:

128x64 pixels
2.5"x1.5"
monochrome, no greyscale
backlit
good viewing angles
serially connected (i.e. only uses a small number of pins)
high enough refresh rate to show animated icons
low cost (£20)
has a high-quality, maintained library
available from multiple sources for several years

I am finding the resolution of the screen limiting for my application. Ideally I would like a display that is exactly the same but with a higher resolution. Something between

I do not want:

colour (largely as the display is less visible, but also increased cost and code complexity), but red/green/blue on black would be OK.
a physically smaller display (all of the OLED displays are small - 2" and below) as it needs to be visible from a distance

Are there any displays that meet these requirements?

I hope that the specific requirements here mean that this is not a simple "shopping question".


texts: Cannot spin motor 28BYJ-48 with controller board ULN2003APG

texts:
I'm a beginner with Arduino. I managed to grasp the basic understanding and try to use each component/shield that came with my Arduino kit.

I'm unable to use the following component:

Step Motor 28BYJ-48
Step Motor controller board ULN2003APG

I connected the Arduino to the ULN2003APG and put some coding such that I can see that the ULN2003APG's LED turned on from 1, 2, 3, 4, 1, 2, 3, 4, and so on. So this is as expected as per programming below.

My issue:

I noticed the LED in the ULN2003APG is not as bright as a regular
LED.
Once I plugged in the 28BYJ-48 to the ULN2003APG, the ULN2003APG's LED all off.
The motor (28BYJ-48) doesn't spin - at all.
I tried to spin the motor with my 2 fingers, it seems pretty heavy - is this normal?

Is this a faulty ULN2003APG or is it a faulty 28BYJ-48 or is it a faulty programming? please help.

Program:

#include <Stepper.h>

int pin1=8;
int pin2=9;
int pin3=10;
int pin4=11;
int _step=0;
void setup() {
    Serial.begin(9600);
    pinMode(pin1, INPUT);
    pinMode(pin2, INPUT);
    pinMode(pin3, INPUT);
    pinMode(pin4, INPUT);
}

void loop() {
  switch (_step){
    case 0:
      digitalWrite (pin1, HIGH);
      digitalWrite (pin2, LOW);
      digitalWrite (pin3, LOW);
      digitalWrite (pin4, LOW);
      break;
    case 1:
      digitalWrite (pin1, LOW);
      digitalWrite (pin2, HIGH);
      digitalWrite (pin3, LOW);
      digitalWrite (pin4, LOW);
      break;
    case 2:
      digitalWrite (pin1, LOW);
      digitalWrite (pin2, LOW);
      digitalWrite (pin3, HIGH);
      digitalWrite (pin4, LOW);
      break;
    case 3:
      digitalWrite (pin1, LOW);
      digitalWrite (pin2, LOW);
      digitalWrite (pin3, LOW);
      digitalWrite (pin4, HIGH);
      break;
  }
  _step ++;
  if (_step == 4){
    _step = 0;
  }
  Serial.println(_step);
  delay(250);

}


texts:
I was wondering if it is possible to connecting two Arduino boards with each other (Uno + Nano) using an ESP8266 mod on one of them and an nRF24L01 on the other board?

I have seen lots of details of connecting two nRF but couldn't find any about ESP talking to nRF.


texts:
Does anyone know a good IDE for Ipad to write Arduino code and compile it for teensy 3 ?

Answers with different alternatives would be appreciated


texts:
I started one project where i need 4 servos to control 4 grabbers jaws. i use STM32F103C8T6 with arduino IDE for programming it. The motor TZT Micro Servo 9g SG 90. First, I was playing with stepper motors to make them rotate how I want, then I added one servo on the same protoboard where are steppers and drivers for each. I used servo sweep example, and it randomly started twitching and sometimes to spin until power is off. the STM is powered with usb cable from PC. Then i tried other 3 motors and got same result.
Then i put STM on separate protoboard and there connected servo and it was not perfect but it was much stable than on onther protoboard. Then i used old PC power supply which i modified long time ago to have jacks for 12V, 5V and 3,3V, and connected servo to it and it worked normally.
So I started connecting motors 1 by one back to protoboard with other elements and tested them while adding them, first the first one , then added second and tested both, then added 3rd and tested all 3...
First two worked fine, but when i added third, all of them started twitching again, but then it stopped. So i added fourth and now all of them are twitching even if I write in code to rotate only one or two of them, which I don't understand how they can move if I do not give them signal from code.
Here is code for controlling both servo and stepper motors:
#include<Servo.h>

const int stepPin1 = PA4;
const int dirPin1 = PA0;
const int stepPin2 = PA5;
const int dirPin2 = PA1;

const int stepPin3 = PA6;
const int dirPin3 = PA2;

const int stepPin4 = PA7;
const int dirPin4 = PA3;

Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;

void setup() {
  pinMode(stepPin1,OUTPUT);
  pinMode(stepPin2,OUTPUT);
  pinMode(stepPin3,OUTPUT);
  pinMode(stepPin4,OUTPUT);

  pinMode(dirPin1,OUTPUT);
  pinMode(dirPin2,OUTPUT);
  pinMode(dirPin3,OUTPUT);
  pinMode(dirPin4,OUTPUT);

  servo1.attach(PB12);
  servo2.attach(PB14);
  servo3.attach(PA8);
  servo4.attach(PA10);

  //servo1.write(0);
  //servo2.write(0);
  //servo3.write(0);
  //servo4.write(0);
}

void loop() {
  digitalWrite(dirPin1,HIGH);
  digitalWrite(dirPin2,HIGH);
  digitalWrite(dirPin3,HIGH);
  digitalWrite(dirPin4,HIGH);

   //servo1.write(100);
   servo2.write(100);
   //servo3.write(100);
   //servo4.write(100);

  for(int x = 0; x < 200; x++) {
    digitalWrite(stepPin1,HIGH);
    digitalWrite(stepPin2,HIGH);
    digitalWrite(stepPin3,HIGH);
    digitalWrite(stepPin4,HIGH);

    delayMicroseconds(750);

    digitalWrite(stepPin1,LOW);
    digitalWrite(stepPin2,LOW);
    digitalWrite(stepPin3,LOW);
    digitalWrite(stepPin4,LOW);

    delayMicroseconds(750);
  }

  delay(1000); // One second delay

  digitalWrite(dirPin1,LOW);
  digitalWrite(dirPin2,LOW);
  digitalWrite(dirPin3,LOW);
  digitalWrite(dirPin4,LOW);

  //servo1.write(-100);
  servo2.write(-100);
  //servo3.write(-100);
  //servo4.write(100);

  for(int x = 0; x < 200; x++) {
    digitalWrite(stepPin1,HIGH);
    digitalWrite(stepPin2,HIGH);
    digitalWrite(stepPin3,HIGH);
    digitalWrite(stepPin4,HIGH);

    delayMicroseconds(750);

    digitalWrite(stepPin1,LOW);
    digitalWrite(stepPin2,LOW);
    digitalWrite(stepPin3,LOW);
    digitalWrite(stepPin4,LOW);

    delayMicroseconds(750);
  }

  delay(1000);

}

Here is also link to a short video of how the servos are behaving:


texts: Neopixel Painter - Need to change few lines. Not sure where to start

texts:
My name is Maria and I'm learning programing in high school.
I'm working on a birthday present for my mom, want to make a mood light. Using light painter, a neopixel strip, and an arduino.

https://github.com/adafruit/NeoPixel_Painter

I found the part, which reads the bmp line by line a very innovative way to make custom animations.

But some tweaks are needed. (I've tried to make them, believe me, oh I've tried.) So, i was wondering if i can ask someone a favor and teach me how to modify the code (like, comment on parts that been changed.)

Basically, what I want to be changed is, to loop the current bmp until 'next' button is pressed, rather than hold the trigger. Also, I'm not sure if the code try to save power, but it can be disabled since it will run from a power supply.

Here is the part that makes you hold the trigger button (i think)

  for(;;) {
    while(!(TIFR1 & _BV(TOV1)));               // Wait for Timer1 overflow
    TIFR1 |= _BV(TOV1);                        // Clear overflow bit

    show();                                    // Display current line
    if(stopFlag) break;                        // Break when done

    if(++block >= nBlocks) {                   // Past last block?
      if(digitalRead(TRIGGER) == HIGH) {       // Trigger released?
        memset(sdBuf, 0, N_LEDS * 3);          // LEDs off on next pass
        stopFlag = true;                       // Stop playback on next pass
        continue;
      }                                        // Else trigger still held
      block = 0;                               // Loop back to start
    }
    card.readBlock(block + firstBlock, sdBuf); // Load next pixel row
  }

And the complete code: https://github.com/adafruit/NeoPixel_Painter/blob/master/NeoPixel_Painter.ino

Anyway, Since I'm talking to an experts right now, I have this idea to remote control the code! from  another arduino!

My, probably retarded idea is, to run an IR remote code on a second arduion, than when it receives a signal, send a simulated button press to the first ardu playing the bmp! Is that even possible? Just wondering.

Cheers
Maria


texts: How to connect a 12V power supply to an RGB LED strip receiving RGB values via Arduino Uno PWM pins?

texts:
Desired Behaviour

I want to send RGB values from my Arduino Uno PWM pins to an RGB LED strip.

What I've Tried

I've purchased this RGB LED strip and 12V power supply (specs below).

I'm trying to follow this adafruit tutorial but am finding the diagram references unclear.

I've mocked up a diagram but am not sure it would work:

( I haven't used the Vin pin before, so, just to be clear, that is the pin that is connected to the positive line on the breadboard - is that how to transfer the 12V power to the breadboard? )

Questions

01)  Is the above diagram safe and sound?

02)  How do I connect the power supply to the RGB LED strip?

03)  Is it ok to keep the Arduino 'powered' by the USB whilst plugged in to the 12V power (so that it can keep sending the RGB values to the LED strip via the PWM pins)?

04)  I've seen references to grounding the power source, how do I do that?

05)  Are the MOSFETS I have from the Arduino Uno starter kit sufficient for this task?

Printed Text on MOSFET:  IRF520 Y32K BE

MOSFET Datasheet:  Link (IRF520NPbF)

Specifications

RGB LED Strip

LED type:  5050 SMD
Color:  RGB
LED quantity:  300LED
Package:  5 Meter/REEL
Voltage:: 12V DC
Working Power:    14.4W
Working temperature: -20° to 50°
Size: ⌀180mm
Length :  5m
Life Span:    50000+hours
Weight:   0.3kg

Power Supply

Input Voltage: AC 100 - 240V
Output Voltage : DC 12V, 6A
Power : 72 Watts
Connector Size:
External Diameter: 5.5mm
Internal Diameter: 2.5mm


texts: How the light brightness stays constant when we increase the frequency of stroboscope

texts:
Well I am trying to make a Stroboscop. I found this code at blow: and tried. It works normally. But if I increase the RPM so decrease the "strobeDelay" time, the brightness of the LEDs goes out. Even if I try the GreatScott code. The same problem persists at high RPM. I am using power LED.
On the other hand there is a stroboscop which is Fluke 820, it says

Features high-intensity 7-LED array—4,800 Lux @ 6,000 FPM/30cm

How they achieve that constant brightness under the high frequency?
    // Gray text are just helpful comments, you don’t need to type them. :)

/******* -----=====!! EASY STUFF TO MESS WITH !!=====------ ******/

  // What analog pin should we use to read the value from the potentiometer?
  int analogPin = 2; // Yep, you heard right: The coolest of the Analog pins...

  // What pin is the LED connected to?
  int ledPin = 13; // Contains a built in resistor!

  // How much time should the light stay on between delays, in Microseconds (millionths of a second)?
    /* Big number = more blur, more perceived brightness
     * Small number = less blur, less perceived brightness  */
  long onTime = 250;

  // What should the minimum delay be in milliseconds (thousandths of a second)?
  // This sets the bottom delay range of the strobe, as a delay of 0 doesn't actually flash =P
  // The strobe starts with this as the "fastest" mode, and goes slower from there, adding to the delay
  int minDelay = 1; // 1 is the lowest we can actually do without a better delay function

  // What should the maximum delay be in milliseconds?
  // This is the longest time that the biggest potentiometer value will be mapped to, and longest
  // time between strobe flashes.
  int maxDelay = 100;

/******* -----=====^^ EASY STUFF TO MESS WITH ^^=====------ ******/

// Initialize the number to hold our strobe delay. Isn't used till we get to the main loop
long strobeDelay = 0;

void setup() {
 pinMode(ledPin, OUTPUT); // Setup ledPin as an output.
}

void loop() {
  // To make the math easier, we use map(value, fromMin, fromMax, toMin, toMax) to convert the
  // 0 to 1023 range we get from analogRead, into our strobe delay range of 1 to 100 :D
  strobeDelay = map(analogRead(analogPin), 0, 1023, minDelay, maxDelay);

  digitalWrite(ledPin, HIGH); // Switch the ledPin to HIGH, turn it on!
  delayMicroseconds(onTime); // Delay while on, for the given onTime.
  digitalWrite(ledPin, LOW); // Switch the ledPin to LOW, turn if off!
  delay(strobeDelay); // Delay while off, for given strobeDelay.
}

For those who wonder there is a video, but another brand same result, brightness constant even if RPM changes. I tried 2 different power LED. on of them is this, the other LED is I found in a broken projector, I used them 2 working strip. No doubt in your mind, this led strip is very bright at low frequency. Both of them same result like this:


texts: Powering Arduino and L293D with the same Power Supply

texts:
I am relatively new to Arduino and plan to power an Arduino and an L293D Motor Driver with the same 9V power supply as in the diagram below.
I tried to simulate this with Tinkercad, but it seems like Tinkercad always powers the Arduino with an extra USB Cable, so I can't test it with only 1 power supply.
Would the 9V battery power both the Arduino and the L293D in this example?


texts: Trying to connect FT sensor to Arduino Mega using RX TX

texts:
I am trying to interface this sensor, https://www.robotous.com/forcetorquesensor (RTF60-HA01-C), with the Arduino Mega. The sensor has an input voltage of 5Vs and communicates using CAN/RS232/RS422. I am using the RS232 and have connected wires properly and have tried to establish Serial Communication using the below code.

#include<String.h>
# define BuffSize 32

byte buff[BuffSize];
unsigned char data_field[16];
byte comm[11]  = {0x55, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAA};
// SOP == 0x55, EOP == 0xAA, Checksum == summation of each data in data_field
void setup() {

  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial2.begin(115200);
  for (int i = 0; i < BuffSize; i++) {
    buff[i] = 13; //Number to initialise buffer
  }

}

  void loop() {
    // put your main code here, to run repeatedly:

     Serial2.write(comm, 11);
    //Serial.println(Serial2.available());
    if (Serial2.available() > 0) {
      //int read = Serial2.readBytes(buff, BuffSize);
        String output = "";
        for(int i=0;i<BuffSize;i++){
        buff[i]=Serial2.read();
        output = output + buff[i] + "|";
     }
  //Serial.println(read);
    Serial.flush();

    Serial.println(output);
    Serial.println();

    }
  }

The output I receive is just 0s and the occasional 10. Like below

0|0|0|0|0|0|0|0|10|0|0|0|0|0|0|0|0|10|0|0|0|0|0|0|0|0|10|255|255|255|255|255|

I am new to this and hope this is not a stupid question.
Let


texts: How to send information from a web-site to the arduino?

texts: I currently have an Arduino Mega + an Arduino Ethernet shield, I would like to know if it's possible to send data to the arduino from a web-site hosted on the shield itself. So that when someone press a Button on the web-site it sends a signal to the arduino to trigger an action. Could anyone kindly help me.


texts: Motor Shield not giving full power, LED DIMS

texts:
I have an Adafruit Motor Shield, the V1. I have been using this thing with my OPSEPP Uno and a stepper motor with no issues. (Powered by 12v DC wall wart [CASIO]).

My question, or issue, not sure yet, is this:

Why when I connect my motor directly to the 12v power supply it operates efficiently (for my purposes) and when I run it through my Arduino with the Adafruit Motor.h library does it not power the same.

Basically on direct connection it works fine, but I want to be able to regulate the connection and reverse it, change the speed, etc.

It is possible I am utilizing the library or the board wrong.

Can someone indicate why the power or, torque seems to drop when through the board. I have tried all KHZ all speeds etc, no way to get the same 12v power directly and modulate it?


texts: How to measure the supply voltage of Arduino without using an analog pin

texts:
I'm using Arduino Nano to measure temperature with a 10 kohm thermistor and a voltage divider. My problem is I'm getting only 4.2V on the 5V pin. The power is supplied via a USB cable from a desktop PC.

I measured the output voltage of a USB port on the PC and it was around 4.5V. It doesn't look normal. So I suspect the power supply unit of the PC is not strong enough.

But it still makes sense to measure the voltage at the 5V pin since there is no guarantee it's exactly 5V. Its error will affect the calculated resistance of the thermistor. So I got it by connecting the pin directly to the A1 pin.

On the other hand, it seems to me Arduino internally and digitally knows the value of the supply voltage. So it would be faster and easier to get it rather than using the A1 pin. But I don't know how to do it.

After searching on the Internet, I could find only these things which didn't help me much.

voltage level - What are the 5V and VIN pins for? - Arduino Stack Exchange
voltage level - Getting 3.3v on 5v pin in Arduino Uno - Arduino Stack Exchange

I also considered using an external power supply, say 9V to the VIN pin but I don't feel like doing that much.

How can I measure the supply voltage of Arduino without using an analog pin?


texts:
I was wondering if there are a way to do a menu system for arduino UNO using buttons and without libraries.

I tried to do it by myself but the code was too long and heavy.

I don't want full code, just a pseudo-code idea and how does it works.

I know there are libraries that to this, but I want to practise C++.

Thanks!


texts:
I was trying to find out how this library can run multiple stepper motors at the same time, and I saw this important function called...
void AccelStepper::setOutputPins(uint8_t mask)
{
    uint8_t numpins = 2;
    if (_interface == FULL4WIRE || _interface == HALF4WIRE)
    numpins = 4;
    else if (_interface == FULL3WIRE || _interface == HALF3WIRE)
    numpins = 3;
    uint8_t i;
    for (i = 0; i < numpins; i++)
    digitalWrite(_pin[i], (mask & (1 << i)) ? (HIGH ^ _pinInverted[i]) : (LOW ^ _pinInverted[i]));
}

why is it using uint8_t? and what is a mask? and Is this line:
digitalWrite(_pin[i], (mask & (1 << i)) ? (HIGH ^ _pinInverted[i]) : (LOW ^ _pinInverted[i]));

sending a step signal to multiple stepper?


texts: Difference between these two NodeMCU boards?

texts:
I recently received a NodeMCU (identical to the one shown in the first picture below) and originally, I was unable to connect it to my computer which eventually turned out to be driver issues; however, during my initial panic, I found that there seems to be two variations of the NodeMCU board.

As you can see from the pictures below, at first glance there seems to be no difference to the boards, however, some of the more noticeable differences are that the first one has only one "orange" chip whereas the second one has two. Moreover, the first one has a large square chip towards the USB port wheareas the second seems to have a rectangular one.

First one:

Second one:

I would really appreciate if someone could enlighten me to what these small differences are between the two boards are and also what are the implications of these differences (if there are any).

Thank you in advance for any help,

Kind regards,
John


texts:
I've been using Arduino UNO for quite sometime and brought a new Arduino Nano. When I connected it to my computer, the power usb lit up and the blink sketch started running ( as expected of course).

Now I opened up the IDE and switched boards. But when I try to upload code to my Nano I get an error-

  avrdude: ser_open(): can't open device "\.\COM3": The system cannot find the file specified.

Clearly the IDE can't see my board. Uploading to my UNO goes fine. The serial port option is greyed out so I can't change it.

I have searched extensively online for a solution and have found none. This must be either a very unique issue or a very simple one.


texts:
I'm trying to use CTC mode on Arduino 1 but I have the following problem.
I need to generate an interrupt on threshold B and A and I have set the prescaler to 1 since I want to generate interrupt A at 15999 (correspond to 1ms) and interupt B at 15( ie a number small enough from the start of counting).
I'have write a println function in ISR(A and B) to proof the calling of the latter but the program does not print all the characters in the println function and furthermore the counter does not reset at treshold A but stop his work.
How I can resolve the problem?

Here is the program I wrote:

void setup() {
    TCCR1A = 0x00;                // No outputs on compare math, no PWM mode
    TCCR1B = 1 | (1 << WGM12);    // Enable CTC mode up to OCR1A and prescaler /1 -> Start
    //TCCR1B = 0b00001001;
    TCCR1C = 0x00;                // Nothing to set into C register

    OCR1A = 15999;                // Set Threshold A
    OCR1B = 15;                // Set Threshold B
    TCNT1 = 0;                    // Clear Counter

    TIFR1 = (1 << OCIE1A) | (1 << OCIE1B);    // Clear Interrupt flag Match A and B

    TIMSK1 = (1 << OCIE1A) | (1 << OCIE1B);   // Enable Interrapt flag Match A and B

    analogRead(A0);            // Dummy Read to make Arduino setting the AD
    ADCSRA |= (1 << ADIE);     // Enable AD Interrupt on conversion completed
    ADCSRB = 5;                // Select Timer 1 Match B as trigger
    ADCSRA |= 1 << ADATE;      // Enable Auto trigger

    Serial.begin(115200);      // Initialize the USART
    Serial.println("Start");   // Write the welcome message

}

void loop() {
    // Nothing to do
}

ISR(ADC_vect)
{
    Serial.print(TCNT1);
    Serial.print(" - ADC Conversion Completed (");
    Serial.print(ADC);
    Serial.println(")");
}

ISR(TIMER1_COMPA_vect)
{
    TCNT1=0;
    Serial.print(TCNT1);
    Serial.println(" - Interrupt A");
}

ISR(TIMER1_COMPB_vect)
{
    Serial.print(TCNT1);
    Serial.println(" - Interrupt B");
}


texts: Why is arduino Mega2560 taking so much time to recognise the pin is no longer at HIGH?

texts:
I am in my first arduino steps. I have a Mega2560R3 I wrote this code

const byte D0 = 22;
const byte D1 = 24;
const byte D2 = 26;
const byte D3 = 28;
const byte D4 = 30;
const byte D5 = 32;
const byte D6 = 34;
const byte D7 = 36;

void setup() {
  Serial.begin(115200);
  Serial.write("Started");
  pinMode(D0, INPUT);
  pinMode(D1, INPUT);
  pinMode(D2, INPUT);
  pinMode(D3, INPUT);
  pinMode(D4, INPUT);
  pinMode(D5, INPUT);
  pinMode(D6, INPUT);
  pinMode(D7, INPUT);
}

void loop() {
  byte data;
  data = read_dataline();
  Serial.println(data);
  delay(100);
}

byte read_dataline() {
  byte val;
  noInterrupts();

  val |= (digitalRead(D0) == HIGH ? 0x1 : 0x0);
  val |= (digitalRead(D1) == HIGH ? 0x1 : 0x0) << 1;
  val |= (digitalRead(D2) == HIGH ? 0x1 : 0x0) << 2;
  val |= (digitalRead(D3) == HIGH ? 0x1 : 0x0) << 3;
  val |= (digitalRead(D4) == HIGH ? 0x1 : 0x0) << 4;
  val |= (digitalRead(D5) == HIGH ? 0x1 : 0x0) << 5;
  val |= (digitalRead(D6) == HIGH ? 0x1 : 0x0) << 6;
  val |= (digitalRead(D7) == HIGH ? 0x1 : 0x0) << 7;

  interrupts();
  return val & 0xFF;
}

To test it, I took a jumper cable and connected the 5V line with the appropriate pin. What I saw was the following:

the number produced on the serial monitor is correct, but as soon as I unplug the jumper cable, the value lingers for a few iterations, instead of going immediately to zero.
the value is very noisy and it can produce random values just by rubbing my finger over the board.

Why is that?


texts: Can I reuse crystal frequency of Arduino?

texts:
If I use some IC which requires clock frequency like 16MHz, can I take one from Arduino?

Or this it too high frequency to travel to neighboring board?


texts: Link Arduinos over 5 acre laser tag field

texts:
I am building a laser tag system with an Arduino in each gun.

I want the guns to be linked during game play for many different reasons:

Start/Stop game
Nearby teammates
When a flag is captured
etc.

I don't know how to link the guns to one another during game play because the field may be large (e.g. a park). Wifi has too short of a range, cellular would cost, linking to a phone via bluetooth would drain the phone battery (and require each player have a smart phone to play).

Can you think of another way to link the guns? Radio transmitters?

Thanks!


texts: How to get 3v3 pins on Arduino Mega Sensor shield v2.0?

texts: I am using Arduino mega and a sensor shield (picture attached below). I need to connect three different wires to 3.3 V input. Can anybody suggest how can I achieve the same? What voltage do the VCC pins of all digital and analog pins on the sensor shield have?


texts: I used the example code AnalogReadSerial and tried it on all analog pins from A0 to A7. None of the analog pins were connected to anything so I expectedy to get 0 in the serial monitor. But as it turns out, I was wrong. Only pin A7 shows 0 to 19 values on the serial monitor. The rest have values ranging from 100 to 300 for pins A2, A3, A4, A5 and A6. The worst performers are A1 and A0 with values from 921 to 1023 showing on the serial monitor. What is the cause of this and how will I fix it?


texts: Sound or motion activated long term battery powered Arduino

texts:
Basically, I want an Arduino to power up whenever a "creature" enters viscinity (at least within up to 3 meters).

I would really like this to be able to keep monitoring for at least 4-8 weeks, without having to replace batteries. I don't want to use more than 1 or 2 18650 Liion cells.

Couple of methods that I believe would work:

Changes in light-conditions.
Sound.
Small vibrations in the ground.

Approaches to conserve power:

Checking for changes in light at most every 30 seconds (boot the Arduino, and power off quickly).
Checking for 1 second for sound, every 10-15 seconds.
Vibrations in the ground using an accelerometer?

The ideal solution does not run the Arduino at all, unless a trigger causes it to run. When the Arduino starts, it will have to turn itself off again to resume monitoring mode.

What approach should I go for? I'm not very good with electronics, and would like to avoid configurations involving transistors, resistors and so on - unless stricktly required.

Is it possible/easy to wire an Arduino Pro Mini to run directly off a 3.7 V battery, bypassing any power hungry voltage regulators?


texts:
I bought a few PFC8574 and 4x4 keypads for a small project. I'm unclear on the correct wiring of the keypad to the PFC8574.

On the Arduino Playground's site, there are pull-up resistors for each column, but on a few other sites (like this one that I can't read, but I understand a schematic and there's a third example too, but I don't have the reputation to post it), the wiring does straight into the IC.

Does it depend on the library that's being used?  Or what am I missing?

Thanks!


texts: How Programing the nodeMCU Through OTA using GPRS?

texts:
How Programming the nodeMCU Through OTA using GPRS?

Hi Everyone I need big help.

Actually, I m using NodemCU one of my project. the setup in Remote location, that place dont have a wifi option so I m using GPRS (GSM SIM800V)
for sensor data collection to my server. right now I need to update my new firmware to that NodeMCU.

is it possible do a OTA using GPRS (GSM SIM800V)?

plz help for this.

Thanks in advance.


texts: Connecting (SD or HD) TV screen to Arduino

texts:
I had a thought about making myself an arcade cabinet. I found a nice cheap and sturdy 8 directional arcade joystick online, and now I'm thinking about the possible ways of displaying graphics.

I would like to know how can I send graphical data to a large screen using Arduino. When I was researching this I saw "TV Text" library that allows sending PAL and SECAM signals, but that's not the "modern" way. Is there a way of using DisplayPort or HDMI to simply use a cheap used PC monitor? Maybe there are other protocols that I can use? I'm looking for a "cheap" way to create a display that's physically as large as screen of arcades from "the good old days".


texts:
My Arduino Uno is powered by 9v battery to run 2 ultrasonic sensors (HC-SR04) and a buzzer.
I intend let the circuit run for at least a week.
Is there a solution to reduce power consumption / increase battery life?
I am open to hardware and software solutions.
Thanks!


texts:
For a project I need to use an industrial stepper driver with an arduino. There it is: http://www.omc-stepperonline.com/bipolar-stepper-motor-driver-max-4a-current-40vdc-input-16-subdivision-st6600-p-246.html

The motor: https://prototypes.haydonkerk.com/ecatalog/hybrid-linear-actuators/en/linear-actuator-57F42-3.25-099#

I'm not familiar with this driver, so can I use it with the Arduino Stepper Library?

I didn't see a lot of tutorial for this driver compared to many other popular driver.

Thanks!


texts: How to interface OV5640 to Arduino Mega using Embedded C?

texts:
I am trying to interface a OV5640 camera module to Arduino Mega 2560 in Eclipse IDE using C language . However I am not able to figure out the registers that need to be initialised , for the camera to start capturing pictures .

There are Arduino libraries to deal with setup and image transfer , however I do not wish to use them . I would like to code in C , without using any library . I just need to know which registers need to be accessed and modified to get the camera working .

For reference - I am trying to create a CCTV based system that will record picture based on intruder presence . The entire project is written in C language without any libraries .

Data sheet for OV5640 -https://cdn.sparkfun.com/datasheets/Sensors/LightImaging/OV5640_datasheet.pdf

Take a look in this link to get an idea about the kind of program it'll be.
How to get 38 Khz clock from Timer 0/2 in Arduino Mega 2560?


texts: ESP8266 (ESP-01) Not booting with load on IO pin 2

texts: I'm using an ESP-01 to control a load (SSR), which is connected to IO pin 2. This pin needs to be HIGH at boot time, otherwise the module won't boot. I've tried driving the load with an optocoupler to avoid driving the pin LOW while booting, but it's not working. Do you know of any solution to make it boot correctly without changing the IO pin? (there's only two GPIO pins, both ocuppied, plus serial port pins).


texts: Johnny-five driving LCD Matrix or call Arduino library from Johnny-five

texts:
I would like to know if it's possible to drive an LED Matrix like this one with johnny-five.
If not, how can i call Arduino library/code from johnny-five.

If I Write method on sketch into the Arduino, can I call them from J5 REPL?


texts: How can my library source code instantiate an object from another library?

texts:
I'm having trouble explaining my issue. What I'm doing is creating a library to work easily with the RFID reader/writer RC522 module. I need to create an object of the library MFRC522 in my .cpp file to be able to communticate with the module itself. I want my constructor end up like this:UltimateRFID rfid(53, 5);, the parameters being the slave select and the reset pins, respectively.
The problem is that I don't know how to make my constructor so that it is within the scope of the functions that require the MFRC522 object to be called. Below's my code.

#include "Arduino.h"
#include "UltimateRFID.h"
#include <MFRC522.h>

MFRC522::MIFARE_Key key;

UltimateRFID::UltimateRFID(int ss, int rst)
{
   MFRC522 mfrc522(ss, rst); //this would be ideal, but how can my functions access the instance?
}

void UltimateRFID::initialize() //sample of a function that uses the MFRC522 object
{
  //digitalWrite(49, HIGH);
  digitalWrite(2, LOW);
  for (byte i = 0; i < 6; i++) {
    key.keyByte[i] = 0xFF;
  }
  mfrc522.PCD_Init();
  if ( ! mfrc522.PICC_IsNewCardPresent())
  {
    return;
  }
  if ( ! mfrc522.PICC_ReadCardSerial())
  {
    return;
  }

}

Now comes my header file, although I'm not sure it matters much.

#ifndef UltimateRFID_h
#define UltimateRFID_h

#include "Arduino.h"
#include <MFRC522.h>

class UltimateRFID
{
  public:
    UltimateRFID(int ss, int rst);
    void initialize();
  private:
    MFRC522::MIFARE_Key key;
};

#endif

Please be patient, it's my first library.


texts: How to burn bootloader into arduino uno without using another arduino

texts: I need to bootload my Uno board but I do not have another Arduino at my disposal so how do I bootload without another Arduino board


texts: Button not working - Arduino Due project (MiniEngine v2)

texts:
I am building Arduino Due based project called MiniEngine v2 (an open-source motion control software for timelapse photography).

The project is not very active anymore but there are still all the documentation at github. Project owner had webshop where he sold MiniEngine shields for arduino but they are not available anymore. There was gerber files available at project github page so I orderer PCB's form seeed.com.

Project's Github page is at:
https://github.com/airiclenz/miniEngine2

Everything seems to work ok but one of the buttons is not working. There is only 2 buttons and one rotary encoder.

I think the reason why the button is not working is that the output voltage for button from 74HC14N (hex smith trigger) is too low (I am not very good at electronic so I might be totally wrong.

I tried to measure values with voltage meter and here is the result what I got for those two buttons:

Here are the values in written format ( I took measurement from SN74HC14N )

btn_2 (pin9 input, pin8 output)
btn_1 (pin11 input, pin10 output)

SETTINGS BUTTON (btn_2) -> this one works fine

1) button up  - metering from input pin 11 => 3.26
2) button down -metering from input pin 11 => 0
3) button up - metering from output pin 10 => 0.6
4) button down - metering from output pin 10 => 2.38

START/BACK BUTTON (btn_1) -> this one does not work

1) button up  - metering from input pin 9 => 3.26
2) button down - metering from input pin 9 => 0
3) button up - metering from output pin 8 => 1.43
4) button down - metering from output pin 8 => 1.53

Here is how the buttons are initialized:

    void input_init() {

  // set pin modes
  pinMode(PIN_ROTARY_PRESS, INPUT);
  pinMode(PIN_KEY_1, INPUT);
  pinMode(PIN_KEY_2, INPUT);

  // attach interrupts for the keys
  attachInterrupt(PIN_ROTARY_PRESS, input_interrupt_keyRotary_press,  RISING);
  attachInterrupt(PIN_KEY_1,        input_interrupt_key1,             RISING);
  attachInterrupt(PIN_KEY_2,        input_interrupt_key2_press,       RISING);

  // attach interrupts to both encoder pins for every state change
  attachInterrupt(PIN_ROTARY_A,     input_interrupt_rotary,           CHANGE);
  attachInterrupt(PIN_ROTARY_B,     input_interrupt_rotary,           CHANGE);

  // set the initial rotary values & configurations
  rotary.setPosition(0);
  rotary.setKeyMode(true);
  rotary_old_pos = 0;
}

And here is function for btn_1 press that is never called (except once in powering the shield/arduino due)

void input_interrupt_key1() {

  if ((key_1_time + DEF_INPUT_DEBOUNCE) < millis()) {

    key_1_time = millis();
    setBit(input_status, BIT_2);

  }
}

I can only use 2 links in posts (I do not have 10 reputation) so you can find the code for inputs at Github (link above). (folder MiniEngine2/Software/miniEngine2/mE2_input.ino)

All code files are at Sotfware at folder: MiniEngine2/Software/miniEngine2

I have put Serial.println command in code and nothing is printed when btn_1 is pressed. When I plug power on then the btn_1 is triggered once...

Here is link to the the schematic for that shield ( it is quite big so that's why I did not embed the photo):

Schematic for shield is at Github folder : Hardware/miniE shield v2 revB BED board - schematic.pdf

Here is also link to the video where you can see how I took the measurements:
https://youtu.be/wFR7P65qMGA

Please ask if I need to provide more information...


texts:
Is anyone aware of an Arduino library for smoothly controlling a servo?

I have an especially fast servo, which is trivial to control using Arduino's built-in Servo library. However, the library doesn't support proportional control. You specify a position, and the servo immediately goes to that position as fast as it can. With my servo, that creates incredibly fast jerky motion.

I've found some algorithms for interpolating a smooth servo motion by generating small incremental changes to the signal over time. I've been able to translate this to some Arduino code, and although the motion is much slower, it's still very jittery.

I've search for pure Arduino implementations, but I've not found anything. Does anyone know of an implementation? I find it hard to believe no one else has faced this type of servo control problem with an Arduino before.


texts:
This what I have learned :

digital inputs and outputs

Analog inputs and outputs

Line follower ir sensor

Pir sensor

Ultransonic sensor

Ir transmitter and reciever

Lcd

Key pad

Dc motor

Stepper motor

Servo motor

Interrupts

Timers

Watchdogs

 Arduino with raspberry pi

This topics a made with it some projects so the question is what is next to learn about arduino ? What should be my next steps ??


texts: WiFi101 Client HTTP POST fails after 3rd request

texts:
I would really appreciate any help, my home project has been put on hold for weeks as I haven't been able to figure this out. In a nutshell, I'm connecting to my wifi network, measuring temperature from a sensor, and sending that temperature data to a server via a HTTP Request. All of that stuff works.

I have it in a loop, and on the 3rd HTTP request I get 'Connection Failed' when it's trying to client.connect(server, 80) - I don't understand why it fails. I've tried adding client.stop() and client.flush() after each HTTP request, but nothing fixes it. Below is my sketch file with some of the temperature code removed to make it easier to read

#include <SPI.h>
#include <WiFi101.h>
#include <string.h>
#include <stdlib.h>
#include <OneWire.h>
#include <DallasTemperature.h>

//WiFi Client Setup
char ssid[] = "HIDDEN";    //  your network SSID (name)
char pass[] = "HIDDEN";       // your network password
int status = WL_IDLE_STATUS;    // the WiFi radio's status
char server[] = "HIDDEN";
WiFiClient client;

// Setup for temperature sensor
#define ONE_WIRE_BUS A5
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer;

void setup() {
  Serial.begin(9600);
  WiFi.setPins(8,2,A3,-1);
  while (!Serial) {
    Serial.println("Waiting for serial");
  }

  //Connect to wifi shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    while (true);
  }
  wifiConnect();
  sensors.begin();
}

void loop() {
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }
  /*
  Code to get temperature here
  */
  httpRequest(temp);
  delay(10000); // 5min
}

void httpRequest(String temp) {
  String request = "POST /api/webhooks/temp?temperature=" + temp + " HTTP/1.1";

  // if there's a successful connection:
  if (client.connect(server, 80)) {
    Serial.println("connected to server");
    client.println(request);
    client.println("Authorization: Token HIDDEN");
    client.println("Host: HIDDEN");
    client.println("Connection: close");
    client.println();
  }
  else {
    Serial.println("Connection failed");
  }
}

void wifiConnect() {
  //Attempt to connect to WiFi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    status = WiFi.begin(ssid, pass);
    delay(1000);
  }

  Serial.println("You're connected to the network");
}


texts:
I've got an Arduino Uno and two Sparkun's Monster Motor Shields.
The aim is to control 4 motors.

There is no problem to control 2 DC motors with single motor shield. There's a manual on how to do it .

But how can I control all of motors (address commands to each of them) when I stack motor shields one on one?

Thanks in advance.


texts:
After building a working prototype with a breadboard, I was wondering what's next.
So I read about integrating the arduino into a PCB layout.

But in my case, it's worth it?

My project will use a Arduino Mega, futhermore some wired piezo switches therefore I need pcb connectors, and a small amount of resistor and transistors.
I am considering to buy a Mega of the shelf and use the contactpins on a header to fix it on my PCB. Also probably fix it with some screws.

It will save me a lot of pcb design time (a maybe some mistakes) and it will save me buying all diferent components. The  ATMega2560 alone is already around 10,-

I think I only need 10 or 15 pcb's, definitly no massproduction.

Your opinions...


texts: SIM808 module: GSM location command (AT+CIPGSMLOC=1,1) giving wrong value after execution of sending message command (AT+CMGS=+91xxxxxxxx)

texts:
I wrote the code that if an interrupt is generated, get GSM location and send a  message.

The first time the interrupt is generated, I got the correct GSM location using AT+CIPGSMLOC=1,1 and successfully sent a message using the AT+CMGS=+91xxxxxxxxcommand.

But the next time an interrupt was generated, AT+CIPGSMLOC=1,1 gave a wrong location. When I commented out the code to send a message, on every interrupt generated I am getting the correct GSM location. So it seems like the problem is occurring after sending a message. But I have no clue what exactly is going wrong. Following is my code.

Note: on restarting the module, I'm again getting the correct location the first time, before sending a message.

void setup() {
  mySerial.begin(9600);
  Serial.begin(9600);
  while (!Serial) {
  }
  // initialize the pushbutton pin as an input:
  pinMode(sensorPin, INPUT);
  // Attach an interrupt to the ISR vector
  attachInterrupt(0, pin_ISR, FALLING);
}

/////////***GSM RESPONSE***///////////
String DisplayGSMResponse() {
  if(mySerial.available()) {
    String gsm_input="";
    while(mySerial.available()) {
      gsm_input+= (char)mySerial.read();
    }
    gsm_input.trim();
    delay(1000);
    Serial.println(gsm_input);
    return gsm_input;
  }
}

void SendMessage(String mobNum,String Location) {
  Serial.println("Sending message..");
  mySerial.println("AT+CMGF=1");
  //Sets the GSM Module in Text Mode
  delay(2000);
  // Delay of 1000 milli seconds or 1 second
  DisplayGSMResponse();
  mySerial.println("AT+CMGS=\""+mobNum+"\"\r");
  // mobile Number
  delay(4000);
  DisplayGSMResponse();
  cleanBuffer();
  mySerial.print("test");
  // The SMS text you want to send
  delay(100);
  mySerial.println((char)26);
  // ASCII code of CTRL+Z
  delay(8000);
  DisplayGSMResponse();
}

void gprsInit() {
  if (isGPRSInit) {
    return;
  }
  Serial.println("GPRS INITIALIZING");
  mySerial.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");
  delay(2000);
  DisplayGSMResponse();
  mySerial.println("AT+SAPBR=3,1,\"APN\",\"INTERNET\"");
  delay(2000);
  DisplayGSMResponse();
  mySerial.println("AT+SAPBR=1,1");
  delay(8000);
  DisplayGSMResponse();
  mySerial.println("AT+SAPBR=2,1");
  delay(2000);
  DisplayGSMResponse();
  isGPRSInit = true;
}

void gprsterm() {
  mySerial.println("AT+SAPBR=0,1");
  delay(1000);
  DisplayGSMResponse();
  isGPRSInit = false;
}

String getGPS() {
  Serial.println("GETTING GPS LOCATION");
  String loc = "";
  String location = "";
  mySerial.println("AT+CIPGSMLOC=1,1");
  delay(3000);
  loc = DisplayGSMResponse();
  return location;
}

void loop() {
  if (buttonState == 1) {
    detachInterrupt(0);
    gprsInit();
    location = getGPS();
    SendMessage(mobileNumber, location);
    gprsterm();
    Serial.println("location = " + location);
    buttonState = 0;
    location = "";
    attachInterrupt(0, pin_ISR, FALLING );
  }
}

void pin_ISR() {
  buttonState = 1;
  Serial.println("interrupt");
}

EDIT: added gprsterm function.

Note: I removed the interrupt and called the code inside the loop function twice. The first time I got a correct result. The second time a wrong result. So it seems like the interrupt is not be causing the problem.

EDIT2:
One interesting thing I found is that at my home it is showing correct results every time, but in the office it is showing a wrong location on second location call i.e after the SMS was sent and we get the GSM location using AT+CIPGSMLOC=1,1.


texts: Arduino configure script for conditional compilation of libraries

texts:
I have a library the uses conditional compilation based on the preprocessor variables. The library is a separate .cpp object file with a header.

How can I pass preprocessor variables to the compilation of the library? Standard #define in a sketch file wouldn't work, since their live will be limited to my sketch object file(s), not the library's.

Normally it is solved by the ./configure script and/or the custom make process. How can I do it on Arduino?

Supplying a separate compilation/source code of the library for all 2^8 combinations of the preprocessor switches doesn't seem feasible...


texts: how to get live view of esp32cam at remote sever using ssh tunneling?

texts:
I have found many projects involving esp32cam, but in all projects video is being seen on local server only.For its of no use.As for a home security project user can view the video at remote location like MI robotic camera.

Also i do not want any port forwarding or tunneling service from a third party like www.nabto.com, www.ngrok.com etc.


texts:
I just plugged my arduino and click upload, it shows this error:

Arduino: 1.8.5 (Windows 7), Board: "Arduino/Genuino Uno"

Sketch uses 948 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
avrdude: ser_open(): can't open device "\\.\COM1": The system cannot find the file specified.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

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


texts:
I Need a help in this code

I am trying to assign the serial.write(OutData[i]) to byte data[]. Can anyone help me assign it.

Here is my code

#define ECHOPIN 11// Pin to receive echo pulse
#define TRIGPIN 12// Pin to send trigger pulse
int distance=0;
 byte OutData[] = {0x05, 0x03, 0x04, 0x43, 0x65, 0xBA, 0x7D, 0x04, 0xE8};
#include <Crc16.h>
Crc16 crc;
void setup()\
{
  Serial.begin(9600);
 pinMode(ECHOPIN, INPUT);
  pinMode(TRIGPIN, OUTPUT);
  digitalWrite(ECHOPIN, HIGH);
}
void loop() {
digitalWrite(TRIGPIN, LOW); // Set the trigger pin to low for 2uS
  delayMicroseconds(2);
  digitalWrite(TRIGPIN, HIGH); // Send a 10uS high to trigger ranging
  delayMicroseconds(10);
  digitalWrite(TRIGPIN, LOW); // Send pin low again
  distance = pulseIn(ECHOPIN, HIGH,26000); // Read in times pulse
  distance= distance/58;
  Serial.print(distance, HEX);
   OutData[3] = 0x00;

  OutData[4] = 0x00;

  OutData[5] = 0x41;

  OutData[6] = distance;
for (int i = 0; i <= sizeof(OutData); i++) {

    Serial.write(OutData[i]);

    byte data[] = OutData[i];
    crc.clearCrc();
  for(byte i=0;i<9;i++)
  {
     Serial.print("byte ");
     Serial.print(i);
     Serial.print(" = ");
     Serial.println(data[i]);
     crc.updateCrc(data[i]);
  }
  unsigned short value = crc.getCrc();
  Serial.print("crc = 0x");
  Serial.println(value, HEX);

  Serial.println("The crc Check of the byte array");

  //Modbus
  value = crc.Modbus(data,0,9);
  Serial.print("Modbus crc = 0x");
  Serial.println(value, HEX);

  while(true);
}
int calcrc(char *ptr, int count)
{
    int  crc;
    char i;
    crc = 0;
    while (--count >= 0)
    {
        crc = crc ^ (int) *ptr++ << 8;
        i = 8;
        do
        {
            if (crc & 0x8000)
                crc = crc << 1 ^ 0x1021;
            else
                crc = crc << 1;
        } while(--i);
    }
    return (crc);
}

My Error is :

C:\Users\system3\AppData\Local\Temp\arduino_modified_sketch_307616\sketch_dec13a.ino: In function 'void loop()':

sketch_dec13a:34:25: error: initializer fails to determine size of 'data'

     byte data[] = sizeof(OutData);

                         ^

sketch_dec13a:34:25: error: array must be initialized with a brace-enclosed initializer

sketch_dec13a:60:1: error: a function-definition is not allowed here before '{' token

 {

 ^

sketch_dec13a:77:1: error: expected '}' at end of input

 }

 ^

Multiple libraries were found for "Crc16.h"
 Used: C:\Users\system3\Documents\Arduino\libraries\Crc16-master
exit status 1
initializer fails to determine size of 'data'


texts: Does DFR0063 I2C LCD work with Arduino Due? I cannot even pass i2C scanner

texts:
I have 2 Due and Two DFR0063 I2C LCD.  I cannot even pass i2C scanner.
I always got No I2C devices found.  I tried both SCL/SDA and SCL1/SDA1. For SCL1/SDA1, I do add 10K pull up resister. But still not work.
I notice most of example is using Arduino Uno not Due.  So I wonder maybe they just not work together.
I actually just need any Chelp I2C device work smoothy with DUE not other board.
Anyone recommend any goof I2C device for DUE?

Thanks

Joseph