texts:
I'm having this weird effect where my NeoPixel will blink/glitch after every cycle of a fading sketch. I'm not certain whether the issue is hardware or in my code. The blinking only occurs during the if statement portion of the code and not during the else statement which blinks red. I have tried multiple sources of power, 5V 2amp, 9V 1 amp, 12V 1amp and a Mac Usb and the problem persists on each power supply.

Any suggestions or ideas would be greatly appreciated.

#include <Adafruit_NeoPixel.h>
#include <DistanceGP2Y0A21YK.h>

#define PIN 6
#define PIXEL 16

Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL, PIN, NEO_GRBW + NEO_KHZ800);

DistanceGP2Y0A21YK Dist;
int distance;
int R = 0;
int G = 0;
int B = 0;

void setup() {
  strip.begin();
  strip.show();
  strip.setBrightness(127);

  Serial.begin(9600);
  Dist.begin(A0);
}

void loop() {
  distance = Dist.getDistanceCentimeter();
  Serial.print("\nDistance in centimers: ");
  Serial.print(distance);
  delay(2); //make it readable

  if (distance > 10) {

    for (R && G && B; R < 150 && G < 150 && B < 150; R++ && G++ && B++) {
      for (int i = 0; i < strip.numPixels(); i++) {
        strip.setPixelColor(i, strip.Color(R, G, B));
        strip.show();
        delay(1);
      }
      delay(2);
    }

    // fade off
    for (R && G && B; R > -1 && G > -1 && B > -1; R-- && G-- && B--) {
      for (int j = 0; j < strip.numPixels(); j++) {
        strip.setPixelColor(j, strip.Color(R, G, B));
        strip.show();
        delay(1);
      }
      delay(1);
    }

  } else {

    for (int j = 0; j < 256; j++) {
      for (int i = 0; i < strip.numPixels(); i++) {
        strip.setPixelColor(i, strip.Color(255, 0, 0));
        strip.show();
      }
      delay (1);

      //blink off
      for (int j = 64; j > 0; j--) {
        for (int i = 0; i < strip.numPixels(); i++) {
          strip.setPixelColor(i, strip.Color(j, 0, 0));
          strip.show();
        }
        delay (2);
      }
    }
  }
}


texts: Int64_t aka long long acts as int32_t and overflows at 2^31

texts:
I have an int64_t variable. When I add another int64_t variable

and convert it to a double to print it on the serial monitor, it acts as if it was a int32_t variable. This is the program:

int64_t a = 1 << 31;
double b = static_cast<double>(a);
Serial.println(b);

The output on the serial monitor is -2147483648.00.

What is going on?


texts:
I have 2560 mega, and I Want to generate 3-phase PWM signal at 62.5khz, synced and shifted 120 degrees apart.

I need that for 3-phase split-coil boost converter (or even isolated flyback converter), with 3 phase transformer coupled inductor. So I dont need sine wave table like here, but actually, a direct square wave PWM output, from 3 synced digital pins, with chosen duty cycle. How can I do that?


texts: Speed of built in DAC/ADC in Arduino Due

texts:
Can someone tell me how fast the built in DAC (and ADC) in an Arduino Due can be written or read? I currently don't have the equipment to measure but need the information to plan my next steps.

I try to move galvanometer mirrors and want to make the voltage/position updates as small as possible. How fast are the internal DACs compared to an SPI connection (where I have to write 2 Byte).


texts: Communication between Arduinos using USB Host Shield

texts:
I'm working on a project that needs to use USB to pass serial messages between Arduinos (I can't use I2C or SPI for a few reasons – I especially need USB's support for hot-swapping and address allocation). So far I have the USB Host Shield set up on one Arduino Uno, connected to the standard USB port on another. It appears to be working, as can be seen when I run the board_qc:

The 'slave' Arduino is just running the following code:

void loop() {
  Serial.println("Hello");
  delay(1000);
}

On the master, I create a USB object from the USB Host library (https://github.com/felis/USB_Host_Shield_2.0).

USB Usb;

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

void loop() {
    if (Usb.getUsbTaskState() == USB_STATE_RUNNING)
    {
        Usb.ForEachUsbDevice(&PrintAllData);
    }
}

void PrintAllData(UsbDevice *pdev)
{
    UsbDeviceAddress adr;
    adr.devAddress = pdev->address.devAddress;
    Serial.println(adr.devAddress, HEX);

    uint8_t msg = 0;
    uint16_t len = 0;
    uint8_t rcode = Usb.inTransfer(adr.devAddress, pdev->epinfo->epAddr, &len, msg);

    if (rcode && rcode != hrNAK) {
     Serial.print(F("\r\nData rcv: "));
     Serial.print(rcode, HEX);
   } else if (len > 0) {
     Serial.print(F("\r\nData Packet: "));
     Serial.print(msg[0]);
   }
}

I'm not getting any data through though. Does anyone have any suggestions? Or know of any helpful sample code?


texts:
I have an application where I would like to include an external multiline script as a const in my sketch. As far as I understand from C++11, this should work:

raw_string_literal_test.ino

const char *script =
#include "script.txt"
;

void setup() {
  // put your setup code here, to run once:

}

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

}

script.txt

R"(Line 1
Line 2
Line 3
Line 4
Line 5
Line 6)"

script.txt is placed in the same folder as raw_string_literal_test.ino

However, upon clicking Verify (selected board is Arduino/Genuino Uno, Arduino version is 1.6.12 on Mac OS 10.11.6) I get the following error:

/Users/owner/Desktop/raw_string/raw_string.ino:2:22: fatal error: script.txt: No such file or directory
 #include "script.txt"
                      ^
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.

What am I doing incorrectly?


texts: How to drive N channel gate correctly from Adafruit Feather pinout?

texts:
I am learning how to create a soft latch power switch, using an N channel mosfet.

Currently, I have this:

simulate this circuit – Schematic created using CircuitLab

The idea is (so far) that I can turn it on with the switch, the Arduino immediately brings the power control high (ensuring the FET stays on), and brings that same pin low after 1.5s (simulating a timed shutdown).

However; when the power control goes low, I still see about 1.8v in the power control line (I'm presuming its floating?), which leaves this particular FET partially open.

If I disconnect the power control line from the MCU, I get the behaviour I expect. I can touch the power control to +ve and the FET will switch on.  If I lift the control line from +ve, the FET closes the gate, due to the pull down resistor.

I'm struggling to understand why the FET works in isolation, but does not work when connected to the MCU output pin.  The pinMode is OUTPUT.

FET (3055VL): https://www.onsemi.com/pub/Collateral/MTP3055VL-D.PDF

Here's the test code I'm using.
It simply flashes a build in LED 10 times then does a power off.

int ledPIN = 17;
int controlPin = 11;
int lDelay = 150;

bool shouldBeUp = true;

void setup()
{
  pinMode(ledPIN, OUTPUT);
  pinMode(controlPin, OUTPUT);
  digitalWrite(controlPin, HIGH);
}

void loop()
{
  if (shouldBeUp) {
    for (int i = 0; i < 10; i++)
    {
      digitalWrite(ledPIN, LOW); // on
      delay(lDelay);
      digitalWrite(ledPIN, HIGH); // off
      delay(lDelay / 2);
    }

    // Leave the LED low
    digitalWrite(ledPIN, LOW);
    digitalWrite(controlPin, LOW);
    shouldBeUp = false;
  }
}

Any help is appreciated! Thank you :)


texts:
I need to check if the code burned on the some Arduino is the same one as I have.
I know how to get the hex file from the Arduino. My question is what influence the hex code? Board Type? Microprocessor type? avrdude version? anything else?


texts: How can I connect the Tamiya double gearbox to Arduino Uno?

texts:
I'm working on building my first robot. this is my first foray into DIY electronics. I already have an Arduino Uno, and I have ordered the Tamiya double gearbox here. My goal is to control the gearbox to move the robot, but from what I've already read, I need to have something between the Ardiuno and the motors. It seems like people have trouble doing that because the included motors are low voltage, so the Arduino motor shield won't easily work.

I'm looking for a clear solution to making this thing run, in the simplest way possible. One thing I'm considering is replacing the motors in the gearbox with these motors. If I do that, am I right in thinking I could run them from the Arduino motor shield?

If there is a simpler (or cheaper!) way of making it work than being stuck on the Arduino Motor shield, I'm game for that. I've just gravitated to that solution because it seems simpler as an electronics noob. (I haven't bought that shield yet.) But I'm really open to other solutions, so if you can, I'd appreciate the advice!


texts: Which board has the highest max current via 3.3v pin?

texts: Is there any arduino board which can deliver 600-800ma via 3.3v pin? Maybe the Arduino due or the nano 33 ble?


texts: I2C to UART bridge as breakout or in DIP package

texts:
For a project, I need to connect more than one device to an Arduino through a serial port with hardware flow control (RTS/CTS).

Sparkfun used to make breakout boards for the SC16IS750, but this product is discontinued and I can't find any place to order it. There are also plenty of ICs doing what I need, but I am not keen on soldering SMD components and I cannot find any products coming in e.g. an old fashioned DIP package.

Does someone know about an available breakout board or a DIP packages I2C to UART bridge? Since the device will be battery powered, I would prefer a dedicated low-power circuit instead of a programmed microcontroller as suggested by majenko.


texts:
I've been trying to use this HC-05 bluetooth module for a project, where the data would be sent to a Max/MSP/jitter program. Initially, every time I connected my bluetooth device to my computer, it stayed connected for about 10 to 20 seconds then disconnect. I'm not sure if it's a voltage thing, but from what I read on other forums, it should work fine. My setup:
1- Powering Arduino on a wall wart (Input: 100-240V AC, 50/60Hz 0.3A ; Output: 12V DC 1A);
2- Bluetooth's Tx to Arduino's Rx (D3) and Bluetooth's Rx to Arduino's Tx (D4)
3- APDS9960 sensor also connected on the same breadboard (the sensor I should be receiving the data from, and I do, when connected on an USB cable port)
4 - HC-05 configured to be 115200 baud (AT+UART=115200,0,0), which seems to be the appropriate bps for HC-05 to Max (??)
But then... Once I logged into Max, and printed the data from this serial port (which should send data in a continuous fashion), some lines were printed and then it stopped. So I go on to check the Arduino Serial Monitor and – though everything seemed to be working fine and I received the data properly – there's nothing showing up.
#include "SoftwareSerial.h"
#include <Arduino_APDS9960.h>

SoftwareSerial blue(3,4); //rx tx, qualquer 2 portas digitais sem ser 7 e 8

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

  Serial.println("mensagem do computador");
  blue.println("mensagem do módulo bluetooth");

   if (!APDS.begin()) {
    blue.println("Error initializing APDS9960 sensor.");
  }
}

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

    while (! APDS.colorAvailable()) {
    delay(5);
  }
  int r, g, b;

  // read the color
  APDS.readColor(r, g, b);

  // print the values
//  blue.print("r = ");
  blue.println(r);
//  blue.print("g = ");
  blue.println(g);
//  blue.print("b = ");
  blue.println(b);
//  blue.print();

  // wait a bit before reading again
  delay(100);
}


texts: Using SoftwareSerial library with EnableInterrupt

texts:
I'm working on a project that involves both serial communication and GSM transmission.
I'm using the SoftwareSerial library for RS232 communication, and GSM (SMS) transmission:

TX and RX for RS232 : Arduino Uno D3 and D4 pins
TX and RX for GSM module : Arduino Uno D7 and D8 pins

The project requires also the use of the EnableInterrupt library to enable interrupt in Arduino's analog pins, meaning that I DON'T USE EnableInterrupt for all of the Arduino's digital pins including D3, D4, D7 and D8.

However when running the program that includes the two libraries, this long error message shows up :

libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin): In function `SoftwareSerial::read()':

(.text+0x0): multiple definition of `__vector_3'

sketch\sketch_jun14a.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin): In function `SoftwareSerial::read()':

(.text+0x0): multiple definition of `__vector_5'

sketch\sketch_jun14a.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin): In function `SoftwareSerial::read()':

(.text+0x0): multiple definition of `__vector_4'

sketch\sketch_jun14a.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

collect2.exe: error: ld returned 1 exit status

exit status 1
Erreur de compilation pour la carte Arduino/Genuino Uno

Clearly, there is a conflict between the two libraries, Is there any solution to remove this conflict and run the two libraries together ?

Thanks in advance !


texts:
I'm a high school student working on a robot arm project that uses an arduino board.

I had uploaded my previous program to my board, but I've since changed my code and want to reset the board, but I seem to have a problem with that.

I had thought the red reset button would solve the problem, but it doesn't.

So I searched online and tried uploading

  void setup() {}

  void loop() {}

Unfortunately, I keep on getting this error below, and I can't really seem to figure out what exactly is the problem.

  UPDATED
  Sketch uses 2218 bytes (6%) of program storage space. Maximum is 32256 bytes.
  Global variables use 59 bytes (2%) of dynamic memory, leaving 1989 bytes for local variables. Maximum is 2048 bytes.
  avrdude: stk500_recv(): programmer is not responding
  avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
  avrdude: stk500_recv(): programmer is not responding
  avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
  avrdude: stk500_recv(): programmer is not responding
  avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
  avrdude: stk500_recv(): programmer is not responding
  avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
  avrdude: stk500_recv(): programmer is not responding
  avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
  avrdude: stk500_recv(): programmer is not responding
  avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
  avrdude: stk500_recv(): programmer is not responding
  avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
  avrdude: stk500_recv(): programmer is not responding
  avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
  avrdude: stk500_recv(): programmer is not responding
  avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
  avrdude: stk500_recv(): programmer is not responding
  avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00
  Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

Could someone help me out please?


texts:
I have connected BMP180 sensor:

to Arduino and was able to read its values with appropriate samples (from Adafruit BMP085 Library and Adafruit BMP085 Unified).

Apparently, this sensor is sending information via I2C bus.

However, I2C protocol assumes addresses of connected devices.

What are addresses in my case? How to know and/or change them?

Is it possible to connect several BMP180 to a single Arduino?


texts: Arduino Uno with ESP8266 Wifi transceiver or ESP8266 NodeMCU board?

texts:
I already have an Arduino Uno, and I want to learn Internet-of-Things. I'm planning to use an ESP8266 since it's cheap. Should I purchase an ESP8266 Wifi transceiver module to use with my Arduino Uno or just buy an ESP8266 NodeMCU board?

Is there any advantage using an ESP8266 NodeMCU board to using my Arduino Uno with an ESP8266 Serial transceiver module?


texts: Arduino Uno board works but Arduino Uno + Wifi is not being detected

texts:
When I connect my Arduino Uno board it instantly detects the board and shows it in the list. But when I connect my new Uno + Wifi board it doesn't detect it. I also manually selected Arduino Uno Wifi but it still gives me the message

Error uploading check if the selected board is currently available

How can I fix this?

This is the one that's not working:

Arduino Uno + Wifi

While this one I got does work:

Arduino Uno


texts: Arduino not detected On El Capitan Public Beta 6

texts:
Since I updated to El Capitan Public Beta, my Arduino Uno doesn't show up in the serial devices list.

The System Information utility shows an Arduino connected on the USB port (as 'Communication Device'), but a serial port does not get created at /dev.

The board works on Windows and the previous versions of El Capitan.

The problem persists on beta 6.


texts: Why can only some digital ports output PWM and the others not?

texts: If it matters, I'm talking about the arduino uno v3.


texts: How to get the name of the device connected to the bluetooth?

texts:
Recently, in the supermarket, I've seen a speaker that tells you the name of the device connected to ut via bluetooth.

Now, I want to a portable speaker powered by bluetooth with arduino, and I want to do the same as the other speaker.

I searched arround the web  (including the official arduino forums) and I didn't found nothing useful.

I don't know if it can be done with a special library.

My question is (if it's possible to do it), how can I get the name of the device connected to the bluetooth via arduino?

If it's useful, I have an arduino uno.

P.D.: The code is not necessary, only the way to do it.


texts:
I am using an Arduino board with an ESP8266 module to connect to a WiFi device.
How do I check if the device is connected?


texts:
I would like to use an Arduino to make tasks in my life automatic - maybe to rotate every morning a motor, or to open a door.

So, can I run an Arduino as solo with no pc needed? Can i connect it to the Internet and can I setup software like PHP and Apache on it to control it over the internet? Has it any protocols like SSH like a normal server?

As an example: I will send over any protocol a signal to my Arduino with a certification and then the Arduino would run a function...

Is that possible?

thanks ahead


texts: ESP8266 NODEMCU V3 web server with MAX7219 and DS3231 RTC

texts:
I am using ESP8266 NodeMCU with MAX7219 and a DS3231 teal time clock. I want to display the time and some text. The display is made of 4 FC16 modules which are made of 4 8x8 MAX7219 led matrix modules so it would be a 32x32 led matrix diplay divided in 4 rows.
I am displaying the time hh:mm on the last row and text on the first 3 rows.
With ESP8266 I connected to my wi-fi and I created a web server which says "Hello World!"
So my question is: how do I upload my code to the web server so I can change the text remotely?
I found this tutorial https://maker.pro/esp8266/tutorial/how-to-build-an-led-matrix-display-with-a-nodemcu-esp8266 that shows how to change the text on one row of display but I don't want something that fancy. I just want my code uploaded and to be able to change in the code.
#include "RTClib.h"
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

ESP8266WebServer server;

// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 12
#define NUM_ZONES 3

int CS_PIN = D4;
int CLK_PIN = D5;
int DATA_PIN = D7;

// Hardware SPI connection
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// Arbitrary output pins
// MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

RTC_DS3231 rtc;
#define SPEED_TIME  25
#define PAUSE_TIME  1000

uint8_t lastUpdateMin = 0;
uint8_t lastUpdateHour = 0;

// Global variable
const char  *pc[NUM_ZONES] =
{
  "TIME", //0
  "ROOM", //1
  "SUBJECT", //2
  //"GRADE",//3
};

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

  WiFi.begin("ssid", "password");

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

  Serial.print("Connected, IP address: ");
  Serial.println(WiFi.localIP());
  server.on("/", []() {
    server.send(200, "text/plain", "Hello World!");
  });
  server.begin();

  P.begin();
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  if (rtc.lostPower()) {
    Serial.println("RTC lost power, lets set the time!");
    //     If the RTC have lost power it will set the RTC to the date & time this sketch was compiled in the following line
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }

  P.begin(3);
  P.setZone(0, 0, 3); // Modules 0-3 in zone 0
  P.setZone(1, 4, 7); // Modules 4-7 in zone 1
  P.setZone(2, 8, 11); // Modules 8-11 in zone 2
  // P.setZone(3, 12, 15); // Modules 12-15 in zone 3
}

void loop(void)
{
  server.handleClient();
  DateTime now = rtc.now();
  if (lastUpdateMin != now.minute()) { // change every minute
    lastUpdateMin = now.minute();
    char buffer[] = "hh:mm";  // hours and minutes
    P.displayZoneText(0, now.toString(buffer), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
  }
  if (lastUpdateHour != now.hour()) {   // change every hour
    lastUpdateHour = now.hour();
    P.displayZoneText(1, pc[1], PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);  // 2nd row
    P.displayZoneText(2, pc[2], PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);   // 3rd row
    //   P.displayZoneText(3, pc[3], PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT); // 4th row
  }
  P.displayAnimate();
}


texts:
1. Example

Check the program below for an Arduino Nano, Old Bootloader, for variable values of N.

For low values (N<=1857), the program outputs "[FFFFFFFF]",
For higher values (1858<=N<=1953), the program outputs unpredictable variations of this string,
For higher values (1954<=N<=1955), the program outputs fails flooding the symbol "[",
Over a certain value (1956<=N), the programs does not output any character.

I didn't check extensively these results, which could be very different actually, and totally platform dependent, but I guess, reproducible.

Note that no dynamic allocation is being used.

Note that everything is initialized, first 4 values to 0xFF, next N-3 values to 0x00 (Ref.).

The compilation do not show any relevant alert, showing a modest 10% capacity usage.

Sketch uses 3206 bytes (10%) of program storage space. Maximum is 30720 bytes.
Global variables use 196 bytes (9%) of dynamic memory, leaving 1852 bytes for local variables. Maximum is 2048 bytes.

It is evident from this example how to figure the proper value of N, indeed a capacity related issue could be expected (Ref.).

Note these values are by far less than the "guess" value of N=32767 for 1 byte variables (?) (Ref.).

2. Problem

Now, with a considerably huge, real program, I am having the same issue regarding those unexpected results, so I am almost sure (few moments ago) than this is the cause.

When exceeding some "~maximum~" level, the program starts failing, and when "~releasing~" this capacity, the program starts working well (without those deleted functionality of course!).

3. Question

How should I debug, measure, dimension, or prevent this situation, and specify when it is the proper time to keep this processor, and when should I move into a bigger one, when clearly the compiler is not a reasonable guess?.

// CAPACITY TEST
#include <SoftwareSerial.h>

// SET THE PROPER N VALUE
// N<=1857: Last Valid Result
// 1858<=N<=1953: Last Observable Output - Single Char
//     PC=0x0444. [AVR MEMORY] Writing to memory location 0x0948 outside of memory size 0x0900. [UP0]
// 1954<=N<=1955: Last Observable Output - Flood
//     Invalid opcode 0xFFFF at PC=0xA402
//     PC=0x0444. [AVR MEMORY] Writing to memory location 0x0948 outside of memory size 0x0900. [UP0]
// 1956<=N: No Output
//     Invalid opcode 0xFFFF at PC=0xA402
#define N 1857

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

    byte a[N+1]={0xFF,0xFF,0xFF,0xFF};

    char si[3];
    Serial.print("[");
    for (int i1=0;i1<=N-1&&a[i1]!=0;i1++){
        sprintf(si,"%02X",a[i1]);
        Serial.print(si);
    }
    Serial.print("]");
}

void loop(){}


texts:
I want to use an OLED with DUE.
I plan to connect it via hardware SPI.
The Due has a 3X2 pin connector labeled SPI. Is it here where i connect the SCK and MOSI?

If indeed, i connect it here, then which one is SCK and which one is MOSI?

Most importantly, i saw somewhere that in the DUE, hardware digital pin 13 is SCK and pin 11 is MOSI?
Is this true? Because if it is, i can simply hook it up to these pins and get rid of the confusing 3X2 pin connector.


texts: HC-05 bluetooth module not accepting AT commands

texts:
I have been attempting to program my HC-05 ZS-040 Bluetooth module for quite some time, and I cannot get the AT commands to return any values. I have searched google for quite some time, and I none of the answers seem to work for me. I have been following along with this website:

https://sites.google.com/site/wayneholder/inexpensively-program-your-arduino-via-bluetooth

I am using an Arduino Mega 2560 clone by Elegoo to program this Bluetooth module. Currently I have it wired up using this diagram

https://sites.google.com/site/wayneholder/inexpensively-program-your-arduino-via-bluetooth/HC-05-to-FTDI.png?attredirects=0

Currently I have it modified slightly to use a voltage divider between the Arduino's Tx and the HC-05 Rx, as the HC-05 works on 3.3v logic. The one possibility I think could be causing this problem is that the Arduino Mega is just interpreting all Tx incorrectly as I measured that it sounds ardoun 3.2 volts for a high voltage. According to multiple websites the HC-05 is in AT command mode when the LED flashes slowly, about once every 2 seconds, which is happening. I put it in command mode by holding down the button above the EN pin while providing power to the HC-05.

I have been using pin 14 and 15, which are Hardware Serial3 on the Arduino Mega. Here is the code I have written:

  /*
  Software serial multple serial test

 Receives from the hardware serial, sends to software serial.
 Receives from software serial, sends to hardware serial.
 */
#include <SoftwareSerial.h>

SoftwareSerial mySerial(15, 14); // RX, TX

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  Serial.println("AT");
  // set the data rate for the SoftwareSerial port
  Serial3.begin(38400);
}

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

Any suggestions are much appreciated!

EDIT:
I have now received some unrecognizable responses from the controller after sending AT multiple times, here is the screenshot, included is a video of my circuit, which shows how the LED is flashing:

https://drive.google.com/open?id=1mc8PEEnhiKpPzzy5kL9QxTvoQA3NAH6b

The only modification to the code is adding a Serial.println("TESTING"); in the while loop that reads Serial3. I have tried using other Hardware serial ports as well, all with the same result as the above screenshot.


texts: My serial Monitor of the Arduino ide does not show up when running Gui?

texts:
I have created an gui in python using pyserial to communicate with Arduino but my serial monitor does not show up it says (Serial port busy) whenever I run the gui.

The gui works fine but when I want to see the printed data for that, I am using an external LCD but I was wondering if there was a way to see the data in serial monitor. If not could you explain why? I have no idea whatsoever why is this happening.


texts:
I called HTTP web service on Arduino Uno, now i am trying to store the data in SD card. But as soon as i compile the program, it shows LOW MEMORY error and no data stored in SD card.
Any one can help?


texts: Merging strings and constants causing scope errors

texts:
I'm getting a few errors when merging strings with constants.

Here's the pertinent code...

#define STATION_ID ABC123
#define STATION_PASS XYZ987

void loop(){
    String path = "/weatherstation/updateweatherstation.php?ID="+STATION_ID+"&PASSWORD="+STATION_PASS+"&dateutc=now&tempf="+celsiusToFahrenheit(temperature)+"&humidity="+String(humidity)+"&action=updateraw";
}

And then the errors...

weather.cpp:15:20: error: 'ABC123' was not declared in this scope
weather.cpp:64:66: note: in expansion of macro 'STATION_ID'

weather.cpp:16:22: error: 'XYZ987' was not declared in this scope
weather.cpp:64:90: note: in expansion of macro 'STATION_PASS'

Not sure where I'm going wrong on this.


texts:
I am working on a brushed motor quadcopter using Arduino pro mini.
Every time I try to throttle, the Arduino gets reset by itself (motors start to spin but they will be turned off in 2 sec). I have added a 1000uf capacitor (tried up to 3300uf) to the input of Arduino VCC and GND. But still having the same issue.


texts: Problem sending data from arduino with ESP8266 to a local mysql database

texts:
i'm currently trying to send a randomly generated number from Arduino via ESP8266 wifi module to a local mysql database estabilished with xampp, but having a problem with it. Here is my arduino and php receiving code. I should mention that i'm extremely unfamiliar with mysql, php, and the whole server & database things, so any help would be greatly appreciated.

Arduino Code:

#include <ESP8266WiFi.h>

const char* server = "192.168.1.106";
const char* ssid = "DARUSALAM C8";
const char* password = "asro4520";
const char* SensorID = "ESP001";

WiFiClient client;

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

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

  WiFi.begin(ssid, password);
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.print(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi Connected");
}

void loop() {
float n = random(300);

Serial.print("Random Number: ");
Serial.println(n);

  if (client.connect(server,80)) {
    Serial.print("Posting data...");
    digitalWrite(BUILTIN_LED, LOW);
    Serial.println("Random Number: " + String(n));
    client.println("GET /log.php?n=" + String(n));
    client.println("HOST: ");
    client.println(server);
    client.println("Connection: close");
    client.println();

    client.stop();
    Serial.println();

    digitalWrite(BUILTIN_LED, HIGH);
  }

  delay(5000);
}

PHP code:

<?php

$db_amb = mysqli_connect("127.0.0.1", "root", "", "wemos");
if (!$db_amb) die("Gagal terkoneksi ke DB Utama. Error : " . mysqli_connect_error());

$n = $_REQUEST['n'];
if (!empty($n) &amp;&amp;)
{
  $s = "insert into data_random set value1='$n'";
  $r = mysqli_query($db_amb, $s);
  echo "OK";
}
else echo "ERR";
?>;

The database is named 'wemos', and the table where i intend to store the data is named 'data_random' with 4 columns named value1-value4. My intentions is to store the random number to the 'value1' field.

EDIT the problem i encountered is whenever i checked http://localhost/log.php this appears:

Parse error: syntax error, unexpected ';' in C:\xampp\htdocs\log.php on line 7

i have tried modifying the syntax in numerous ways but the problem presist. I suspect my code may have some underlying fundamental problem that is not syntax related, but i can't tell due to my lack of experience. Again, any help/clue is greatly appreciated. Thank you very much


texts: Writing data to a specific address in EEPROM

texts:
I'm trying to write two strings to an Arduino Uno's EEPROM. Here, the first code block works fine: it writes string(True/False) at 'address 0'. But the second block, which writes data at 'address 5', is not working as expected.Reading data at address 5 prints a blank line. What am I missing here? Is this the correct way to write two different strings to EEPROM?

First code block:

int state = LOW;
char first_eeprom_value;
if (state == LOW) {
  state = HIGH;
  char example_string[4] = "True";
  first_eeprom_value = EEPROM.read(0);
  Serial.println(first_eeprom_value);
  for (int i = 0 ; i < 5 ; i++) {
    EEPROM.update(i, example_string[i]);
  }
} else {
  state = LOW;
  char example_string[5] = "False";
  first_eeprom_value = EEPROM.read(0);
  Serial.println(first_eeprom_value);
  for (int i = 0 ; i < 5; i++) {
    EEPROM.update(i, example_string[i]);
  }
}
Time = millis();

Second code block:

char first_eeprom_value1;
if (state1 == LOW) {
  state1 = HIGH;
  char example_string1[4] = "True";
  first_eeprom_value1 = EEPROM.read(5);
  Serial.println(first_eeprom_value1);
  for (int i = 5 ; i < 11 ; i++) {
    EEPROM.update(i, example_string1[i]);
  }
} else {
  state1 = LOW;
  char example_string1[5] = "False";
  first_eeprom_value1 = EEPROM.read(5);
  Serial.println(first_eeprom_value1);
  for (int i = 5 ; i < 11 ; i++) {
    EEPROM.update(i, example_string1[i]);
  }
}

Time = millis();

//reading data at address 5
int addr = 5;
char value = EEPROM.read(addr);
Serial.println(value);// this prints blank line


texts:
When I connected an external power supply to my Arduino Uno R3 (it was connected to PC via USB cable too), I heard Windows disconnected device sound and the device isn't visible since then (nothing happens when I plugin the USB). Cable is ok, because it works with the second Arduino. TX/RX LEDs don't blink anymore.
Following this guide, I checked two things:

I was able to flash ATMEGA328 with LED blinking program using external ICSP programmer and it worked
I was able to flash ATMEGA16U2 with the official firmware and it completed without any error

Is there anything else I can check? I'm not really desperate to fix it - I just want to know which component is broken.


texts: Alternate between 2 relays with one button

texts:
I have a very basic programming knowledge, but the thing I want to achieve is to alternate between switching 2 relays with a button or a RPi input pulse.

So something like this:

Press the button
Switch relay 1 on and off (1 second delay)
Press the button
Switch relay 2 on and off
Press the button
Switch relay 1 on and off (1 second delay)
Press the button
Switch relay 2 on and off
Press the button
Switch relay 1 on and off (1 second delay)
Press the button
Switch relay 2 on and off
etc.

Here's my code, I thought if I'd just put the second relay after the first else everything would work. But I'm missing some basic knowledge to figure this out.

const int ledPin = 2;
const int ledPinA = 3;

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

void loop() {
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue);
  delay(1);
  if (sensorValue > 500) {
    digitalWrite(ledPin, HIGH);
  } else {
    digitalWrite(ledPin, LOW);
  }
  if (sensorValue > 500) {
    digitalWrite(ledPinA, HIGH);
  } else {
    digitalWrite(ledPinA, LOW);
  }
}

I'm thinking I should use while.


texts: Own type definition using a struct does not name a type

texts:
I need to initialize several buttons and LEDs connected to my Arduino. To store data related to an individual button or LED, I decided to define my own data type using two different structs. One for a button and another one for a LED.
As I need to configure some GPIOs and other peripherals after instantiating each button/LED, I implemented a small factory function to get a clean interface and combine the required steps for instantiating and initialization.
Defining my own button_t type works as expected. The compiler does not throw any errors. However, I tried to implement the same approach for led_t type upon the compiler states the following error:

example:25:1: error: 'led_t' does not name a type
led_t ledFactory(uint8_t pinNumber)
^~~~~
exit status 1 'led_t' does not name a type

My example code looks like this:
#include <Arduino.h>
#include <stdint.h>

struct button_t
{
    const uint8_t pin;
    uint8_t currentState;
    uint8_t lastState;
    uint32_t lastDebounceTime;
};

button_t buttonFactory(uint8_t pinNumber)
{
    button_t btn = {pinNumber, 0, 0, 0};
    // setting some MCU registers here
    return btn;
};

struct led_t
{
    const uint8_t pin;
    const uint8_t state;
};

led_t ledFactory(uint8_t pinNumber)
{
    led_t led = {pinNumber, 0};
    // setting some MCU registers here
    return led;
};

void setup()
{
}

void loop()
{
}


texts:
I'm not talking about the onboard LED at the Arduino board here.  What those LED's mean, is the LED's we usually plug at the breadboard.

I plugged in a yellow LED and a green LED onto a breadboard.  I wired it up, and noticed something.  Green LED lights up at its full brightness, while yellow LED didn't emit any light.  Tried in another yellow LED, and it seems like it's smoking, which means it's burned.

I'm not using a 220 Ohm resistor or any kind of resistor that time.  I also have no idea why the green LED didn't burn itself, when you plug it directly on 5V and GND.  I'm expecting that the green LED should also be burned, because I think, that's the way how LED's work.

When I plugged the green LED into a 220 Ohm resistor, it did as expected.  It lowered its brightness, of course, because the resistor is resisting some of the electricity to pass on the LED.


texts: ws2812b NeoPixel - how to address it? How Arduino knows the correct order of LEDS on the stripe?

texts:
How to get a One-Wire address of a given WS2812B pixel? I bought several of these, and I cannot make them light. On the other hand, when I connect the addressable LED strip made of these diodes, I have no problem controlling it.

Here is my set-up:

I tried many programs, e.g. AdaFruit_NeoPixel -> simple, setting number of LEDS to 1, but no effect. No blinks, nothing - as if the diodes were dead.

If every One-Wire device is identifiable by 64 bit ID, how does the Arduino know the correct "order" of the LEDS on the ribbon? How to tell the Arduino the new sequence of the LEDS on the strip that would result if I replace one (broken) LED with another?


texts: AVR Timer1 OCR1A controls TIMER1_COMPB_vect interrupt!

texts:
I was struggling with timer interrupts in my project. I couldn't make it work properly. So I decided writing a simple code and I saw a very interesting case.

ISR(TIMER1_COMPB_vect)
{
        PORTB ^= (1 << PORTB5);
}

int main(void)
{
    cli();          // disable global interrupts
    TCCR1A = 0;     // set entire TCCR1A register to 0
    TCCR1B = 0;     // same for TCCR1B

    OCR1A = 10000;
    OCR1B = 100;

    TCCR1B |= (1 << WGM12);

    TCCR1B |= (1 << CS10);
    TCCR1B |= (1 << CS12);

    TIMSK1 |= (1 << OCIE1A);
    TIMSK1 |= (1 << OCIE1B);
    DDRB= 0xFF;

    #define F_CPU 16000000
    sei();
    while (1)
    {

    }
}

Here is my code. When I change OCR1B value, nothing happens, but if I change OCR1A value then blinking gets faster. Is there a logical explanation for this?


texts: l293d is not able to drive two 300 rpm motors simultaneously

texts: I am using l293d in a line follower but recently I am facing a problem. my l293d motor driver is not able to power 2 300 rpm motors simultaneously while with one of the motors at a time it works perfectly fine. Earlier it used to drive both the motors at optimal desired speed but recently its posing the above mentioned problems. I have tried replacing the Motor driver and Arduino itself but nothing worked and I am still facing the problem.


texts:
I am getting back into doing some hardware stuff after a fairly long time away and am having a hard time getting back into it. I have a Teensy 2.0 and am trying to run a basic sketch that when a button is pressed will output 0, but my button is always High. I think that I miswired something but my breadboard looks like all the tutorials so I'm just confused as to what is going on and would appreciate any help.

const int pinBtnUp = 0;
const int pinLEDOutput = 11;

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

  //Setup the pin modes.
  pinMode( pinLEDOutput, OUTPUT );
  //Special for the Teensy is the INPUT_PULLUP
  //It enables a pullup resitor on the pin.
  pinMode( pinBtnUp, INPUT_PULLUP );

}

void loop()
{
  Serial.println(digitalRead(pinBtnUp));
}


texts: When setting hardware timers as interrupts, should I prefer a lower prescaler value or a lower CTC?

texts:
I'm currently playing with Arduino's hardware timers, and a question came to my mind. Let me explain it a bit.

Let's suppose I want a certain function to execute every 1024 clock ticks. AFAIK, I could achieve this in several ways, playing with the prescaler value for Timer2, and its CTC:

Setting the prescaler to 1 and the CTC to 1024
Setting the prescaler to 8 and the CTC to 128
...
Setting the prescaler to 1024 and the CTC to 1.

All these ways would achieve what I want, but, which one is more efficient? Or it doesn't matter at all?

Thanks in advance for sharing your knowledge :P


texts:
The below is a snippet of a code for operating SI4455 Rf module with Arduino. I have some doubts which I'd like to seek some help in clearing.

byte numOfBytes = *pSetPropCmd++;

    if (numOfBytes > 16u) // What does this 16u mean?
    {
        /* Initial configuration of Si4x55 */
        if (SI4455_CMD_ID_WRITE_TX_FIFO == *pSetPropCmd)
        {
            if (numOfBytes > 128u) // What does this 128u mean?
            {
                /* Number of command bytes exceeds maximal allowable length */
                return SI4455_COMMAND_ERROR;
            }

            /* Load array to the device */
            pSetPropCmd++;
            WriteEZConfigArray(numOfBytes - 1, pSetPropCmd);

            /* Point to the next command */
            pSetPropCmd += numOfBytes - 1;

            /* Continue command interpreter */
            continue;
        }

In the above snippet, what does 16u and 128u mean?. I think its meaning u for unsigned, but still not clear as what does 16u and 128u mean.

Rgds
VD


texts:
I've been wondering for a long time what these pins, labeled ICSP and blank, do.

I can't seem to find a diagram that explains them, so I've been wondering:

What are they for?
Are they GPIO, or do they do something special?
How can you use them?

Thanks for the help.


texts:
I am working on a project which includes Arduino and a fingerprint scanner. It is completely based on embedded system. But then, I have downloaded a library for the fingerprint scanner. When I run the program I get an error which maps to the cpp file of the library file. See below to see the error and the library file.

Error

  FPS_GT511C3\FPS_GT511C3.c.cpp.o: In function
  Command_Packet::GetPacketBytes()':
  C:\Users\Dipti\Documents\Arduino\libraries\FPS_GT511C3/FPS_GT511C3.c.cpp:17:
  undefined reference tooperator new[](unsigned int)'
  FPS_GT511C3\FPS_GT511C3.c.cpp.o: In function
  FPS_GT511C3::GetResponse()':
  C:\Users\Dipti\Documents\Arduino\libraries\FPS_GT511C3/FPS_GT511C3.c.cpp:735:
  undefined reference tooperator new[](unsigned int)' collect2.exe:
  error: ld returned 1 exit status

Library File (CPP)

  byte* packetbytes= new byte[12];

  byte* resp = new byte[12];


texts:
I have made a drone/car quadruped robot thing and I need help with the code. I have found two codes to use to control each aspect of it but I need help to connect them. I have made a radio controller with a Xbee 3 Pro that has a spdt (two position switch) and I want to use it to switch the modes. I want the car to be LOW and the drone to be HIGH (If it helps the switch is on pin digital pin 9 of a Arduino Nano). I am a beginner at the coding aspect of the project and I would appreciate all the help I can get.

https://www.youtube.com/watch?v=enT-O4NwCzc


texts:
I tried to download the ATmega16 board in my Arduino. I have set below URL under File->Preference->Additional board manager URL

https://mcudude.github.io/MightyCore/package_MCUdude_MightyCore_index.json

I am getting below attach images. How can we resolve this error and install atmega16 board manager?

I am using Arduino version 1.6.9. I don't have any issue in opening MightyCare and Arudino URL from my chrome browser.


texts:
I am using Atmega328p with arduino bootloader in a project. There happens to be an LED connected on SCK pin. During Start (or restarts), the LED appears to flicker a couple of times (3 times to be exact). I don't want this to happen. I can change the connections but I would prefer a software solution because hardware change means a PCB modification.

I probed the SCK pin and I got some expected waveforms. There were two different cases:

1) When I powered the arduino using USB to serial programmer i.e. Tx Rx connected to a PC:

2) When I powered the arduino with an external power source (the case with my project):

This is what I think:

1) As mentioned in this thread, the bootloader has a piece of code which makes it act that way.
The bootloader code has a pin definition file which declares SCK pin as a LED and blinks it a couple of times to indicate that it has entered the bootloader. I found the code here:

#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega88) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__)
/* Onboard LED is connected to pin PB5 in Arduino NG, Diecimila, and Duemilanove */
#define LED_DDR     DDRB
#define LED_PORT    PORTB
#define LED_PIN     PINB
#define LED         PINB5

Other relevant piece of code is here.

In this case, changing the LED definition to PINB4 and burning the bootloader and program again should take care of the issue. However this didn't work out for me. This is what I did exactly:

a) Opened the file D:\Program Files (x86)\Arduino\hardware\arduino\avr\bootloaders\optiboot\pin_defs.h

b) Modified the PINB5 to PINB4 on line 6.

c) Saved the file, burnt the bootloader and then program.

d) Powered up the chip and tested whether I am getting those 3 pulses. I got those 3 pulses.

(Even though it didn't work, I am still going to try it a few more times just in case I might have made an error.) :(

2) This brings me to second thought that since atmega328 accepts code through SPI by default, it checks for incoming data by clocking the SCK pins 3 times during startup. In this case, a software fix won't do anything.

What do you guys suggest? Should I go for the PCB modification or is there still some hope left?

Ignacio pointed out that I can disable bootloader to get rid of the issue. I want to program the chip using arduino IDE (preferably via UART) but I can consider SPI as well in case everything else fails.

Note: I am not sure whether this post is more suited for EE or Arduino. In case you guys(mods) think I'd get better suggestions there, feel free to move my post to Arduino.


texts: ATMEGA 328P Standalone on 3.3v controlling a servo

texts:
I'd like to use an ATMEGA 328P on standalone mode powered by a 3.3V supply source to control a servo (which is powered by 4 AA batteries, resulting in 6V). My question is: do I have to convert the PWM signal's peak amplitude to 5V for it to work? Or will the servo work just fine with a 3.3V amplitude signal? My servo's datasheet says its operation voltage ranges from 4.8V to 6V, but I'm not sure if that applies only to its power source or if it has implications on the control signal as well.

Servo's datasheet:
https://www.donkeyhoute.com/UploadFiles/2014916134245511.pdf

Also, since I will be using an 8 MHz external clock, do I have to change anything in my Arduino sketch regarding the PWM signal frequency, or do I just set the board to the 'Lilypad' option when burning the bootloader and keep the sketch the way it is now?


texts: How can I stop a loop when using a servo with a Key input?

texts:
How can I stop my following code using a key?

Basically the code should run the servo in a loop if "t" is pressed and stop the loop if "s" is pressed.

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position
int servodata;

void setup() {
  myservo.attach(8);  // attaches the servo on pin 9 to the servo object

  Serial.begin(9600);

}

void loop() {
  if (Serial.available()>0){
    servodata = Serial.read();
    while (servodata == 't'){
           for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
       myservo.write(pos);              // tell servo to go to position in variable 'pos'
       delay(3);                       // waits 15ms for the servo to reach the position
  }
    for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
       myservo.write(pos);              // tell servo to go to position in variable 'pos'
       delay(3);                       // waits 15ms for the servo to reach the position
    }
    }
  }
  while (servodata == 's'){
    break;
  }
}

thank you for help.


texts:
I've written this code for a reaction timer game. The reaction time is to be displayed in milliseconds to the serial monitor as accurately as possible. The reaction time is not being displayed correctly. I'm including my timer setup routine and where I increment milliseconds.

TCCR1A=0;
TCCR1B=0;
timer1_counter=65536;
TCNT1=timer1_counter;
TCCR1B |=(1<<CS12);

TIMSK1 |=(1<<TOIE1);
interrupts();
}

ISR(TIMER1_OVF_vect)
{
  TCNT1=timer1_counter;
  int_flag=1;
 }

  digitalWrite(LED,LOW);
  randomSeed(analogRead(A1));
  NumSecs=random(1000,7000);
  delay(NumSecs);
  digitalWrite(LED,HIGH);
  while(digitalRead(PUSHBUTTON) == HIGH)
  {
  }
  if (int_flag==1){
  millisecs++;
  int_flag=0;
  }


texts: Please explain this adafruit image for connecting a DS1307 RTC

texts:
https://learn.adafruit.com/assets/3813

I understand that analog 4 and 5 are SDA/SLC, isn't the picture also showing 5v and GND being plugged into two analog pins? Does that work?

I have it wired up to the actual 5v and GND, but it would be convieniet to be able to stack the RTC like they show in the picture


texts:
im new to arduino and have a problem currently with my project on sun tracking. The problem is that every loop it resets my variable back to 1 or whatever i set it. I have 4 photodiodes working properly but using only 2 on one axis. Code example:

void loop(){
    int stop1 = 1;
    senzor read1  //this is just code example
    senzor read2
    senzor read3
    senzor read4
    if (senzor1>senzor2){stop1=senzor1 - senzor2}
    if (senzor2>senzor1){stop1= senzor2 - senzor1}
    if (stop<5){stop motors}
}

this is simple example code and the problem is that it doesn't stop, it keeps looking for light (successfuly) and doesn't stop. Sorry for bad English if any and thanky in advance.


texts: LiquidCrystal library and timers don't seem to be compatible

texts:
If I set timer2 to Compare Match mode, my LCD display stops working. If I use Overflow Interrupt it works fine.

Here's my test code. I have a loop() function which does its thing, and a timer interrupt which increments another variable, just to show it's working.

#include <LiquidCrystal.h>
#include <avr/interrupt.h>
#include <avr/io.h>

LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 );   //Pins for the freetronics 16x2 LCD shield. LCD:

int i;
volatile int j;
void setup()
{
  i=0;
  j=0;
  //button adc input
  pinMode( A0, INPUT ); //ensure A0 is an input
  digitalWrite( A0, LOW ); //ensure pullup is off on A0
  //lcd backlight control
  pinMode( 10, OUTPUT ); //D10 is an output
  digitalWrite( 10, HIGH ); //backlight control pin D10 is high (on)
  //set up the LCD number of columns and rows:
  lcd.begin( 16, 2 );

  // setup timer interrupt
  cli(); //disable global interrupts
  TCCR1A = 0;   //set tccr1a and tccr1b to 0
  TCCR1B = 0;
  //set cs10 and cs12 bit so timer runs at clock iSpeed/ 1024
  TCCR1B |= (1 << CS10);
  TCCR1B |= (1 << CS12);

  // Compare Match Mode **Doesn't work**:
  //set compare match register
  OCR1A = 15624;
  // turn on CTC mode
  TCCR1B |= (1 << WGM12);
  // enable Timer1 compare interrupt
  TIMSK1 = (1 << OCIE1A);

  // Overflow mode **Works**
  // enable overflow interrupt
  // TIMSK1 = (1 << TOIE1);

  //enable global interrupt
  sei();
}
void loop()
{
  lcd.setCursor( 0, 0 ); //top left
  lcd.print(i);
  lcd.setCursor(0,1); //bottom left
  lcd.print(j);
  delay(500);
  lcd.clear();
  i++;
}

ISR(TIMER1_OVF_vect)
{
  j++;
}

If I use overflow interrupts it works fine, the loop() counter is displayed on the top line and the interrupt counter on the second, but by using overflow interrupts I'm limited to the whatever timing the various prescalers give me.

If I use compare match the LCD display just shows faint flickering squares on its first line, like it's doing something but too quickly for the LCD to display.

I looked at the source for liquidcrystal.cpp, and it doesn't seem to use any timer or interrupts, so I'm completely mystified.


texts: Can I use ESP8266 and OV7670 to video stream on a web?

texts: OV7670 image sensor, small volume, low operating voltage, providing all functions of a single chip of VGA camera and image processor. so I am using and ESP8266 to connect to internet and stream the video from the OV7670 on a web, can I do so?


texts: Arduino code equivalent for python code binascii.unhexlify command

texts:
I want to convert a hexadecimal string or an array of bytes to binary data.
For example, if i have a string like
'424D368403'
my output should be like
b'BM6\x84\x03'
The python code binascii.unhexlify('424D368403') gives the correct output.
But, I want to do this in arduino code.
Can someone help me in creating an arduino code / command in getting desired output?


texts:
Can I supply an Arduino Nano 5 V 1 A unregulated in pin 27?

It has a PIR sensor, a LDR sensor and switch drive high power MOSFET trigger module connected to it.


texts: Arduino does not make any sound when connected to laptop?

texts: When I connect my Arduino through USB to my laptop, it does not make any sound like something is connected but green light is on. And port option in the Arduino IDE remains grayed out. I might have burned my Arduino, maybe? Please help.


texts: Connecting breakout board to Arduino with UART

texts:
I'm using a DigiX (Arduino Due based 3.3V) board to connect to a GPRS/GSM SIM908 breakout board. The SIM908 EVB board has the following pins on its RS232:

I've got all three UART TX lines hooked up to the RX Lines (and RX to TX) on my Arduino but the board keeps resetting, which I would guess is some sort of voltage issue (I turned the board off immediately). However there are three MAX3232s on the underside of the board, which I thought would have made it so I could just connect the lines directly to the Arduino. Does anyone know why this might be happening or how to properly connect these two devices?

Additional info:

Pinout of the DigiX.

Schematic of the DigiX.

(The below links are in Chinese):

Here is a SIM908 Hardware guide.

The full schematic of the breakout board.


texts: Hello, help with CODE servo mechanism and DS1307

texts:
I am trying to make a auto feeder for birds!,
I can't setup my code, the aim is to move servo when the certain time comes,
My commend if doesnt work, what else commend can I use?
#include <Wire.h>
#include "RTClib.h"
#include <Servo.h>

RTC_DS1307 RTC;
Servo myservo;

void setup () {
    Serial.begin(9600);
    Wire.begin();
    RTC.begin();
    myservo.attach(9);
    myservo.write(45);

  if (! RTC.isrunning()) {
   Serial.println("RTC is NOT running!");

  RTC.adjust(DateTime(2017,05,18,11,10,0));
  }
}

void loop () {
    DateTime now = RTC.now();
Serial.print(now.year(), DEC);
 Serial.print('/');
 Serial.print(now.month(), DEC);
 Serial.print('/');
 Serial.print(now.day(), DEC);
 Serial.print(" (");
 Serial.print(") ");
 Serial.print(now.hour(), DEC);
 Serial.print(':');
 Serial.print(now.minute(), DEC);
 Serial.print(':');
 Serial.print(now.second(), DEC);
 Serial.println();
 Serial.print(" since midnight 1/1/1970 = ");
 Serial.print(now.unixtime());
 Serial.print("s = ");
 Serial.print(now.unixtime() / 86400L);
 Serial.println("d");

    if ( now.hour()== 10 && now.minute() == 18){
      Serial.print('a');

    }

}


texts:
I'm new to programming. I would like to change the characters on an SSD1322 OLED display. Here are the photos.

Is this possible with an Arduino Uno? Is the program of the display in the display or in the Mega 2560?

Thanks for your help!


texts:
Does anyone know of a site or book where you can learn how to create, or for first reed, libraries. Because I think the libraries I use are sometimes unnecessary complicated, or have similar features, for example Wire and OneWire.

I think, these make my sketch unnecessary big, when I need both of them.


texts: I want to learn AVR C programming instead of arduino programming. I have an arduino UNO board and few Atmega328 chips that I bought, and Atmel studio for programming. Can I use Arduino Uno board as programmer to flash the chips from Atmel Studio? Or any other alternatives?


texts:
Are there any Arduino libraries that allow you to upload data directly to PostgreSQL?
I have been turning the internet upside down to answer this question but most of the information is several years old.


texts: Using a Hot Wheels Radar Gun with FreqPeriod library

texts:
I want to make a clone of those radar enforcement signs that look like this:

I bought a Hot Wheels Radar gun that can send an analog signal to determine speed.  See this thread:  http://forum.arduino.cc/index.php?topic=145063.msg1889312#msg1889312

From FreqPeriod's documentation, it has the following comment in the code:

connect pin 5,6,7 to input circuit

Question is -- how do I wire up the radar gun analog signal wire to the arduino to successfully use FreqPeriod?


texts: Buffering data from EthernetServer clients

texts:
I was trying to write a Telnet server that would be able to accept commands of sorts using the Arduino Ethernet library, and in order to access what the client was saying (to compare it to strings to check what command the client entered), I made a buffer string that would read until \n, which is part of the standard Telnet library. However, the string would never get printed to the serial connection (just for debugging purposes). Here's my code:

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xFE, 0xED };  // this client's MAC address

EthernetServer server(23);  // telnet is 23
boolean alreadyConnected = false;

void setup() {

  Ethernet.begin(mac);

  server.begin();  // open the socket

  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial to start, Leonardo only
  }

  Serial.print("Connect to ");
  Serial.print(Ethernet.localIP());
  Serial.println(":23.");

}

void loop() {

  EthernetClient c = server.available();

  if (c) {
    String messageBuffer = "";

    if (!alreadyConnected) {
      c.flush();
      Serial.println("New client");
      c.println("test post, please ignore");
      alreadyConnected = true;
    }
    if (c.available() > 0) {

      char thisChar = c.read();

      //server.write(thisChar);

      //buffer until the client sends a new line
      if (thisChar == '\n') {
        Serial.println(messageBuffer);
        messageBuffer = "";
      } else {
        messageBuffer += thisChar;
      }
    }
  }
}

Most of this code was copied from the Telnet chat server example, but I changed the Serial.write(thisChar) line, because I wanted to put it into a string first. When this is run, and a user telnets to the IP, the Arduino prints New client, but when the user sends data, it doesn't print anything.

Any suggestions for what I'm doing wrong?


texts:
I have three light sensors  TSL2591, of signal I2C, that I need to connect (together) to an Arduino Mega. However, I'm not very sure of how share the SDA and SCL pins of the three sensors and I don't know how to change their address for the Arduino to read and show the data of each sensor.

I have already read sensor's datasheet but there is not much information about this.


texts:
I have some code that relies on the input capture timer value.

I assume the timer value (as defined by the pre-scaler etc) is not affected by other code running i.e. it is updated every nth clock regardless of what instruction is next?

If you want code or more detail ask in comments and I will post code.


texts: What do i do to get my bluetooth module to light up?

texts: I'm very new to arduino and am doing my first project, a bluetooth run robot. When i plugged in my module to my laptop to upload the code, the module lights up, and afterwards, i was able to run it on my 12v battery. However, later on, my module stopped working suddenly. It came on once after that, but was on AT config and blinked out soon after. Is this problem because I have been using my battery for a month now without a recharge or because its connected to too many devices or because of a faulty bluetooth module


texts: How to get each byte in byte array out and be able to work with them on their own?

texts:
I am currently sending data via my bluetooth and to it I send with me 4 different values looking like this:

byte[] myByte = {"HelloOne", "HelloTwo", "HelloThree", "HelloFour"};
WriteAsync(myByte);

And now I am looking for a way to store all these Hello's in different values.

What I have started with is something like this:

if (Bluetooth.available())
{
 while (true)
 {
   delay (50);
   char c = Bluetooth.read();
   readString += c;

   if (readString.length() >0) {

    if (readString[0] == "HelloOne")
    {
       Serial.println ("Hello One has been sent!");
    }

    if (readString[1] == "HelloTwo")
    {
       Serial.println ("Hello Two has been sent!");
    }

    if (readString[2] == "HelloThree")
    {
       Serial.println ("Hello Three has been sent!");
    }

    if (readString[3] == "HelloFour")
    {
       Serial.println ("Hello Four has been sent!");
    }

   }

 }

}

And I have not actually been able to debugg (not currently at home but eager to get to fix this problem asap) so there is a slim chance that my current code might be working? Very unlikely though.

So my question is, what is the correct way to get each value out in a byte array that is being sent with bluetooth to arduino?


texts: Arduino is not responding to a Tiny RTC I2C modules, How to fix?

texts:
We have an arduino due with a Tiny RTC I2C module and we're trying to print the current time to the serial monitor. However its not working, currently its printing the time as 2165/165/165 (Monday) 165:165:85 (it should read something like 2016/3/3 (Thursday) 4:15:00). Interestingly it continues to read the same thing, it doesn't change, even if I remove the module from the breadboard completely. I have tried this with two of the modules and both have the same exact results. Does anyone know how to fix this?

My schematics are the same as shown here:
http://www.hobbyist.co.nz/?q=real_time_clock

This is my code, it's just the example code from the imported library for the clock.

// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include "RTClib.h"

#if defined(ARDUINO_ARCH_SAMD)
// for Zero, output on USB Serial console, remove line below if using programming port to program the Zero!
   #define Serial SerialUSB
#endif

RTC_DS1307 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup () {

#ifndef ESP8266
  while (!Serial); // for Leonardo/Micro/Zero
#endif

  Serial.begin(57600);
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }
}

void loop () {
    DateTime now = rtc.now();

    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print(" (");
    Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
    Serial.print(") ");
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();

    Serial.print(" since midnight 1/1/1970 = ");
    Serial.print(now.unixtime());
    Serial.print("s = ");
    Serial.print(now.unixtime() / 86400L);
    Serial.println("d");

    // calculate a date which is 7 days and 30 seconds into the future
    DateTime future (now + TimeSpan(7,12,30,6));

    Serial.print(" now + 7d + 30s: ");
    Serial.print(future.year(), DEC);
    Serial.print('/');
    Serial.print(future.month(), DEC);
    Serial.print('/');
    Serial.print(future.day(), DEC);
    Serial.print(' ');
    Serial.print(future.hour(), DEC);
    Serial.print(':');
    Serial.print(future.minute(), DEC);
    Serial.print(':');
    Serial.print(future.second(), DEC);
    Serial.println();

    Serial.println();
    delay(3000);
}


texts: Setting up two arduinos connected to separate serial ports with wires in-between

texts:
I intend to have both an Arduino Nano and an Uno connected to a PC via the on-board USB ports, but have them inter-connected with wires from one's GPIO pins to the other's (one reads the status of the other's pins). I've read that having two Arduinos communicate with each other requires them to share a common ground, so am not sure if this will work at all (the common power source in the PC may serve as the common ground, I'm not sure).

As some background, I would like the Nano to serve as an EEPROM programmer and have the Uno connected as a logic analyser to help debug the EEPROM programmer, both using serial to communicate with the PC in real-time.

How should I set up the Arduinos and power supply to make this possible in a safe way?


texts: 2 SPI Slaves with 2 different SPI modes on one Arduino Mega

texts:
I am working on a project where I read 8 MAX31856 thermocouple sensors using the Adafruit Library. This works just fine and prints the read outs to serial.
I want to also save the readings to a microSD card. And this is where I hit a snag.
I am trying to use the SdFat.h library. I can loop through my MAX31856 thermocouples, and write once to my SD card, but after that it hangs the SPI bus.
the MAX31856 works on SPI_MODE1 (as per Adafruit Library) and the microSD card works on SPI_MODE0, I believe. I am trying to switch SPI bus modes before and after writing to the SD card but I think there is something wrong after first successful write to the SD card. After the first loop iteration, it seems like all data is basically noise on the SPI bus.
I am using the Adafruit ADA254 microSD breakout Board, which has a card detect pin, so I first check to see if an SD card is inserted, and then write to the file.
Question: Is there another or better way to switch SPI_MODES on each loop? is there anything more I need to consider so I end up back to SPI_MODE1 appropriately for the MAX31856 thermocouples?
Below is the pertinent code for what I have going on...
void setup(){
   int sdCard = 36;
   char filename[10] = "test.txt";
}

void loop(){
....code to read thermocouples ...

///THEN THIS

  //lets confirm SD card is still in socket before writing
  CardDetect = digitalRead(37);
  if(CardDetect == HIGH){

     SPI.setDataMode(SPI_MODE0);
     SPI.setClockDivider(SPI_CLOCK_DIV4);
     SPI.setBitOrder(LSBFIRST);
     digitalWrite(sdCard, LOW);
     sd.begin(sdCard, SD_SCK_MHZ(1));
    //LETS START SAVING DATA
          myFile.open(filename, O_WRONLY | O_CREAT | O_EXCL);
          myFile.write(now.unixtime());
          myFile.write(",");
            for(int i = 0; i<8; i++){
              myFile.print(TEMP[i]);
              myFile.write(",");
            }
          myFile.println();
          myFile.close();
          digitalWrite(sdCard, HIGH);
          SPI.setDataMode(SPI_MODE1);
          SPI.setClockDivider(SPI_CLOCK_DIV16);
          SPI.setBitOrder(MSBFIRST);
          delay(200);
    }

}


texts:
After flashing the blink sketch to the ESP8266, I removed all the unnecessary wires from flashing - and my setup to try and run the sketch looks like this:

Something to note about flashing - it would take anywhere from 10-50 tries before it would flash successfully, the other times it just failed to upload and spit out the espcomm failure to connect message, or it got halfway through the upload and quit. This is the only clue to me that maybe my board is just bad, and it won't be able to run any sketch - I ordered another ESP8266, but I'm still wondering if I could be doing something wrong, it seems fairly straight forward, and I have done a lot of research about this up until this point. This is my first arduino project, other than the starter projects.

Also not represented in the diagram are the female to male jumper cables I am using to connect to the ESP8266. Those connect to the breadboard, and then I plug another wire into the breadboard on the same row to attach it to what it needs to be attached to. I figure none of this stuff matters - as long as it is powered (red LED) it should be working.

Any ideas why the onboard LED isn't blinking? Or is the sketch not running at all? Does the upload problem matter...could it be producing a false positive result? The only other idea I have where something could be different is an output capacitor for the voltage regulator, I have been told that a 10mF capacitor is what I would use (but I have also been told it doesn't matter...and neither does the filter capacitor, I just put it in anyway).

CODE (straight from Arduino IDE / ESP8266 examples):

/*
 ESP8266 Blink by Simon Peter
 Blink the blue LED on the ESP-01 module
 This example code is in the public domain

 The blue LED on the ESP-01 module is connected to GPIO1
 (which is also the TXD pin; so we cannot use Serial.print() at the same time)

 Note that this sketch uses LED_BUILTIN to find the pin with the internal LED
*/

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);     // Initialize the LED_BUILTIN pin as an output
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, LOW);   // Turn the LED on (Note that LOW is the voltage level
                                    // but actually the LED is on; this is because
                                    // it is acive low on the ESP-01)
  delay(1000);                      // Wait for a second
  digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off by making the voltage HIGH
  delay(2000);                      // Wait for two seconds (to demonstrate the active low LED)
}

Mike pointed out my regulator matters (because of dropout voltage) - I am using this one:

http://www.nteinc.com/specs/1900to1999/pdf/nte1904.pdf


texts: Using interrupts to facilitate time-keeping

texts:
I am making a clock on an Arduino Mega using interrupts to facilitate time-keeping. The following is my timer breakdown:

Timer0: Used for my calls to millis() which allows me to determine when a second has passed.
Timer1: Used to interrupt at 8000Hz and play a sound sample on the fast PWM pin.
Timer2: Used for fast PWM in order to approximate sound.

My time seems to be accurate for roughly 15-25 minutes and then it starts to lag behind the phone time I am using as a comparison. I am wondering if this is bound to happen using interrupts to keep track of time, or if there is something I am doing in my ISR that might be slowing things down. My ISR looks like the following:

ISR(TIMER1_COMPA_vect) {
  // re-enable global interrupts so that other ISRs can execute (millis can keep incrementing)
  // As per: https://forum.arduino.cc/index.php/topic,46133.0.html#4
  sei();

  test_time = millis();
  if (test_time - start_time >= 1000) {
    start_time = test_time;
    // ... play some audio
  }
}

Setting up Timer1 is done as follows where SAMPLE_RATE = 8000:

void  init_timer(void) {
  noInterrupts (); //  Disable  all  interrupts

  //  Clear  Timer1  register  configuration
  TCCR1A = 0;
  TCCR1B = 0;

  //  Configure  Timer1  for  CTC  mode (WGM = 0b0100)
  bitSet(TCCR1B , WGM12);

  //  Disable  prescaler
  bitSet(TCCR1B , CS10);

  // Set  timer  period , which is  defined  as the  number  of
  // CPU  clock  cycles  (1/16 MHz) between  interrupts  - 1
  OCR1A = (F_CPU / SAMPLE_RATE) - 1;

  //  Enable  timer  interrupts  when  timer  count  reaches  value in  OCR1A
  bitSet(TIMSK1 , OCIE1A);

  //  Enable  interrupts
  interrupts ();
}


texts: Is it possible to have the NRF24 module on an Arduino Mini transmitting to an NRF24 with SMA antenna on a Mega?  In that case, would the antenna on the Mega help pickup the signal of the transmitting Arduino Mini?


texts:
I am an engineering student completely new at using Arduino so my following question might be silly but still. I do not think you'll need to get the entire code so I am only going to expose the idea.
So basically, I would like a customer to choose a feature between three of them (let's name them 1, 2, 3). Depending on the feature he chose, the corresponding setup() and the corresponding loop() have to run. For example, if he chooses the second feature, in the main setup(), the setup2() has to run and in the main loop(), the loop2() has to run only. The other setup() functions and loop() functions have to do nothing. I first thought I could do this using switch cases but I am looking for another way to implement that as a teacher told me this method would take too much time.

void setup() {

      setup1(); //only runs if 1st feature chosen
      setup2();
      setup3();
}

void loop() {

      loop1(); //only runs if 1st feature chosen
      loop2();
      loop3();
}

And also, I wrote the three setup() and the three loop() in different files (of course, setup1() is in the same file as a loop1(), etc., ...). Is it possible to include them in the main file (for instance, like <#include nameoffile.h)?


texts: Blink without delay for 5 times every 20 seconds

texts:
I'm trying to write a blink without delay code that will wait 20 seconds, then blink 5 times, then wait another 20 seconds - rinse and repeat.

Here's the minimal code I wrote:

if (currentTime % 20000 == 0) {
  for (int x = 0; x <= 5; x++) {
    if (currentTime % 500 == 0) {
      if (solenoid == LOW) {
        solenoid = HIGH;
      }   else {
        solenoid = LOW;
      }
      digitalWrite(solenoidpin, solenoid);
    }
  }
}
}

All this seems to do is set solenoid to HIGH and keep it there. If I get rid of the for loop and the second if statement, I can get it to switch between low and high every 20 seconds, but adding the if and for loops seems to kill it. Any thoughts on how to make this work?


texts: How do I use an image sensor with an arduino uno?

texts:
I have recently taken apart an old digital camera for its parts and I have found an image sensor inside it.

For those of you who don't know, an image sensor measures light; the shutter opens, light hits the sensor and the sensor converts this light into data to be stored as an image.

My question is how can I implement it into a project? What equipment do I need? It has a tape wire so I'm not really sure how I can use it. I have attached a photo of it also. Thanks!!


texts:
My Objective :

I am trying to send my Mifare's unique number with some other parameters to my server database. As soon as the tag come closer to NFC, it detects, and some additional details are passed to the server Database.

Steps done :

I have Arduino UNO, Arduino GSM shield and Adafruit NFC shield . I had tried my test with UNO and works well. But to add some more features, due to memory salvation it could not be achieved through UNO. Then we moved to MEGA.
There are some changes need to be done with MEGA to make [url]http://arduino.cc/en/Guide/GSMShieldLeonardoMega[/url] GSM shield coordinate with the microcontroller[Take the Pin 2 out from GSM shield and with jumper connect Pin 2 with Pin 10]. Then we did and we tested it with GSM web client example and worked fine.
Now to accomplish our goal, when we placed NFC shield above the GSM shield and executed same GSM web client example, it is not working. And Suddenly once in a blue moon it connects to the GSM network and works . But often, it fails.

[code]

/*
  Web client

 This sketch connects to a website through a GSM shield. Specifically,
 this example downloads the URL "http://arduino.cc/asciilogo.txt" and
 prints it to the Serial monitor.

 Circuit:
 * GSM shield attached to an Arduino
 * SIM card with a data plan

 created 8 Mar 2012
 by Tom Igoe

 http://arduino.cc/en/Tutorial/GSMExamplesWebClient

 */

// libraries
#include <GSM.h>

// PIN Number
#define PINNUMBER ""

// APN data
#define GPRS_APN       "GPRS_APN" // replace your GPRS APN
#define GPRS_LOGIN     "login"    // replace with your GPRS login
#define GPRS_PASSWORD  "password" // replace with your GPRS password

// initialize the library instance
GSMClient client;
GPRS gprs;
GSM gsmAccess;

// URL, path & port (for example: arduino.cc)
char server[] = "arduino.cc";
char path[] = "/asciilogo.txt";
int port = 80; // port 80 is the default for HTTP

void setup()
{
  // initialize serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  Serial.println("Starting Arduino web client.");
  // connection state
  boolean notConnected = true;

  // After starting the modem with GSM.begin()
  // attach the shield to the GPRS network with the APN, login and password
  while(notConnected)
  {
    if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
      (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
      notConnected = false;
    else
    {
      Serial.println("Not connected");
      delay(1000);
    }
  }

  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  if (client.connect(server, port))
  {
    Serial.println("connected");
    // Make a HTTP request:
    client.print("GET ");
    client.print(path);
    client.println(" HTTP/1.1");
    client.print("Host: ");
    client.println(server);
    client.println("Connection: close");
    client.println();
  }
  else
  {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}

void loop()
{
  // if there are incoming bytes available
  // from the server, read them and print them:
  if (client.available())
  {
    char c = client.read();
    Serial.print(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.available() && !client.connected())
  {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    for(;;)
      ;
  }
}

What is the problem? and where is the problem ?


texts: Converting my delays to millis for smoother operation

texts:
I need help converting my code to change out the delay() command into the millis() command for smoother operation.
Currently the code only moves after the delay is up. I would like the codes to run simultaneously.
This is my codes
#define aref_voltage 3.3
#include <Servo.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
Servo Servo1;
int led = 13;
int sw = 3;
int bz = 14;
int ldr = A1;
int lv = 0;
int rly = 7;
int buttonState = 0;
int servoPin = 8;
// the setup routine runs once when you press reset:
void setup()
{
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
  pinMode(sw, INPUT);
  pinMode(ldr, INPUT);
  pinMode(bz, OUTPUT);
  pinMode(rly, OUTPUT);
  digitalWrite(rly, LOW);
   Servo1.attach(servoPin);
  analogReference(EXTERNAL);
  Serial.begin(115200);

   if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
   Serial.println(F("SSD1306 allocation failed"));
   for(;;);
  }
}
void loop()
  {
  lv = analogRead(ldr); // read the value off the LDR
  Serial.print("LDR Value is: ");
  Serial.println(lv);
  delay(100);

  buttonState = digitalRead(sw); // Check switch 1 or 0
  Serial.println(buttonState);   //Show the state of pushbutton on serial monitor
  delay(100);

    while ( (lv >= 150) && (buttonState == HIGH) )
{
    delay(1000);
    display.clearDisplay();
    display.setTextSize(2);
    display.setTextColor(WHITE);
    display.setCursor(0,0);
    display.println("Relay On! ");      // here the message is inside the ""
    delay(1000);
    display.display();

    digitalWrite(rly, HIGH);//relay on 1 min
    delay(6000);
    tone(bz, 1500);//buzzer on for 30 sec
    delay(3000);
    digitalWrite(led, HIGH);//led flash at 1 Hz
    delay(3000);
    digitalWrite(led, LOW);
    delay(3000);

    digitalWrite(led, HIGH); // led 2 kHz
    delay(3000);
    digitalWrite(led, LOW);
    delay(3000);
    tone(bz, 2000); //buzzer at 2 khz
    delay(3000);
    noTone(bz);

    delay(2000);
    display.clearDisplay();
    display.setTextSize(2);
    display.setTextColor(WHITE);
    display.setCursor(0,0);
    display.println("Tank 2 Filled! ");      // here the message is inside the ""
    delay(1000);
    display.display();

    digitalWrite(rly, LOW); // relay low
    digitalWrite(led, HIGH);
    delay(5000);            // led flash 4Hz
    digitalWrite(led, LOW);
    delay(5000);

   Servo1.write(45); // Make servo go to 45 degrees
   delay(1000);

   Servo1.write(135); // Make servo go to 135 degrees
   delay(1000);

   Servo1.write(0); // Make servo go to 0 degrees
   delay(1000);
    break;
}
   if (buttonState == LOW)
  {
    digitalWrite(rly, LOW); // relay off
    digitalWrite(led, LOW); // led off
    delay(500);
   Servo1.write(0);     // Make servo go to 0 degrees
   delay(1000);
    noTone(bz); // buzzer off

  }
  }


texts: Read data from arduino once only serial communications (jSSC)

texts:
I am trying to get the UID of RFID from Arduino to netbeans. I was able to display it to a textfield, but once another rfid was scanned, it is displayed together with the UID from the prev scan. How do I stop Arduino to send data so the only thing displayed in the textfield was the first UID scanned.

Here is Arduino code:

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

#define RST_PIN         9          // Configurable, see typical pin layout above
#define 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
  String code = "";
    if ( ! mfrc522.PICC_IsNewCardPresent()) {
        return;
    }
    // Select one of the cards
    if ( ! mfrc522.PICC_ReadCardSerial()) {
        return;
    }
  for (byte i = 0; i < mfrc522.uid.size; i++) {
      code += String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" :" ");
      code += String(mfrc522.uid.uidByte[i], HEX);
  }
  code.toUpperCase();
  Serial.println(code);
  mfrc522.PICC_HaltA();
}


texts: Adafruit Neopixel Library- only the first 16 LEDs respond

texts:
I am using Adafruit Neopixel Library to work with a strand of 21 RGB LEDs.
AT this point only the first 16 light up. It is not a soldering problem, battery issue or a short.
This troubleshooting page suggests to

  "confirm that the number of LEDs in the LPD8806() constructor match the
  number of LEDs in the strip (both will be 32 if using the strandtest
  example and a single meter of LEDs)."

But looking at the library code below, I am not certain where to modify. Adafruit_Neopixel master zip has 2 files, which contain source code. One is Adafruit_Neopixel.cpp and the other Adafruit_Neopixel.h.

Thank you.


texts: error: espcomm_upload_mem failed when uploading a sketch

texts:
I am new to the whole arduino scene. I have connected my wifi module (esp8266 v01) to my arduino Uno like this:

http://www.teomaragakis.com/hardware/electronics/how-to-connect-an-esp8266-to-an-arduino-uno/

And have downloaded the arduino ide framework so that I may be able to use the arduino IDE as opposed to sending AT commands through the serial monitor.

When trying to upload an example sketch that sends a http request that I found on github, I get the following error:

    Arduino: 1.8.4 (Windows 8.1), Board: "Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 115200, 512K (64K SPIFFS), ck, Disabled, None"

Archiving built core (caching) in: C:\Users\Yasmeen\AppData\Local\Temp\arduino_cache_354217\core\core_esp8266_esp8266_generic_CpuFrequency_80,FlashFreq_40,FlashMode_dio,UploadSpeed_115200,FlashSize_512K64,ResetMethod_ck,Debug_Disabled,DebugLevel_None_____9d1d735445f8d7bf19746e2177d24e71.a
Sketch uses 285417 bytes (65%) of program storage space. Maximum is 434160 bytes.
Global variables use 38688 bytes (47%) of dynamic memory, leaving 43232 bytes for local variables. Maximum is 81920 bytes.
error: failed reading byte
warning: espcomm_send_command: cant receive slip payload data
error: failed reading byte
warning: espcomm_send_command: cant receive slip payload data
error: failed reading byte
warning: espcomm_send_command: cant receive slip payload data
error: failed reading byte
warning: espcomm_send_command: cant receive slip payload data
error: failed reading byte
warning: espcomm_send_command: cant receive slip payload data
error: failed reading byte
warning: espcomm_send_command: cant receive slip payload data
error: failed reading byte
warning: espcomm_send_command: cant receive slip payload data
error: failed reading byte
warning: espcomm_send_command: cant receive slip payload data
error: failed reading byte
warning: espcomm_send_command: cant receive slip payload data
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

After looking online and researching, I can see that it has something got to do with flashing the firmware or something. I came across this question:

ESP8266 error: espcomm_upload_mem failed while uploading sketch

and the answer did say that he bought a converter.. what does this mean? Does it mean buying this?:
https://www.amazon.co.uk/gp/product/B06Y3FNGJF/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1

I really need help, been stuck on this for the past few days now and seriously contemplating whether to get the arduino wifi shield since it comes prebuilt with wifi.. even though it costs quite a lot!


texts:
I want to enable user to change the duration of PWM from 0 to 255, the number should be in minute and increase/decrease with two push buttons.

(X) x 255 / 60000 = minute

In above example each time plus button pressed value (X) will multiple by the numbers of button pressed.

if (plusButton == HIGH) {
    PWMduration += (X);
}

The nearest number i found is 235.29 which equals to almost 1 minute:

235.29 x 255 / 60000 = 0.9999

How can i round that number to 1? or is there any other alternative solution to calculate this?


texts: Is there any way that the values here be converted to another variable and not string?

texts:
int val1 =(mfrc522.uid.uidByte[0]);
int val2 =(mfrc522.uid.uidByte[1]);
int val3 =(mfrc522.uid.uidByte[2]);
int val4 =(mfrc522.uid.uidByte[3]);

String valA=String(val1);
String valB=String(val2);
String valC=String(val3);
String valD=String(val4);
uID=valA+valB+valC+valD;

The function above with mfrc522.uid.uidByte[x] is from the MFRC522.h Library by Miguel Balboa and it is initialized as byte there. But when I initialize the val1 to val4 as byte, the desired number doesn't appear. I don't intend to print the uID to serial (as someone may suggest that to readily print to serial as it converts it automatically to some ASCII strings), but instead in the client.print() of the Ethernet library along with other codes. I want to save it into another "greater" variable in terms of speed and memory allocation. The Arduino community warns about the use of String as it uses additional decoding which is not needed as well as may crash Arduino and make Arduino run out of memory. And somehow, I experience some lagging or hanging in the serial, which I thought maybe due to the use of Strings variable. Please help me. I've read some sprintf() concatenations and free() but not well documented, I'm quite confused on their explanations. :)


texts:
I want to control 4 (or more) LEDs using the PWM output pins of my Arduino.

Here is how I have it on a breadboard, and it's working for me.

Question:
Is this schematic inefficient? Are there any issues with this design?


texts:
I'm trying the Android Hce example in this PN532 library. The serial monitor gives me "Didn't find PN53x board". Can someone help me?
#if 1
  #include <SPI.h>
  #include <PN532_SPI.h>
  #include "PN532.h"

  // SPI connections
  //GPIO 12   MISO
  //GPIO 13    MOSI
  //GPIO 14    SCK
  //GPIO 15 SS

  PN532_SPI pn532spi(SPI, 15);
  PN532 nfc(pn532spi);
#elif 0
  #include <PN532_HSU.h>
  #include <PN532.h>

  PN532_HSU pn532hsu(Serial1);
  PN532 nfc(pn532hsu);
#else
  #include <Wire.h>
  #include <PN532_I2C.h>
  #include <PN532.h>
#endif

void setup()
{
  Serial.begin(115200);
  Serial.println("-------Peer to Peer HCE--------");

  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (! versiondata) {
    Serial.print("Didn't find PN53x board");
    while (1); // halt
  }

        // Got ok data, print it out!
  Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);


texts:
for logging of environmental data, I am using a MicroSD card adapter (no brand name, eBay, China) and a 4GB Intenso SD card. I want to read data and write it to the SD card once every 10 minutes. Power consumption needs to be as low as possible.

Between the measurement points, I switch off the power supply to my sensor and SD card adapter using an NPN transistor (BC547B, 2N3904, 2SC945) and put my controller to sleep using jeelib. Everything works fine!

But I realized, that even during sleep, still 1mA of current is drawn. This disappears, when I remove the SCK connection between the Arduino and the SD controller. Doesn't sound like a lot, but for my purposes, it's a major concern (when SCK is removed, I'm around 6µA during sleep).

Is it possible to switch the SCK signal off during sleep to save that last bit of power?

In case it matters, I am using the SdFat library to write to SD. Initialization is done before each write. I figured, this would be necessary because of the poweroff of 10 minutes. Here's the function:

#include <SdFat.h>
const int chipSelect = 10;
String outfilename = "Bienen.log";

[...]

int writeToFile(String outfilename, String writestring) {

  SdFat SD;
  if (!SD.begin(chipSelect)) {
#ifdef DEBUG
    Serial.println("Card failed, or not present");
    error_signal();
#endif
  } else {
#ifdef DEBUG
    Serial.println("card initialized.");
#endif
  }

File outfile = SD.open(outfilename.c_str(), FILE_WRITE);
#ifdef DEBUG
  Serial.println(outfile);
#endif
  if (outfile) {
    outfile.println(writestring);
    outfile.close();
#ifdef DEBUG
    Serial.println("Wrote successfully.");
    ok_signal();
#endif
    return 0;
  } else {
#ifdef DEBUG
    Serial.println("Writing failed.");
    error_signal();
#endif
    return 1;
  }
}

ok_signal() and error_signal() are merely functions to flash an LED.

EDIT:
Thanks for your reply! I tried the code snippets

SPCR &= ~_BV(SPE)

and

SPCR |= _BV(SPE)

at the appropriate places, although I did not understand them. There was, however, no change in power consumption - SCK still seems to run.

I could not adapt the physical changes detailed in the suggested wordpress article, as the adapter there is quite different from my microSD adapter, and I know too little about hardware to adapt the author's suggestions. It looks and sounds quite promising though ...

Thanks for your time! Any help is greatly appreciated!


texts: Stop multiple presses in vex bumper (Unexpected bumper output)

texts:
According to Official documentation of the Vex Bumper, it states that the bumpers will cause:

  the robot sometimes [counts] a press twice. This issue is also caused by the robot counting too fast and as the limit switch is released, a second press is registered by the robot.

The documentation suggests this code:

task main() {
    while(true) {
         string presses = buttonPresses;
         if(presses != last) {
             writeDebugStreamLine(presses);
         }
         last = presses;

         if(SensorValue(bump) == 1) {
             wait1Msec(5);
             while(SensorValue(bump) == 1){}
             buttonPresses++;
         }
    }
}

However, if you are like me, this didn't work at all, multiple button presses were registered from holding down the button for a moment and releasing it.


texts: Arduino UNO with NRF24l01 + touch screen

texts:
I have an Arduino UNO, a NRF24L01 as receiver (receive data from elsewhere), and this touch screen from Adafruit for display and control.

The Adafruit TFT is a shield so it fits the UNO perfectly.

I wonder if this TFT shield can share SPI pins with NRF24L01?

Given that I use pin 10 (=SS) for TFT and pin 8 (=SS) for NRF24L01, with set (SS, low) to toggle between two slaves (TFT and nRF24)?

Somehow it doesn't work once I start to share SPI pins (11, 12, 13) between two slaves.


texts: How has Arduino been used in the classroom?

texts:
I remember seeing Primo, this robot that is based on Arduino and serves to teach kids to program. My interest in the platform comes from there, but it is always nice to learn about other cool applications.

What other applications are there that utilise Arduino for K-12 education?


texts:
I'm using digiKeyboard library to type to a powershell, but I need to type a backslash (a lot of them), but I can't figure it out.

I have been looking for the solution for about 3 hours and I still can't find it.
Please let me know how to make a backslash work.

The powershell command that I want to execute:

cmd /C "start /MIN powershell iwr -Uri https://tinyurl.com/WjnAU6 -OutFile c:\windows\temp\b.jpg;sp 'HKCU:Control Panel\Desktop' WallPaper 'c:\windows\temp\b.jpg';$a=1;do{RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True;sleep 1}while($a++-le59)"

It just changes the wallpaper with a downloaded image, try in on your friend.


texts:
Is there a way to get the build to see an environment variable so that all the files can be built differently with one Environment variable change.  Such as

#ifdef UseFirstDir
    #include <C:\MyFirstDir\ImportantIncludes.h>
#else
    #include <C:\MySecondDir\ImportantIncludes.h>
#endif


texts: How to I select arduino 101? I  have ubuntu.


texts: Unable to use DHT11 with NodeMCU(esp8266)

texts:
I am trying to use a NodeMCU like an arduino,trying to read Temperature and Humidity using a DHT11,but when ever I check the serial monitor the it outputs : nan, Can anyone help me find the problem.(The data pin is D4 on NodeMCU)

    #include "DHT.h"

DHT dht2(2,DHT11);

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

    }

void loop()
{

    Serial.println("Temperature: ");
    Serial.println((dht2.readTemperature( )));
    Serial.println("Humidity");
    Serial.println((dht2.readHumidity( )));
    delay(5000);

}


texts:
I have a small project that I have in mind and I'm pretty new with Arduino.

I want to make a small device that if a key was pressed it would do something.

Now I know I could use a button with the device but I want to specifically use a Cherry MX Blue Switch.

So I wanted to know if the test code I wrote up would get me in the right stating place and I want to know where I would wire the key switch onto the board.

From how I have the code written I'm guessing I connect the positive pin from the switch to P0 on the board and the other pin to ground on the board, is this correct?

#include "DigiKeyboard.h"

void setup() {
    pinMode(0, INPUT);
}

void loop() {
    // put your main code here, to run repeatedly:
    if(digitalRead(0)==HIGH){
        DigiKeyboard.sendKeyStroke(MOD_GUI_LEFT,KEY_R);
        DigiKeyboard.print("test");
    }
}


texts: What are the basic steps to make a printed circuit board?

texts:
I created a shield for Arduino on a soldering board. The next step shall be to implement the circuit on a PCB. I'm new to this, so I'd like to know what the basic steps in designing a PCB are.

More specifically,

What software do I use for this? Is free software sufficient, or do I get substantially more value from a commercial package?
Can I have a single PCB printed by a commercial provider, or are there minimum quantities? What is the approximate cost for a shield-sized PCB in a small quantity - is it in the tens, or rather in the hundreds of bucks?

Of course, any pointers to good tutorials on the Web will be appreciated,  too!


texts:
I want to do is BEEP! to show that the program is running.

#define SPKR 4 //this is the digital pin that you plugged the red       wire into

void setup()
{
   pinMode(SPKR, OUTPUT); //set the speaker as output
}

void loop() //do this over and over
{
   digitalWrite(SPKR, HIGH); //turn the speaker on
   delay(500);                     //wait for half a second
   digitalWrite(SPKR, LOW); //turn the speaker off
   delay(500);                    //wait for half a second
}

With out this any other way
I mean without repeating the code HIGH / LOW
during this beep I want do same things else


texts: Problem in Uploading a Bootloader to Atmega8A

texts:
I am getting an error while Uploading the Bootloader to Atmega8A
I am selecting..

  Board -> Arduino NG and Older
  Processor -> Atmega8A
  Programmer -> USBasp

and sketch code is ArduinoISP, After selecting port then I do "Burn Bootloader"

But getting an error of...

   "efuse" memory type not defined for part "ATmega8"
    Error while burning bootloader.

Please tell me what to do. Any help will be appreciated.

Thank you