text:
Proper Attiny85 timer/delay
Im having problems with Attiny85 programming. I am making something similar like this project. But i added function that every day on some time it turns on output - something like alarm clock. The real struggle is to make it active for longer time as one minute.. If current time is equals alarm time wake_HOUR==hour()& wake_MINUTE==minute() then it will run only for a minute so I added changeable field for the time how long output should be active - for example 5 minutes despite 1 minute. I tried to make timer with millis() and after those 5 minutes reset timer but this is where i stuck, because compiling for attiny it shows error, but if i use same code sample just for arduino then its working.. Code below:
#include <avr/sleep.h>
#include <TinyWireM.h>
#include <EEPROM.h>
#include "ssd1306.h"
#include "WDT_Time.h"

#define TIMEOUT 6000            //display timeout
#define UNUSEDPINA 1            //RESET
#define ALARM 4                 //ALARM
#define BUTTONPIN  3            //GND
unsigned int wake_HOUR = 0;     //Hours when it should wake up
unsigned int wake_MINUTE = 0;   //Minutes when it should wake up
unsigned int wake_SECOND = 0;   //Seconds when it should wake up - Not using
unsigned long ALARM_TIME;       //How long alarm should be active- changable in display
unsigned long new_millis = 0;   //Timer
unsigned long interval;         //How long alarm should be active
extern volatile unsigned long timer0_millis;
unsigned int ACTIVE_ALARM = 0;  //alarm activated?

#define SET_UP_BUTTON_THRESHOLD 100   //100k
#define UP_DOWN_BUTTON_THRESHOLD 600  //7k
#define PRESSED_BUTTON_THRESHOLD 1000 //NO resistance

// enum
typedef enum {
normal, sleeping
}  run_status_t;

typedef enum {
time_mode, debug_mode, alarm_mode
}  display_mode_t;

// button field constant
#define NO_FIELD 0
#define YEAR_FIELD 1
#define MONTH_FIELD 2
#define DAY_FIELD 3
#define HOUR_FIELD 4
#define MINUTE_FIELD 5
#define SECOND_FIELD 6
#define ALARM_HOUR_FIELD 7      //Alarm Hour
#define ALARM_MINUTE_FIELD 8    //Alarm Minute
#define ALARM_FIELD 9           //How long should alarm be active - minutes
#define SET_ALARM_FIELD 10      //Activate alarm
#define FIELD_COUNT 10
//#define ALARM_SECOND_FIELD 9

// variables
SSD1306 oled;
static uint32_t display_timeout = 0;
static run_status_t run_status = normal;
static display_mode_t display_mode = time_mode;
static display_mode_t last_display_mode = time_mode;
static bool time_changed = false;
static bool alarm_changed = false;
static uint8_t selected_field = NO_FIELD;

uint8_t wake_SET = 0;
//const char wake_BACK[15] = "GO BACK";

void setup() {
  // setup input pins, also pullup unused pin for power saving purpose
  pinMode(UNUSEDPINA, INPUT_PULLUP);
  pinMode(BUTTONPIN, INPUT_PULLUP);
  pinMode(ALARM, OUTPUT);
  digitalWrite(ALARM, LOW);
  interval = ALARM_TIME*60000;

  // init time
  init_time();

  // init I2C and OLED
  TinyWireM.begin();
  oled.begin();
  oled.fill(0x00); // clear in black

  // init display timeout
  set_display_timeout();
}

void loop() {
  // detect and handle button input
  check_button();
  unsigned long currenTime = millis();
  //unsigned long new_value;
  //setMillis(new_value);

  if (run_status == sleeping) {
    // return to sleep mode after WDT interrupt
    system_sleep();
  } else { // not sleeping
    if (millis() > display_timeout) { // check display timeout
      enter_sleep();
    } else { // normal flow
      readRawVcc();
      readRawTemp();
      draw_oled();
    } // normal flow
  } // not sleeping
  if (ACTIVE_ALARM==1)
  {
    if (wake_HOUR==hour()& wake_MINUTE==minute())
    {
    digitalWrite(ALARM, HIGH);
    new_millis = millis();
    }
    else if (currenTime -new_millis <= interval)
    {
    new_millis = millis();
    digitalWrite(ALARM, HIGH);
    }
    else if (currenTime -new_millis >= interval)
    {
    new_millis = 0;
    digitalWrite(ALARM, LOW);
    }}
  else if (ACTIVE_ALARM==0)
  {
    new_millis = 0;
    digitalWrite(ALARM, LOW);
  }
}
//void setMillis(unsigned long new_millis){
//  uint8_t oldSREG = SREG;
//  cli();
//  timer0_millis = new_millis;
//  SREG = oldSREG;
//}

void enter_sleep() {
  oled.fill(0x00); // clear screen to avoid show old time when wake up
  oled.off();
  delay(2); // wait oled stable

  run_status = sleeping;
}

void wake_up() {
  run_status = normal;

  delay(2); // wait oled stable
  oled.on();

  // update display timeout
  set_display_timeout();
}

void set_display_timeout() {
  display_timeout = millis() + TIMEOUT;
}

/*
 * UI related
 */

void draw_oled() {
  if (display_mode != last_display_mode) {
    oled.fill(0x00);
    last_display_mode = display_mode;
  }
  oled.set_font_size(1);
  if (display_mode == time_mode) {
    // 1st row: print info
    oled.set_pos(5, 0);
    oled.print("TIME");
    oled.set_pos(80, 0);
    oled.print("AcALARM=");
    oled.print(digitalRead(ACTIVE_ALARM));
    oled.set_pos(80, 1);
    oled.print("A_TIME=");
    oled.print(digitalRead(ALARM_TIME));
    oled.set_pos(80, 2);
    oled.print("ALARM=");
    oled.print(digitalRead(ALARM));

    // 2nd row: print date
    print_digit(7, 1, year(), (selected_field == YEAR_FIELD));
    oled.write('-');
    print_digit(7 + (5 * FONT_WIDTH), 1, month(), (selected_field == MONTH_FIELD));
    oled.write('-');
    print_digit(7 + (8 * FONT_WIDTH), 1, day(), (selected_field == DAY_FIELD));

    // 3rd-4th rows: print time
    oled.set_pos(30, 4);
    oled.print("SET ALARM");
    oled.set_pos(3, 5);
    oled.print("HH:MM-->ALARM MIN");
    oled.set_pos(95, 5);
    oled.print("ON/OFF");
    oled.set_font_size(2);
    print_digit(0, 2, hour(), (selected_field == HOUR_FIELD));
    oled.draw_pattern(2 * FONT_2X_WIDTH + 1, 2, 2, 2, 0b00011000);
    print_digit(2 * FONT_2X_WIDTH + 5, 2, minute(), (selected_field == MINUTE_FIELD));
    oled.draw_pattern(4 * FONT_2X_WIDTH + 6, 2, 2, 2, 0b00011000);
    print_digit(4 * FONT_2X_WIDTH + 2 * FONT_WIDTH, 2, second(), (selected_field == SECOND_FIELD));
    print_digit(0, 6, wake_HOUR, (selected_field == ALARM_HOUR_FIELD));
    oled.draw_pattern(2 * FONT_2X_WIDTH + 1, 6, 2, 2, 0b00011000);
    print_digit(2 * FONT_2X_WIDTH + 5, 6, wake_MINUTE, (selected_field == ALARM_MINUTE_FIELD));
    print_digit(6 * FONT_2X_WIDTH + 2 * FONT_WIDTH, 6, ALARM_TIME, (selected_field == ALARM_FIELD));
    print_digit(80, 6, ACTIVE_ALARM, (selected_field == SET_ALARM_FIELD));
  }
  else if (display_mode == debug_mode) { // debug_mode
    print_debug_value(2, 'I', get_wdt_interrupt_count());
    print_debug_value(3, 'M', get_wdt_microsecond_per_interrupt());
    print_debug_value(4, 'V', getVcc());
    print_debug_value(5, 'T', getRawTemp());
  }
}

void print_digit(uint8_t col, uint8_t page, int value, bool invert_color) {
  oled.set_pos(col, page);
  if (invert_color) oled.set_invert_color(true);
  if (value < 10) oled.write('0');
  oled.print(value);
  if (invert_color) oled.set_invert_color(false);
}

void print_debug_value(uint8_t page, char initial, uint32_t value) {
  oled.set_pos(0, page);
  oled.write(initial);
  oled.set_pos(14, page);
  oled.print(value);
}

// PIN CHANGE interrupt event function
ISR(PCINT0_vect) {
  set_display_timeout(); // extent display timeout while user input
}

void check_button() {
  int buttonValue = analogRead(BUTTONPIN);

  if (buttonValue < PRESSED_BUTTON_THRESHOLD) { // button down
    set_display_timeout(); // extent display timeout while user input

    if (run_status == sleeping) {
      // wake_up if button pressed while sleeping
      wake_up();
    } else { // not sleeping
      if (buttonValue > UP_DOWN_BUTTON_THRESHOLD) { // down button
        handle_adjust_button_pressed(-1);
      } else if (buttonValue > SET_UP_BUTTON_THRESHOLD) { // up button
        handle_adjust_button_pressed(1);
      } else { // set button
        handle_set_button_pressed();
      }
    } // not sleeping
  } // button down
}

void handle_set_button_pressed() {
  display_mode = time_mode; // always switch to time display mode while set button pressed

  selected_field++;
  if (selected_field > FIELD_COUNT) { // finish time adjustment
    selected_field = NO_FIELD;
    if (time_changed) {
      wdt_auto_tune();
      time_changed = false;
    } //time changed
  } // finish time adjustment
}

void handle_adjust_button_pressed(long value) {
  if (selected_field == NO_FIELD) {
    // toggle display_mode if no field selected
    display_mode = (display_mode == time_mode) ? debug_mode : time_mode;}
  else {
    long adjust_value;
    if (selected_field == YEAR_FIELD) {
      // TODO: handle leap year and reverse value
      adjust_value = value * SECS_PER_DAY * (leapYear(CalendarYrToTm(year())) ? 366 : 365);
    }
    else if (selected_field == MONTH_FIELD) {
      // TODO: handle leap year and reverse value
      adjust_value = value * SECS_PER_DAY * getMonthDays(CalendarYrToTm(year()), month());
    }
    else if (selected_field == DAY_FIELD) {
      // TODO: handle leap year and reverse value
      adjust_value = value * SECS_PER_DAY;
    }
    else if (selected_field == HOUR_FIELD) {
      adjust_value = value * SECS_PER_HOUR;
    }
    else if (selected_field == MINUTE_FIELD) {
      adjust_value = value * SECS_PER_MIN;
    }
    else if (selected_field == SECOND_FIELD) {
      adjust_value = value;
    }
    else if (selected_field == ALARM_HOUR_FIELD)
    {
      if (wake_HOUR >= 23)
      {
      wake_HOUR=0;
      }
      else if (analogRead(BUTTONPIN) > UP_DOWN_BUTTON_THRESHOLD)
      { // down button
       wake_HOUR--;
      }
      else if (analogRead(BUTTONPIN) > SET_UP_BUTTON_THRESHOLD)
      { // up button
       wake_HOUR++;
       }
        }
    else if (selected_field == ALARM_MINUTE_FIELD) {
      if (wake_MINUTE >= 59)
      {
      wake_MINUTE=0;
      }
      else if (analogRead(BUTTONPIN) > UP_DOWN_BUTTON_THRESHOLD)
      { // down button
       wake_MINUTE--;
      }
      else if (analogRead(BUTTONPIN) > SET_UP_BUTTON_THRESHOLD)
      { // up button
       wake_MINUTE++;
       }
        }
      else if (selected_field == ALARM_FIELD) {
      if (ALARM_TIME >= 59) //MAX 1h
      {
      ALARM_TIME=0;
      }
      else if (analogRead(BUTTONPIN) > UP_DOWN_BUTTON_THRESHOLD)
      { // down button
       ALARM_TIME--;
      }
      else if (analogRead(BUTTONPIN) > SET_UP_BUTTON_THRESHOLD)
      { // up button
       ALARM_TIME++;
       }
        }
      else if (selected_field == SET_ALARM_FIELD) {
      if (ACTIVE_ALARM >= 1)
      {
      ACTIVE_ALARM=0;
      }
      else if (analogRead(BUTTONPIN) > UP_DOWN_BUTTON_THRESHOLD)
      { // down button
       ACTIVE_ALARM--;
      }
      else if (analogRead(BUTTONPIN) > SET_UP_BUTTON_THRESHOLD)
      { // up button
       ACTIVE_ALARM++;
       }
        }

    adjustTime(adjust_value);
    time_changed = true;
  }
}

I would like to reset timer then when wake_hours&minutes and changeable alarm activation time interval = ALARM_TIME*60000 have passed.
      if (ACTIVE_ALARM==1)
  {
    if (wake_HOUR==hour()& wake_MINUTE==minute())
    {
    digitalWrite(ALARM, HIGH);
    new_millis = millis();
    }
    else if (currenTime -new_millis <= interval)
    {
    new_millis = millis();
    digitalWrite(ALARM, HIGH);
    }
    else if (currenTime -new_millis >= interval)
    {
    new_millis = 0;
    digitalWrite(ALARM, LOW);
    }}
  else if (ACTIVE_ALARM==0)
  {
    new_millis = 0;
    digitalWrite(ALARM, LOW);
  }

Any ideas what kind a timer/delay i could use to make my code work?

Did you try with && instead of &? The meanings are very very different.

You have an awful lot of code in there that has nothing to do with what you're asking...

Its all okey with wake_HOUR==hour()& wake_MINUTE==minute() part. Because in next line i declare that if the interval havent reached then output still is ON

Then i will change my question - Is there any proper way how to make timer that will work in my situation?

@IgnacioVazquez-Abrams, in the case of boolean predicates (like wake_HOUR==hour() and wake_MINUTE==minute() it's the same... :)  ... [both & and && have lower precedence than == which allows rookie mistake to turn out ok]

Trying to run a watch off the WDT oscillator is just silly. Even after calibration, it will be too inaccurate to be anything but a toy.

So i fixed my problem. I didnt use timer what i wanted in the beginning but as the code it self's running clock i used current clock as to activate output and then based on clock to turn off output.
Not always the hardest way is better.
Basically this is what i needed to change:
if (ACTIVE_ALARM==1)
{
if (start_wake_HOUR==hour()&& start_wake_MINUTE==minute())
{
digitalWrite(ALARM, HIGH);
}
if (end_wake_HOUR==hour()&& end_wake_MINUTE==minute())
{
digitalWrite(ALARM, LOW);
}
}
else if (ACTIVE_ALARM==0)
{
digitalWrite(ALARM, LOW);
}

As noted in the comment of IgnacioVazquez-Abrams, in the instances at hand you should be using the && (logical AND) relational operator, rather than the & (bitwise AND) arithmetic operator.
That aside, you should separate things out so that instead of an ungainly if - else series you have some independent cases.  For example:
if (wake_HOUR==hour() && wake_MINUTE==minute()) {
   digitalWrite(ALARM, HIGH);
   alarmMillis = millis();
}
if (millis()-alarmMillis > interval) {
   digitalWrite(ALARM, LOW);
}

This will do the job, as follows:
• During the match-minute, ALARM will be driven high over and over, and new_millis will update to the current millis() value over and over.  Which is OK.
• After the match-minute but before the end of the timed interval, ALARM will remain high and new_millis will remain fixed with the time of the end of the match-minute.  OK, that's as desired.
• After the end of the timed interval, ie, when millis()-new_millis > interval, ALARM will be driven low over and over.  Which is OK.
Note, I don't see a declaration of currenTime or anywhere it is updated.  Hence, it does not represent current time and should not be used as such.
Note, interval should be declared as something like a const unsigned long int, with a value that is a minute shorter than the total length of interval that you want.  (new_millis represents the end of the first minute of the interval.)
Note, new_millis should not be zeroed at the end of the interval.  If the original code were magically made to mostly work, because of  new_millis being zeroed it still would have a bug.  During the first few minutes after each millis() overflow, a false alarm would sound.  millis() overflows are about 49.71 days apart.


text:
The Arduino Sketch does not save in Arduino folder location
I have just installed Arduino on Mac OS. The Arduino folder is created under Documents. But whenever I save the sketch it gets stored in some ghost location and gives an error, the same name already exits. Upon finding the location of file. It gets stored under this directory(Hidden).
/private/var/folders/_v/nbrwcsh51wd2k07kfhy9vhjm0000gn/T/untitled1010592992.tmp/sketch_sep28a

How can I move this location to my documents folder. In Arduino preferences, I have also changed the location of sketch, still it does save in above location.

I appreciate this is a issue with the Arduino IDE, but you might get more help on a Mac forum.

Hi @CodeGorilla, I am afraid that goes a bit beyond the IDE - I am experiencing the same issue with arduino-cli

Download the latest IDE from Arduino.cc
Drag your Arduino application icon to the trash.
Open up terminal and type rm -r ~/Library/Arduino15
Delete the Arduino folder in your Documents folder for good measure
Drag the newly downloaded Arduino application to your application folder and see how it goes from a clean install.

Failing that PlatformIO IMO is a much better IDE for developing on these platforms : http://platformio.org/

isn't the "Arduino folder in your Documents folder" the place where OP might have saved his precious projects?

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
How to connect IR Transmitter and Receiver Module?
The IR Transmitter and Receiver module has both receiver and transmitter in same board. I tried Arduino IR Remote library example to decode Remote signal using below connection, but its not working.

IR MODULE:   ARDUINO
Ground   ->  Ground
5V       ->  5V
RXD      ->  PIN 11
TXD      ->  PIN 10

The board also has 3 pin connector (Gnd, 5v, S). How to connect pins to Arduino to receive/decode and send IR signals? (Can't able to find any tutorial for this type of board)

Example Code:
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
  delay(100);
}

That is not the sort of IR circuit one would normally use with an Arduino, rather it looks like it has some sort of on-board modulator or something.  Your question will not be answerable until you find full data on the module.  For ordinary arduino projects, you just want a loose receiver module and a loose IR LED, resistor and NPN transistor.

This particular question would be more easily answered if a link to the device was provided. I'm interested in the product, as it appears to answer a question I have not posted. This device appears to be suited for reflecting the IR signal from a distant surface, but it would be necessary to physically isolate the emitter diode and the receiver in order to prevent false signals. You say you are unable to make this item work with the code provided. Please clarify what portion does not work as expected and also what steps you have taken to narrow down the problem.

The given code doesn't seem to make any attempt to transmit or enable a transmitter on the module, which has both transmit and receive pins.  This seems unlikely to work.

@fred_dot_u I just connected this device to Ardunio and uploaded above sample code. Then given IR signal from my remote...But it now showing in serial monitor

Google the part number: YS-IRTM. I found a post on the Arduino Forum for example which describes using this device. There is also a YouTube Video.

The device in the question is commonly sold on aliexpress.com and the likes of ebay.com.  As you might guess there is little in the way of documentation.  Without documentation we can only speculate.  As such, I expect that the module handles all the modulation and demodulation.  It is likely all you need to do is use the Arduino serial library and connect the TX and RX to the Arduino's RX and TX pins.  However, if you would like to preserve the function of these pins for use with the Arduino Uno's USB port, you can use the Arduino software serial library which will "emulate" a serial port an an unused (alternate) set of pins.
(This is an example of a similar well documented device with access to the schematic and source code.  Armed with this type of knowledge you can turn this device into what ever you want.  In other words, you probably don't even need an Arduino.  You can just program this device and be done with your project.)

Connecting additional devices to the hardware UART RX and TX of a classic ATmega328p type arduino is possible but will interfere with the usual connection to the computer.  People usually use a software serial implementation or a chip with more hardware UARTs.

True.  Was just using an ARM based Arduino which, I'm hoping, doesn't have that problem.  I'll change the answer around to accommodate the difference.

I think you need to switch RX and TX in your code. Looking at the video that @nick-gammon reffered to. TX on audrion is RX on device.

Thanks. I have similar module and i just switched up rx/tx and all works fine

it use UART protocol so your code is wrong.
Here link with code

For that module you dont need library for easy example for sample for send HIGH and LOW status but. it doesnt work for control IR protocol. for that you need the basic conection Just (data-gnd-Positive)   in that example data is for pin = 11

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Made a Adafruit Flora unusable
I was playing around with an Adafruit Flora and a strip of NeoPixel LEDs.  After uploading the sketch to the Flora (via Arduino IDE), the LED strip lights for about 1 second and then dims to a dull orange color for all the lights.  When this orange color appears, it seems to indicate that the Flora has crashed.  If I unplug the Flora from power and plug it back in, the LEDs light again for about 1 second and then it crashes again.
The time between boot and crash is short enough that I can't upload a new sketch.
So how would I go about rescuing the Flora?
Is there a couple pins I can jumper to put it into bootloader mode?  Or some other way of resetting the Flora so as to remove the offending code?

Sounds like it might be a power problem, perhaps your LEDs are overloading your USB port (how many do you have?).  You might try disconnecting the LED strip to verify you can still program the flora.

@ChrisStratton: 42 pixels in the strand all set to bright white.  If I read the datasheet correctly each pixels draws a max of 0.2A - so that should be 8.4 amps!?  Sounds awfully high?

No, they should only take about 60mA each. But at 2.5A that's still too high for the on-board regulator.

And several times too much for a USB port, too.  Disconnect power to the pixels and you'll find your flora is probably fine.  But you'll need to rig up a suitable power supply if you want to turn more than a few of them on dimly.

42 pixels in the strand all set to bright white.

This exceeds the power supply capability of either a USB port or the Arduino's regulator.
Likely the circuit starts out working, then once the LEDs are all on drawing high power either a protective device such as a polyfuse / PTC fuse activates trips or the supply simply sags under load.  At this point the circuit either shuts down or starts misoperating, the ATmega may go into brownout protection mode, etc.
Disconnect power to your LEDs and you will probably find that the Flora is fine.
You will need to use a suitable higher current power supply if you want to light more than a few pixels of this type at any given time.


text:
Reading the DotStar datasheet - power requirements
I'm trying to figure out my power requirements for a strand of Adafruit DotStar LEDs - APA102 Cool White, not the RGB. I'm not sure how to interpret the datasheet.
In the middle of the product spec table on page 1, under Power Consumption, it says 0.2W (MAX: 1W).  Which would mean at 5V, MAX would be 0.2A, or 200mA.
Then on page 3 in the electrical characteristics table under the symbol/Parameter "LOL/Sink Current Voltage" it says typ. 24.5mA; max. 26.5mA.
I plan on having the strand on full brightness most of the time.
So which is it?  200mA? or 26.5mA?

I expect you will have to run an experiment and measure how much current each unit draws at full brightness.
The APA102C spec sheet seems to mix together data about the whole unit (controller chip plus three LEDs) and the controller chip itself.  The “LOL/Sink Current Voltage (RGB)” line that shows “min. 22.5, typ. 24.5, and max. 26.5 mA” appears to apply to the controller, and probably to single outputs on that controller, which anyway would give a 3X multiplier.  (The Cool White strips have three white LED chips per unit, instead of 1 each R, G, B.)
Note, the Adafruit DotStar LED Strip - APA102 Cool White webpage suggests using their 5V 4A power supply to drive “a half meter or meter” and their 5V 10A supply to drive  “a couple meters”, which at 30 units per meter works out at 2/3 to 5/6 W of power supply capacity per unit.

You have correctly worked out:
I(A) = P(W) / V(V)

I = 0.2 / 5
I = 0.04A

MAX:
I = 1 / 5
I = 0.2A

From that it seems it will use between 40 - 200mA depending on brightness.
Sink current refers to the current required to drive the led's digital input from your MCU's digital output.

More information on current sinking


text:
Using Arduino GSM with WiFi
I have a project that requires  data to be sent online from a moving bus. I am using ESP8266F modules to send the data.
I am wondering what Arduino modules to buy that will act as an access point with wifi and will connect to the internet through GSM.
In this configuration, the ESP8266 will connect to the access point and will upload the data online.
I want to connect a DF robot "SIM808 GPS/GPRS/GSM Shield For Arduino" to an Arduino Yun and use them as a wifi access point to connect to the internet through GSM connection.
The ESP8266 (5 of them) will connect to the Arduino Yun and will then send variables to the internet through the internet connection provided by the GSM.

Please explain better. How many nodes are sending data? You need a GSM module that can act as an access point as well?

Why not just use a cheap Android phone?

GSM modules tend to use large amounts of current when transmitting so you might find that the ESP modules reset.  Why by an Arduino, stick to an ESP8226 and use that as you access point.

All the ESP (5) are connected individually with their own power supply and they all record certain analog value to be sent to GOOGLE spreadsheet using pushingbox. And my instructor already rejected the idea of using a cheap Android phone.

ESP is a full stack WiFi module. If you are intended to collect some data from several ESPs you can configure one more as an access point and collect those data from other ESPs as stations. At access pint you can make a small web server as well. To send aggregated data through GSM then you can use a GSM module wire-connected to this ESP. To avoid RF interference while GSM sends data, you should use different power sources and shielded twisted pair for connection. It may happan, that you will need to place GSM module at some distance from ESP access point to avoid overload of the receiver. Even better to use external antennae outside the bus for GSM and shield it inside the bus to minimise the interference. I do not see how Arduino can help here.

Maxim, that a good idea but I have to upload the data (analog data) from the different ESPs to GOOGLE spreadsheet using pushingbox. Is it possible to send the data through the web server of the access point ESP connected to the GSM. And is it possible to connect ESP to GSM?


text:
VLcd pin to ground?
I just bought an ERC12864-655 LCD screen.
On the datasheet it says that I need to connect the vlcd pin to GND.
However in this (page 8) datasheet it says that vlcd is the main power supply. As far as I know ground is no power supply. That doesn't make sense to me.
So what should I do with this pin?

It appears that the LCD is powered/switched by the chip, not directly powered externally. The 10K to ground would be a pulldown to keep pin 20 from floating when the LCD is not being powered, and the .33 uF cap would be for power filtering.
The datasheet pointed to by your second link is a quality-control document; not quite what most of us call a datasheet, but Note B on page 1 suggests more documentation is available on the manufacturer's website. Their interfacing description and demo code should help.


text:
I'm new here. Where to look for documentation for my specific board
sorry if this isn't the done thing. I have a little red space invader shaped board that has an arduino chip on the back from a conference. There is an LCD display and I've just got it to function correctly (there was a power issue.
ATE1 E
0
ATE
1

The above is what the screen is displaying and I can't make heads or tails of it. Any ideas?
I've tagged this with arduino-micro because I think it may be that although I've had relative success using 'SparkFunProMicro' board in arduino IDE
EDIT: I've been able to get some more board info from arduino IDE. VID:1B4F, PID:9204, BN:unknown board, SN:Upload a sketch to get it.

Its unclear what you are asking, but I'm guessing Iding the boards is the first step.  Maybe a photo of the board would help.  Sparkfun boards are normally red and they use the Vendor ID of 1B4F.  They make a 5v Pro Micro with a Product ID of 9205 and a 3.3V version PID=9203.  They also make a Leonardo with a PID of 9206.  So you PID is in the right area, but god knows what it is.  Can you read the back of the ICs to see what they say?

Quote from Tech Note Wiki: All SparkFun ATmega32U4 boards share the same VID - 0x1B4F, and they all have unique PIDs. 5V Pro Micros lay claim to PIDs 0x9205 and 0x9206 (one for the bootloader, one for the sketch). 3.3V Pro Micros will show up as 0x9203 and 0x9204 for bootloader and sketch, respectively. And the Fio v3 has 0xF100 and 0xF101.

an arduino chip on the back - what chip? Part number?


text:
Time.h rollover after 49.7 days
I'm developing a arduino based system, which includes a alarm system.
Searching on the Internet, I found these lybraries "Time.h" and "TimeAlarms.h".
In the requirements, it says: "Time does not require any special hardware. Internally, Time depends upon Arduino's millis() function to keep track to elasped time."
Considering Arduino's millis() rollover after 49.7 days, how can I ensure these lybraries are handling the rollover well?
I don't think that waiting 49.7 days to test it is the better way.

See this answer to a related question. Specifically, the section titled How do I test my sketch against the millis rollover.

Have you considered using a RTC?

As this is a duplicate of the question and answer Edgar Bonet linked to I'm going to close this question.

As long as the date is before 2038, and your code calls one of the time functions at least once every 49 days, rollover won't affect you.
Internally the library uses Unix epoch time. Every time you call a function it checks to see if 1 or more seconds have past since the last time it was called and then updates the epoch time accordingly. Only for this check it uses millis(). And in only checks the difference between the last call's millis-value and the current millis-value, and rollover has no effect on time differences (as long as they are less that 49 days).

You should simply buy a real time clock such as the common DS3231. They work well and don't have any problems with resting or continuous data reading. It also dictates the date!
Hope I helped :)

I have a lengthy post about this.
To avoid going to the link if you don't want to, the simple answer is to subtract when calculating time intervals, eg.
unsigned long startTime = millis ();
unsigned long interval = 60000;

...

if (millis () - startTime >= interval)
  {
  // do something
  }

This always works! - even after 49.7 days - because of the way that unsigned arithmetic works.
The only time it would fail is if you needed to time an interval of over 49.7 days - in which case a real-time clock is an obvious answer.
Another example:
startedFeedingFish = millis ();

...

if (millis () - startedFeedingFish >= 20000)  // feed them for 20 seconds
  {
  // stop feeding the fish
  }


text:
Can't get ESP8266 working
I have received an ESP8266 (ESP-07) Wi-Fi module from DealExtreme (Link: http://bit.ly/2dFJdxE).
It is a 4-pin module with the following pins: RX, TX, VCC and GND.
The module has a switch so you can switch between the following modes: Program & UART. The module also has a RESET-button.
Here's a picture of my module:

I've connected the module to my Arduino Uno like this:
RX > RX,
TX > TX(TX>RX & RX > TX, like mentioned in manuals, results in no connection),
VCC > 3.3v (not using any level shifters because the module has on board level shifters),
GND > GND.
I found a lot of manuals to test the module, but apparantly I can't get my module working. I am using Windows with the Arduino IDE.
The boards mentioned on the manuals/tutorials also seem to differ from my module because most of the manuals are talking about a board that has 8-pins (with an extra GPO0, GPO2 CH_PD and RST pin).
I've tried to upload the BareMinimum sketch to the module, which only finishes uploading if I disconnect and reconnect the 3.3v input that's feeded to the ESP-board when the Arduino IDE says "Uploading...... " while the ESP-board is in Program-mode.
I have installed the ESP8266 library within the Arduino IDE and the Generic ESP8266 Module is selected.
Then when I open the serial monitor in the Arduino IDE, to test the AT commands (on different BAUD values), it does not respond (neither in Program-, nor in UART-mode).
Strange thing is when I keep the serial monitor on at 74880 BAUD (and UART-mode on the module) and I push the RESET button on the module, it gives the following message:
ets Jan  8 2013,rst cause:2, boot mode:(3,7)
ets_main.c

I've tried several things.  But none of them seem to work; like trying to flash new firmware (for example 'v0.9.5.2 AT Firmware.bin' and 'esp8266-2016-05-03-v1.8.bin') with esptool.py with the following command:
esptool.py -b 115200 -p COM3 write_flash 0 FIRMWARE.bin

It says that the writing is finished and no errors appear after running the esptool. This is what is printed + command that is used:
esptool.py -p com3 -b 115200 write_flash 0 firmware.bin
esptool.py v1.2-dev
Connecting...
Running Cesanta flasher stub...
Flash params set to 0x0000
Writing 520192 @ 0x0... 520192 (100 %)
Wrote 520192 bytes at 0x0 in 44.2 seconds (94.1 kbit/s)...
Leaving...
A strange thing is when I open the serial monitor in the Arduino IDE after that moment (without resetting the module/unplug from 3.3v or change to UART mode), it keeps printing the following at 115200 BAUD:
Fatal exception (28):
epc1=0x4000228b, epc2=0x00000000, epc3=0x00000000, excvaddr=0x000000b5, depc=0x00000000

I even tried it with the erase_flash before and 0x00000 instead of 0. Also tried to run the command with a variety of flash_sizes (with the command --flash_size=Xm).
Esptool looks like the only tool where I can flash new binaries successfully, tried some others that where on some manuals but without success.
When I run esptool.py -p flash_id
I get the following response:
Connecting...
Manufacturer: e0
Device: 4014
Who knows how to fix this problem so I can send AT commands to the module through the serial monitor in the Arduino IDE.
Thanks in regards (this is my first post so if some things are unclear, please let me know)
Edit: Note that I have to disconnect and reconnect the 3.3v to the module EVERY time to successfully run a command (like write_flash, flash_id et cetera). Also tried connecting it to 5v and using an external power supply next to the USB.

On DealExtreme  it says Working voltage: 4.5V - 5.5V. You are supposed to power it with 5V not 3.3V.

Sorry I didn't write it in my post, but already tried that + tried it using an extra power supply connected to the Arduino (besides USB). Makes no difference.

Seeing "ets Jan  8 2013,rst cause:2, boot mode:(3,7)": Good, your ESP is alive, and wired correctly for communication. "Fatal exception (28):" Good, you managed to set the ESP to non-program/normal mode. Only the software on it seems bad :) What you want to do is flash it with the Espressif AT firmware, and it should work as you expect it, responding to AT commands. DONT after that upload any sketches, cause it will replace the AT firmware. There's tutorials of uploading the AT firmware I think, I'm behind a firewall atm. so can't look for any for you :)

Thanks for your answer, tried different firmware packages from the Espressif website earlier but without any success.

Personally I think using an ESP as a interface for an Arduino is backwards and the Arduino ought to act as the interface to your devices for the much more powerful ESP.
I think you had a board that was configured to work as a interface between serial and Wifi, not as a normal board.  I'm pretty sure that you have now shagged it totally by trying to write programs to it.  However you might be able to recover it if you can find the original program and upload that to it.  You don't need the ability to program and ESP-8266 in the IDE to use this board, you can not upload sketches to it, you can't access the GPIOs.
I think you should just be able to slide the switch to "program" power the board up and type AT commands via a terminal emulator to set the board up and then power down, slide the switch back to UART and away it goes.  As to the Tx and Rx pins, that depends on weather its saying "this is the Rx pin" or "this is the Rx connection", you'll get it right second time :)
If you want a ESP8266 try AliExpress they cost between £1 and £2 and I've never had any problems, probably because they were made in China.

Have you had a look at this documentation I found another seller of your board offering this link.  I haven't downloaded it so virus scan it.
https://www.adrive.com/public/8SGB7d/FZ1727-Serial%20Wifi%20module.zip

Thanks for your answer. Think I should have been more careful before I blindly followed some online tutorials. New boards are on the way so I hope I have more luck with them, hehe. Giving up on this one now I guess, think it's firmware is screwed, tried any firmware package I found on the Internet.

@sschrijver - You could always unsolder the ESP board and put a new one on.

Or buy a more common/popular type of ESP8266 board. The "Sparkfun Thing" and "Adafruit Huzzah" are good if you want quality and customer support. They provider good tutorials as wel. Alternatively you could get a cheap, but common module like the NodeMCU or WeMos.

It may be that the type you have has extremely low memory, bad/unstable power circuitry, weird or specific upload mode or different bootloader. If you get one that is in the upload list, you'll have the right settings. And popular boards are proven to be working and if not, you'll find a lot of tutorials/support specific to your board/problem that may even be the same problem as yours (and how to fix it)


text:
EthernetClient: HTML table isn't being fully populated
I have the following code below for an EthernetClient named client. It is supposed to print a 2 row, 9 column table. The headers are ID and Name and are the first cell in each row. The other columns are the associated data. The problem I am having is that it is only printing the first ID and then the rest of the cells for that row are blank. The names all get printed in the row below it without a problem. Why won't it print the other IDs?
Here is the ID array: String ids[16] = {"00000", "00001", "00010", "00011", "00100", "00101", "00110", "00111", "01000", "01001", "01010", "01011", "01100", "01101", "01110", "01111"};
client.println("
");
client.println("
");
client.println("ID	");
for(int i = 0; i < 8; i++) {
  client.print("");
  client.print(ids[i]);
  client.println("	");
}
client.println("
");
client.println("
");
client.println("Name	");
for(int i = 0; i < 8; i++) {
   client.print("");
   client.print(name[i]);
   client.println("	");
}
client.println("
");
client.println("
");

Could you show the output your get? Preferably the raw "view-source" html output.

I tried your code, changing client to Serial and the output looked OK. It even rendered OK in my web browser.


text:
Having trouble using RTC if I set an ISR for a 1 second timer
I built a sketch using some timer ISR code to get a trigger every second.  (for the Atmega328 chip I use the following code I got form the internets.  It works)
It runs fine and I get a trigger/callback every second.
void setupAtmega328()
{
#ifdef __AVR_ATmega328P__

//      traceDebug("setupAtmega328() entry");
    cli();  // stop interrupts

//    traceDebug("setupAtmega328() 1");
            //set timer1 interrupt at 1Hz
    TCCR1A = 0;// set entire TCCR1A register to 0
    TCCR1B = 0;// same for TCCR1B
    TCNT1 = 0;//initialize counter value to 0
              // set compare match register for 1hz increments
    OCR1A = 15624;// = (16*10^6) / (1*1024) - 1 (must be <65536)
                  // turn on CTC mode
    TCCR1B |= (1 << WGM12);
    // Set CS12 and CS10 bits for 1024 prescaler
    TCCR1B |= (1 << CS12) | (1 << CS10);
    // enable timer compare interrupt
    TIMSK1 |= (1 << OCIE1A);
//  traceDebug("setupAtmega328() 2");
    sei();//allow interrupts
//  traceDebug("setupAtmega328() 3");

#endif
}

I also wanted to add the capability of a real time clock (RTC) so I got a DS3231.
I downloaded and ran the sample app from this RTCLib on github
The sample code works fine when running under the Arduino IDE
However, when I add the RTC code to my sketch I don't get the results I want/expect.
Specifically, the program seems to hang/halt at the call to:
cli();

I am new to the Arduino platform and not sure what I am missing.
What do I need to do to get the RTC to work in conjunction with an ISR?
I wired the RTC according to the directions from Adafruit's site
I have other arduino boards that use different ISRs, but I have not tried them yet with the rtc since the 328 seems to be the standard arduino boars that is used to do initial work/testing.
How can I use the 3231 RTC AND a 1 second ISR/callback?
EDIT:
I removed the trace/serial output - I had originally added those to track the code to see where I got but i think I exacerbated or added problems in doing that.
for those interested the code is at https://github.com/tjurik/Intervalometer

Provide your whole sketch.

Calling Serial.print after you call cli is ill advised. Serial requires interrupt to send the data (if I remember correctly). Try removing the serial.prints between cli and sei, or at least make the text shorter so the buffer doesn't fill up. PS you can setup the DS3231 to send a pulse every second to the SQW pin. You can connect this pin to one of the Arduino interrupt pins. That way you get a very accurate 1Hz interrupt call.

@gerben - using the rtc to send the 1hz interrupts would be far more desirable!  thanks.  i will try that.

In the Arduino you don't have control how are some essential parts implemented.
For example delay function requires interrupts to be enabled or it'll be deadlocked (for sure).
Serials are little bit better, it'll be working until send buffer gets full. For devices with small RAM it's 16B only! And your traceDebug is little bit longer.
In general ISR should be as short as possible and it's mainly used for setting some flag to be handled in main loop later.
volatile bool flag = false;

ISR(...) {
  flag = true;
}

int main() {
  init();

  while (1) {
    if (flag) {
      do_something();
      flag = false;
    }
  }
}

Yeah, that is how i wrote the code - and then when trying to debug the problem I added serial output which I think made more problems!


text:
DC Motor Pinning the Ada Fruit Moto Shield with the Mega2560 R3
I picked up an AdaFruit Motor Shield V2.3 .  The example on the site shows how to code the DC Motor connection
// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);

// Select which 'port' M1, M2, M3 or M4. In this case, M1
Adafruit_DCMotor *myMotor = AFMS.getMotor(1);
// You can also make another motor on port M2
//Adafruit_DCMotor *myOtherMotor = AFMS.getMotor(2)

What I'm unclear about is how to connect the shield to the mega board.  Which pin on the shield should connect to which pin on the board in order for Motor 1 to run at that speed?

Well because an Arduino Mega2560 is pretty much and UNO with a longer rear end, try seeing the UNO in the MEGA if that makes any sense. Then just put the shield in like a normal shield that you would put on a UNO. Most UNO shields are compatible with MEGAs. Then you just use your shield like if it was on an UNO.


text:
Arduino Uno R3 not working with Cytron shield GPS 53
My project is to find latitude and longitude of certain places. I am using an Arduino Uno R3 with a Cytron GPS 53 shield to get the position of places but, my device cannot run because COM4 already in use. How to fix this error?

Please read How do I ask a good question?. Please give a lot more details, like how you are connecting things. I don't see how COM4 in use is anything to do with a shield.

Your GPS board supports sending the data to the USB socket on the Arduino, sending it to pins 0 and 1, or sending it to a Software Serial port.  The first two options are going to confuse the output you are getting from the Arduino, so you should probably use the Software Serial option (read the manual on how to do that).
The data that you receive on the Arduino from the software serial port will need forwarding to the USB serial port that your PC is connected to, you will have to right a program to do this, but its not a difficult program and I'm sure there are examples out there.
If you want to make this mobile, you will need a battery to power the kit and an LCD display to show your results (get one with an I2C 'backpack' it will be easier to program).
Hopefully that should give you a start.


text:
Get pin input status without using the arduino library
I am not allowed to use the Arduino Library (or any Library) for this program. How would I check the input of a pin?
I found two different functions:
In Arduino.h:
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)

Following digitalRead back to pgmspace.h:
#define __LPM_enhanced__(addr)  \
(__extension__({                \
    uint16_t __addr16 = (uint16_t)(addr); \
    uint8_t __result;           \
    __asm__ __volatile__        \
    (                           \
        "lpm %0, Z" "\n\t"      \
        : "=r" (__result)       \
        : "z" (__addr16)        \
    );                          \
    __result;                   \
}))

For the first one, I don't know where bit and value come from and I just don't understand the second one at all.

This looks a very similar topic to your other recent question: How do I use masks to make it so pin 13 (PB7 and the LED) as output and then have pin 10 (PB4) as an input?. Please don't ask two very similar questions in the space of a couple of hours.

I asked this one first to see how to get an input. The other question was to see if use the same Data Port for both an input and an output.

But it's the same project, right? You are just looking at the same problem in slightly different ways.

No I'll more than likely use this for every project I do and the other one, it just depends on the project. Where this one is just get any pin. The other question is how to deal with getting an input from the B data registry and changing the state of the light as an output in the same data registry.

I changed the title of the other question to better describe that question.

For reading, e.g., PB2, you would test
PINB & _BV(PB2)

where PINB is the port input register and _BV(x) is a macro defined as
(1 << (x)).
C.f. the datasheet for the relevant port names.
See also the Arduino tutorial on
port manipulation.

Can you explain what (1<< (x)) does please?

@kingcobra1986: https://www.arduino.cc/en/Reference/Bitshift

I'm sorry, I didn't mean what is a bit shift. I know it is a bit shift to the left by x. What does it do though? Is it for getting the correct pin from the register? Or does it do something else?

It does exactly what you know it does: it shifts 1 by x places to the left. No more, no less. C.f. http://playground.arduino.cc/Code/BitMath

@kingcobra1986 The PB2 is defined as bit position not a bit mask (which is needed for bit manipulation).


text:
Can I use the same Data Registry for both input and output pins?
This is for a class in which we are not allowed to use the Arduino Library (Not my choice or preference). I know to use DDRB for the B pins. This is the code that I have so far:
//Global pointers
unsigned char *portDDRB = (unsigned char *) 0x24;
unsigned char *portDataB = (unsigned char *) 0x25;
unsigned char *portPinB = (unsigned char *) 0x23;

void setup () {
  //For the led output I know that I would do this
  *portDDRB |= 0x80;
}

void loop () {
   //And here the code would be like this to light up the light:
   if (condition to turn on light) {
     *portDataB |= 0x80;
   }
   // To Turn off the LED:
   if (condition to turn off the light) {
     *portDataB &= 0x7F
   }
}

I would like for the light to turn on when the input of PB4 is HIGH (from a button press). I just am not sure on what to put in the condition statements or the setup functions.
When I set the DDRB to 0x80, is that just making the PB7 an output and the rest as input?
I am using the Arduino Mega ATmega2560 btw.
From the comments I have this:
//Global pointers
unsigned char *portDDRB = (unsigned char *) 0x24;
unsigned char *portDataB = (unsigned char *) 0x25;
unsigned char *portPinB = (unsigned char *) 0x23;

void setup () {
  //For the led output I know that I would do this
  *portDDRB |= 0x80;
}

void loop () {
   //And here the code would be like this to light up the light:
   if (portPinB & 0x10) {
     *portDataB |= 0x80;
   }
   // To Turn off the LED:
   else {
     *portDataB &= 0x7F
   }
}

You check if the PB4 bit is set in the PINB register, by bitwise and-ing it with all zeros except for the bit you are interrested in. So if( PINB & _BV(PINB4) ) or if( PINB & (1<<PINB4) ). PS by using setup and loop you are still using the Arduino library. PS2 you need to change DATAB to turn the led on, not DDRB

I guess those are the only two we get to use. What do I initialize PINB and PINB4 to? As for the DataB, thats what I have, just tired.

PINB is (kind of) an output register. You can only read from it. It reports the HIGH and LOW voltages on the B-register's pins.

I added to my Question does that look right? Is PINB included in the Arduino Library? If you make it an answer, you'll get the upvote btw.

yes, except you need to change the |= to =, or the bit will only be set, and never cleared.

PINB etc. are defined in <avr/io.h> which isn't part of the Arduino library.

Is the assignment to write unreadable and unportable code?

Actually the assignment is to write a function that debounces input. I don't know why the professor doesn't want us to use the Library becasue it is an embedded systems course. I think he wants us to know more about the system as opposed to the library. Personally, I would rather just want to know how to use the code.

I specifically meant the |= in *portDataB |= 0x7F. Since portDataB was 0x80; when you or it with 0x7F you get 0xFF, not 0x00.

Assuming the button is connected between GND and pin 10, without any pull-ups or pull-downs.
void setup () {
    //For the led output I know that I would do this
    DDRB = 0;             // set all pins on port B to INPUT
    DDRB |= _BV(DDB7);   // set PB7 to OUTPUT
    PORTB = 0;            // set all pins on port B to LOW
    PORTB |= _BV(PORTB4); // enable the pull-up resistor on PB4
}

void loop () {
    if( PINB & _BV(PINB4) )
    {
        // if bit PINB4 is set, the button is not pressed
        PORTB &= ~_BV(PORTB7); // turn off led
    }
    else
    {
        PORTB |= _BV(PORTB7); // turn off led
    }
}

Wait which |= were you telling me to change to =. Also I am good to use my portPinB in place of your PINB right?

You can use portPinB, but why would you?

The professor's "Blinky" example used it. So I figured that I would need to use it too. I'd rather be safe. He stated that if we use anything from the arduino library we would get a 0 for the entire assignment. I would rather be safe then sorry and declare/initialize everything myself.

It's part of libc. You could just ask him. He'd be more of an asshole if he didn't allow this. I find it quite odd of him to force you to use the Arduino IDE, but not use any other part of Arduino; well; except for the loop and setup; oh; and the initialization that Arduino does.

@kingcobra1986 PORTB etc come with the compiler, and are nothing to do with the Arduino API. If your "professor" thinks they are anything to do with Arduino then he is a fool.

When I set the DDRB to 0x80, is that just making the PB7 an output and the rest as input?

Clarification
I take that question to mean "When I assign the value to 0x80 to DDRB". For example:
DDRB = 0x80;

In the code above that question, you were not assigning, you were "or"ing the value.

Yes. Typically you would "or" in the value if you want to affect only one pin, eg.
DDRB |= 0x80;

The conventional way to make it an input again would be:
DDRB &= ~0x80;

That is, "and" in the negated bit pattern for that pin.
Remember, you have 3 registers (per port) where "x" is "A", "B", "C" etc.:

DDRx - data direction - a 1-bit is output, a 0-bit is input
PORTx - output value - a 1-bit is HIGH, a 0-bit is LOW
However, if the data direction is input, then a 1-bit is input-pullup, and a 0-bit is not input-pullup.
PINx - read the input from the port - a 1-bit is HIGH, a 0-bit is LOW
Note that writing a 1-bit to PINx toggles the output value of that port.

These remarks apply to the AVR chips, not the SAM ones.

I was responding to the sentence, not the code. If you set DDRB to 0x80 then it has that effect. I think the words "set a variable" are generally understood to mean "assign a value to a variable". That is, replace the old contents with the new ones.

I clarified my answer to show exactly what I was responding to.


text:
Supply 5V to Arduino
I am building a quadrocopter with an Arduino Uno as control unit. I know I can supply 5 volts to the 5V pin, but my ESCs produce 5.5 volts, which I measured with my multimeter. Will this voltage drop to 5 volts when I connect the Arduino and if not are 5.5 volts to the 5V pin a problem?
Edit:
My Arduino was running well for a couple of days on this setup with 5.5 volts to the 5V pin but died yesterday. By dying I mean the ATmega doesn't execute any code anymore, the L LED doesn't blink, and even a loopback test fails, which is a sign of a defective USB connector. But I am faced with the same challenge. Should I run my Arduino on 14.4 Volts from my 3S LIPO to Vin or supply 5.5 volts to the Vin pin?
Actually I just realised when I measure the voltage from the ESCs they deliver 9 point something volts for half a second when connecting the multimeter, I guess this voltage spike killed the Arduino.

Do you mean 5V to VIN pin?

I'm going to assume you are using the UNO model - or any other board based around the Atmega328p.
According to the datasheet the voltage limits are 1.8v to 5.5, with an absolute maximum of 6v.
You should be fine - but if you are able to get the voltage down closer to 5 volts, I would recommend doing that instead.

Most Arduinos won't mind 5.5v if your are sure that is the max. The ATmega328 is design to be used from 2.7V to 5.5V so that is the very max. No, the voltage will not drop down to 5V when you connect it to the Arduino but I believe you are quite safe with 5.5V. Just don't make a short because you'll be pushing your ATmega328 to it's designed max. You might wanna look at the datasheet for it. All it specs are in there.

You're better off applying that 5.5V to the Vin pin. You may end up with slightly less than 5V at the Arduino, but it'll tolerate that much better than going above 5.5V on the 5V rail.

It's going to yield ~4.4V on output pins and the 5V pin. This never caused me any problems with transistors etc. OP should just use that value for any calculations.

Actually I just realised when i measure the voltage from the escs they deliver 9 point something volts for half a secound when connecting the multimeter ...

Yes, that won't be good for it. I suggest a LDO (low dropout) 5V voltage regulator. Something with a 0.5V dropout will get rid of that extra 0.5V and also handle the initial spike.

Okay - it looks like that voltage spike might be the cause of death for your board.
As an answer to your question though - I would recommend applying the 14.4 volts to vin, as 5.5 volts is not enough (the regulator needs 6 volts as a minimum, and the absolute maximum is 20 volts).
Just make sure you apply the 14.4 volts to the vin pin and NOT the 5v pin, as that would kill the board.
Please tell us how it worked out - good luck!


text:
How to set up one second interrupt/ISR for ds3231 RTC
I am able to set up one hz interrupts using millis and other timers, but would like to do it instead using the RTC I have attached (DS3231)
I am not sure how I can do that.  Can someone point me to a reference for this?
EDIT/UPDATE
I tried to use the square wave to trigger a call back/interrupt, but it's not working for me.  I followed what I thought was the wiring diagram here and
here and here
I also added a led in the circuit to see if I could figure out something that way, but no dice.
Here is some simple code for a sketch that I think should trigger a 1 second interrupt and call my function:
#include <DS3232RTC.h>    //http://github.com/JChristensen/DS3232RTC
#include <Time.h>         //http://www.arduino.cc/playground/Code/Time
#include <Wire.h>         //http://arduino.cc/en/Reference/Wire (included with Arduino IDE)

const int rtcTimerIntPin = 2;
bool flag = false;

void setup(void)
{
    Serial.begin(9600);
    setSyncProvider(gRTC.get);   // the function to get the time from the RTC
    if (timeStatus() != timeSet)
        Serial.println("Unable to sync with the RTC");
    else
        Serial.println("RTC has set the system time");

    bool stopped = gRTC.oscStopped();
    if (stopped)
    {
        Serial.println("Detected clock power loss - resetting RTC date");
        time_t newTime = cvt_date(__DATE__, __TIME__);
        adjustTime(newTime);
        setTime(newTime);
    }
    else {
        Serial.println("Clock did not lose power");
    }

    pinMode(13, OUTPUT);    // onboard LED
    pinMode(rtcTimerIntPin, INPUT);
    attachInterrupt(rtcTimerIntPin, rtc_interrupt, RISING);
    gRTC.squareWave(SQWAVE_1_HZ);

    digitalClockDisplay();
}

void rtc_interrupt(void)
{
    flag = true;
}

void loop(void)
{
    //digitalClockDisplay();

    if (flag) {
        digitalWrite(LED_BUILTIN, HIGH);    // flash the led
        digitalClockDisplay();              // this just prints time to serial port
        delay(500);                         // wait a little bit
        digitalWrite(LED_BUILTIN, LOW);     // turn off led
        flag =  false;                      // clear the flag until timer sets it again
    }
}

void digitalClockDisplay()
{
// do something
}

What sort of precision are you looking for? The interrupt (once you get that working) should fire within a few microseconds of when the clock actually generates the signal. Are you looking for microseconds, or milliseconds? What is the purpose of this? If you are just flashing an LED very high precision is probably not required.

And if you just want to flash an LED every second, connect it to the clock output directly! (via a resistor). :P

I want to have a signal so that I do some check/processing every second.  For this project tens of milliseconds is fine.  It is for a timer to do time lapse photography.

This answer addresses the original question of why the interrupts didn't work. I happened to have a DS3231 lying around so I made up a test.

Interrupt vs pin number
First, this is wrong in your code:

attachInterrupt(rtcTimerIntPin, rtc_interrupt, RISING);

You need an interrupt number, not a pin number. This is correct:
  attachInterrupt (digitalPinToInterrupt (rtcTimerIntPin), rtc_interrupt, CHANGE);

I also made it a CHANGE interrupt so you get both the rising and falling pulse.

Pull-up resistor
Next, the 1 Hz output needs a pull-up resistor, so you should add that or make it INPUT_PULLUP like this:
  pinMode (rtcTimerIntPin, INPUT_PULLUP);

Testing
I used this library from Adafruit.
Adapting one of their examples, and putting in your interrupt code (with my modifications), it worked!
#include <Wire.h>
#include "RTClib.h"

RTC_DS3231 rtc;

const byte rtcTimerIntPin = 2;

volatile byte flag = false;

void rtc_interrupt ()
{
  flag = true;
}  // end of rtc_interrupt

void setup () {

  Serial.begin(115200);

  while (!Serial); // for Leonardo/Micro/Zero

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

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

  // enable the 1 Hz output
  rtc.writeSqwPinMode (DS3231_SquareWave1Hz);

  // set up to handle interrupt from 1 Hz pin
  pinMode (LED_BUILTIN, OUTPUT);
  pinMode (rtcTimerIntPin, INPUT_PULLUP);
  attachInterrupt (digitalPinToInterrupt (rtcTimerIntPin), rtc_interrupt, CHANGE);
}

void loop () {
  if (flag) {
    digitalWrite(LED_BUILTIN, HIGH);    // flash the led
    delay(100);                         // wait a little bit
    digitalWrite(LED_BUILTIN, LOW);     // turn off led
    flag =  false;                      // clear the flag until timer sets it again
  }
}

I was missing two things:
I used INPUT rather than INPUT_PULLUP and I did not have the digitalPinToInterrupt() in the first param for attachInterrupt()
thanks!

Try the following code. It pretty much detects a change in time and when a change has been detected, it will do something. In this case, it will print "do something".
#include <DS3231.h>
DS3231 rtc(SDA, SCL);
String t; //time as a string
String s;    //second
String Ps;   //previous second

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

void loop() {
  t = rtc.getTimeStr();             //finding time
  s = t.substring(6, 8);            //finding seconds

  if(s != Ps)                       //if the time has changed
  {
    Serial.println("do something"); //put whatever you want here
    Ps = t.substring(6, 8);         //redeclaring the previous second because it has advanced
  }
}

I advise against using the String class for something done every time around loop. String uses dynamic memory allocation, and if you aren't careful you will get heap fragmentation. To calculate seconds just use the "modulus" operator (ie. time mod 60).

I don't think it is possible because the DS3231 libray that I have only returns strings.

Can you give a link to the library please? You should be able to get something other than Strings.

http://www.RinkyDinkElectronics.com/  Your the pro so see if you can find anything. Even I would like for it to be able to return ints

Well for one thing the prototype is char *getTimeStr(uint8_t format=FORMAT_LONG); which means you get back a char * not a String. You can use char * without needing dynamic memory allocation. Also there is a function long getUnixTime(Time t); which gives you a long. AFAIK Unix Time is in seconds, so just call that and take modulus 60 of the result.

Where did I get 60 from? Assuming Unix time changes every second, then you just need to compare if the time changes.

Use this DS3231 library. It has a method to set the squarewave RTC.squareWave(SQWAVE_1_HZ)

Thanks Gerben - I will try to set up the squarewave to an input/interrupt.  No success yet.

You could temporarily add an led, to see if you are getting any signal.

Yep, I tried that - and no luck there.  In fact, I used two different 3231 'boards' to see if it was my wiring/soldering.  It may very well be that I wrecked two boards, but it seems more likely I am doing something else wrong.  I will try to post a stripped down version of what i am doing.

You should add a little more detail.

I tried to use the square wave to trigger a call back/interrupt, but it's not working for me.

 bool flag = false;
 ...
 void rtc_interrupt(void)
 {
     flag = true;
 }

Flags set in interrupts should be declared volatile otherwise the compiler may optimize away the comparison to the flag. That is:
volatile bool flag = false;

If you are using the Adafruit library (from the page you linked to) then it should have a couple of functions that can be used to detect when the second has changed, for example:
DateTime now = rtc.now();
int second = now.second();
unsigned long unixtime = now.unixtime();

In either case you just have to check if either one has changed in loop. For example:
void loop(void)
{
  static unsigned long previousTime = 0;
  DateTime now = rtc.now();
  unsigned long timeNow = now.unixtime();

  if (timeNow != previousTime) {
      digitalWrite(LED_BUILTIN, HIGH);    // flash the led
      digitalClockDisplay();              // this just prints time to serial port
      delay(500);                         // wait a little bit
      digitalWrite(LED_BUILTIN, LOW);     // turn off led
      previousTime = timeNow;             // remember previous time
    }
}

thanks @nick  - I fixed the volatile bit.  Note that I want a callback/trigger/squarewave - not to delay()/check the time each iteration of the loop.

Does it work once you added volatile? The delay was from your own code. The delay is not part of working out if the second is up. I don't see a huge difference between checking the time from the clock, as you go around loop and checking a flag, each time you go around loop. Reading the time from the clock might take slightly longer, I suppose.

Volatile didn't fix the desired method of having an ISR triggered by a square wave, but I changed the loop() code to look like what you suggested.  That works.  Thanks for the help.  It's going to bother me about the interrupt though...


text:
Servo.attach method causing strange issue
I am using the L298N motor driver for a robotics project to control 4 motors. 2 motors in each input and output terminal. I have this connected to an Arduino Uno which is powered by about 7-8v from NiMH batteries. This battery source also powers a servo with a 470uF capacitor and the L298N board.
I have a strange problem when I use the servo attach method for my servo, only outputs 1 and 2 on the L298N start working meaning the wheels on the left of the robot start moving only. When I have the servo connected and imported the library but don't use the attach method, the L298N outputs to all DC motors meaning it works. Even when I use the servo attach method on a pin where nothing is connected to it, the motors on out 4 and 3 on the L298N don't move. For some reason this attach method is causing issues. Can anyone explain why?
Note:  I applied a larger power supply, from my 7V to about 12V but the problem still persists. I don't think power is the issue since the problem even happens when the attach method is called on a pin that has no servo connected to it.

Are you using PWM outputs for driving L298? If there is any of PWM outputs on the same Counter/Timer as Servo, it won't work, as Servo needs different settings for that timer.

what do you mean counter/timer

In the microcontroller used in the Arduino Uno, there are three Timer/Counter modules. Each of them has two hardware PWM channels. If you mix up one PWM output and one Servo output, it'll change settings for PWM and it might stop working (thats a problem mainly for Timer1). Pins 3 and 11 are on Timer2, 9 and 10 on Timer1 and pins 5 and 6 are on Timer0 (this one is used for millis() too)

I agree with @KIIV . It seems a problem with Servo library and PWM outputs (specially with pins 9 and 10).

If possible, could you please include your code and your schematic?

The L298N boards can either control stepper motors or general DC motors. You have mentioned that you are using the servo library which is for servo motors which generally only rotate 180 degrees. Can you please clarify what motors you are using?

We need to see your code and schematic.


text:
Problem building a smart shopping cart
I'm building a smart shopping cart with Arduino for my final year project.
The cart is supposed to be able to follow its user while shopping. I don't know of many feasible indoor positioning systems to use.
Proposed solution 1
I have recently seen some RF/ultrasonic positioning systems that make use of:

one ultrasound transmitter and one RF receiver, carried by the person,
and two ultrasound receivers and one RF transmitter carried by the robot.

The robots RF transmitter sends out a signal, which when received by the person's RF receiver, triggers the person's ultrasound transmitter to transmit a signal. This signal is received by the robot's two ultrasound receivers (with a distance, d between them), and the distance and angle to the target person can be calculated.
That sounds very feasible, but my question is, if the robot is in a crowded place, where the other people are also carrying ultrasound transmitters and RF receivers:

Will the RF signal meant for the owner of the robot be accidentally received by the RF receiver on another person, or is there some kind of unique ID shared between RF receiver/transmitter pairs that could prevent this problem, or maybe some kind of frequency hopping system, so there would be no mistaken identity.
How will the ultrasound receivers on the robot be sure that the received signal is from its matching ultrasound transmitter. Again, is there some kind of special ID systems employed by some ultrasonic transmitter/receivers.

Proposed solution 2
I have also read about this new device called Trackr, it makes use of bluetooth low energy to track objects based on their proximity to bluetooth enabled devices like smart phones.
Considering a scenario where various bluetooth devices (beacons) are placed at specific points in a room, and the target to be tracked is equipped with a bluetooth emitter/bluetooth chip/dongle.
When the target passes each of those beacons, the signal strength intensity is received and distance from the target is calculated.
I understand this concept, but have some questions:

When distance is calculated between beacon and target, what about the angle, how would the robot follow the target based on distance alone?
If this method is not accurate enough to be used in a crowded space, what other method can be used, I have checked out some indoor GPS devices and they are way to expensive (above $200).

Would a camera-based tracking system be better and how easy would it be for a non expert like me to implement.

Also see some of the linked questions (in right sidebar, some of which are woefully short on facts, and some of which may be useful.

Is the user (shopper) allowed to wear things? For example, an IR transmitter? How big is the proposed area (shop)? Are there multiple aisles? For the demo are you basically getting the cart to follow someone around a room, or does it have to navigate aisles (or worse still, display cases or other shoppers)?

Also, can you install things in the "shop"? I presume the cart itself can have technology all over it.

yes, any of the above scenarios would be fine, i am not ruling out anything

I have a couple of ideas for you but know these are only suggestions. No hate please.
Have you tought of IR following?
IR is a almost unique signal that only you have. You can either use multiple IR sensors to determine where the emitter is or you can use the servo motor to do it as a radar. Note that you have to isolate each sensor so it knows where you are and it doesn't captures the wave from a different angle by accident.
Extra safety?
You can also incorporate an untrasonic distance sensor so that the cart doesn't bump into you or any one. Like you can say, if the distance is smaller then 12 inchs / 30 cm, stop the cart. It is practically an extra safety feature.

well, if the IR is the only signal that can send unique codes, what then do telecommucication companies use to transfer data

I just think that something like RF is a little too strong. You would want the beam to be concentrated into a small area with an isolated sensor that can detect at what angle of the cart you are. RF is too strong to do that and it is quite more expensive.

Try keeping it simple. I'd have the person wear and infrared transmitter. Then on the cart have an array of IR-receivers pointing in all directions. That way the cart knows which direction to go.
Next you need to get the distance to the target using e.g. an ultrasonic distance sensor.
Lastly you need to add some bumper sensor, so the cart known when it's running into an obstacle.
Your camera solution might also work, combined with OpenCV. But you can't run that on a measly Arduino.

thanks. but with the infrared transmitter, wouldnt the cart follow pretty much anyone who wears a similar infrared transmitter?

my major issue is how to match one person to one cart in a fairly crowed environment

You can have them send unique codes, similar to a remote control.

wow, really. Thanks thanks. So if i surround the cart with infrared receivers, wouldn't there be interference with each other, does it work with line of site. If so, does it mean i would need to cover the entire perimeter of the cart with receivers? Also is it only infrared transmitter/receivers that are capable of sending unique codes?

Another solution, along the lines of your camera option, would be to seed the store with Kinect (or Kinect-like) camera systems.  These systems are already designed to track multiple people at once.
Using this method you don't need to equip the shopper with any device, which lowers logistics (how do I get that device back when the shopper exits the building) and tech support costs.
You might need to equip the carts with some kind of marker - I don't believe the Kinect systems are designed to track inanimate objects, but I could be wrong.
So challenges to overcome with this system would be:

How to track the carts?
Kinect doesn't have a very large focal distance so you will need some kind of system to hand shoppers off to the next Kinect when they pass out of range of the one currently tracking them.

I'm going to get a bit ambitious here and suggest something along the lines of what the Vive virtual reality system uses. You can see from some of the photos on that site that the headset has lots of sensors on it. Judging by this article they detect signals from two base stations. I presume the base stations send IR beams (because radio would not be directional enough). The sensors on the headset are recessed a bit, which would shield them from anything but a line-of-sight beam from a base station.
The store
Now you don't need anything quite that sophisticated, but something like this might work. First, you have some IR transmitters located around the store, pointing in a criss-cross pattern, like this:

The green box is the cart and the bigger boxes the shelving. Now with sensors on the corners of the trolley, pointing in different directions, and with each transmitter sending a differently-coded IR beam, the trolley should be able to work out its position fairly accurately.
The trolley
By a process of exclusion (if you don't see a particular base station then you are not near it) and inclusion (if you do see a base station from a certain sensor then you can deduce a possible area you are in) you should be able to work out your position.
In this case we might expect that the bottom-left-diagonal sensor would be picking up signals from station 1003, and the bottom-right-diagonal sensor would be picking up signals from station 1004. Plus the forward sensor may be getting signals from station 1000 (depending on the range) and the rear sensor from station 1005.
The shopper
Now we also need to know where the shopper is. If you gave the shopper a vest or belt with sensors on it in a similar way (eg. front, back, diagonal) then similar calculations can work out where the shopper is. Let's assume that each shopper and each trolley are given a unique ID pair (that is, a trolley is associated with a vest). Effectively, each shopper would transmit, every second or so "shopper 5677 is at position x=543, y=666 in the store".
Now we can use radio transmission (from the shopper) to its paired trolley, to tell the trolley where its "owner" is. And assuming the trolley knows where it is, then it can work out if movement is required, and if so, in what direction.
Collision detection
In addition to the above, you would need some proximity sensors on the trolley (eg. ultrasonic) to stop the trolley from driving into other shoppers, display cases, its owner, etc.
Maze solving
The trolley could have software on it to solve the problem of reaching the shopper. For example, if its way is blocked for too long on the shortest path, it might take an alternative which would be to go to the end of the aisle, go down a different aisle, and then back to where its owner is.
Extra credit

You could make a button on the trolley you push when you are finished. The trolley could then "lead" you to the checkout with the shortest queue at it (or an empty checkout).
You could have some buttons on the trolley with major grocery types on it (eg. dairy food, bread, frozen foods). When pressed the trolley could lead you to the appropriate aisle.


text:
Soldering Arduino Pro Mini's disaligned pins
I have a couples of Arduino Pro Minis (original from sparkfun) that have those 4 disaligned pin. Unfortunetely, I need to use 2 of them, A4 and A5, because they are the I2C pins and I want to solder them onto a perf board.
Now, I really want to use headers and I do not want to solder any wire directly to it. I also do not want to add headers facing up on the board because I am trying to minimize space. Last, I am not willing to change Arduinos so please do not suggest me to use an Arduino Nano or Pro Micro.

So I would like to know if there is a way to connect those 2 pin to the perf board via headers or is there any alternative pins that I can use to connect and use the I2C interface.

That's indeed quite an problem.
If you don't mind losing 2 analog pin, you could solder some jumper-wires between A4 and A2; and between A5 and A3. Then you could connect your I2C lines to pins A2 and A3.
But you have to be careful to never set pins A2 and A3 to OUTPUT in your software. If you want to be super-duper safe, you could cut the trace from the header pins going to the TQFP-chip. See the image below.

Also for power saving, should I remove the leds?

@canadiancyborg definitely. At least the power-indication led. The pin 13 lid might be useful to keep.

No need to remove the LED. Just unsolder the little bridge next to the GND that is close to pin 2 and it will disable both the regulator and LED

Easy! I like these ProMinis and use them in lots of projects. Simply exchange one of the 12 way header pin strips for a 14 way one (cheap to buy long lengths of these strips from eBay) add small neatly soldered wires to extend A4 and A5 to the extra pins you’ve added and job done.

As you are soldering to perf board, perhaps you don't have a printed circuit board specific to your project. If you did, you could modify it, or could make a little intermediate PCB to accept connections from A4 A5 and shift them onto the grid.
If you have some 90°-angle headers, try removing a couple of pins from the plastic former, and 0.05" or 0.15" out from the line of the short side of the L, bend the long leg 90°.  Point the jog along the X or Y axis to align the pin with your perf board grid.


text:
Serial.read() is getting a whole string rather than just a character?
From the arduino documentation, the Serial.read() function is supposed to return a single character at a time from incoming serial messages. So if I program the arduino with the following:
#include "SPI.h"

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

void loop() {
  if (Serial.available() > 0) {
    char data1 = Serial.read();
    Serial.print(data1);
  }
}

And I open the serial monitor and send "Hello, World!" I would expect the received message to be the individual characters printed one at time but instead I get back the whole message. So what gives? What am I not understanding?

... That you're printing characters until no more are available.

But shouldn't they be printed one at a time?

They are being printed one at a time. But how fast can you read?

Oh I see. I stuck a delay() in there and It makes more sense now. I am not that smart, apparently.

You only think it is a string, it actually returns character by character. You can know by adding something like a delay after you Serial.print(). What the program actually does is that it receives one character each time you type one and it prints it, then the void loop repeats.


text:
Is analogWrite() inferior to writing directly into registers?
I'm trying to control a DC motor's speed with my Arduino Mega analogWrite(), but it doesn't seem to function properly. The motor never completely slows down, just slows down a bit (which is still pretty fast) and then stops spinning completely.
I'm trying to create a robot with different speeds, and it just has to have a slow speed. I know it isn't the code, since the relay and motor works just fine when I use the digitalWrite().
Is it better to write directly into the timer registers to implement the PWM, OR what else could be causing the problem?

To answer that we would have to see the code and how you wired things up. At the end of the day analogWrite writes to the registers, so there is no direct reason not to use it. A possible issue is the amount of power available for the motor. A schematic would help sort things out.

Could it be that the power is in excess or in shortage, because i used a 12V relay to interface the motor to the arduino

A relay will have a physical time it can take to operate. You need a motor driver board (or MOSFET wired suitably). Unless you are referring to a solid-state relay and not a mechanical one.

Motors will stall if there isn't enough current.  Motors have a minimal required speed, before they stall. It also depends on the load on the motor. Not that a 50% duty cycle doesn't mean the motor will run at half the speed. There is no one-to-one correlation.

analogWrite() is already PWM, Arduino doesn't produce a true analog signal
Motors tend to draw a lot of current so you might want to control the motor with a MOSFET then connect your power supply directly to the motor. PWM will still work in that case, you just need to connect the output pin to the gate pin of the MOSFET
If you want more of an assurance when working with motors, try buying a motor shield. You current problem, speed problem and many will be resolved. It also makes it easy to control multiple motors.


text:
Using Arduino as ISP to burn sketch directly to ATmega328 without first installing a bootloader on the ATmega328
Is it possible to take a bare ATmega328 chip, and with an Arduino as ISP, burn a sketch directly to the chip (e.g. not needing a bootloader), or is the bootloader required to run Arduino sketches? I want to embed the ATmega328 into a different device, and do not want the overhead of the entire Arduino board.
I have looked at https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard and https://www.arduino.cc/en/Tutorial/ArduinoISP, and want to do the "minimal circuit" approach (as my application does not require 16MHz).
The tutorial described has steps to first burn a bootloader, then remove the chip from the Arduino, and then install the sketch. Ideally, I would like to skip the bootloader and removing the chip from my Arduino. Ideally, I would like to do it all from Arduino Studio (not AVRDUDE CLI).
I don't mind "dedicating" my Arduino to this (as I assume it's just burning the ArduinoISP sketch whenever I want to burn to a new ATMega328).
Thanks

It is possible to skip the Burn Bootloader step. When you do Upload Using Programmer the bootloader is overwritten and thus serves no purpose. However, there is another reason for the Burn Bootloader step, to set the correct fuses for your board selection. The fuse settings configure things on the ATmega328 such as clock speed and clock source. If the ATmega328 you are using doesn't happen to have the correct fuse settings for the board selection you're using in the IDE then things may not work or may not work correctly. For this reason it's best to always do the Burn Bootloader step the first time you use the ATmega328 and any time you change the board selection or other settings related to that board selection(such as custom Tools menu settings). Since you're not using an external clock source for your ATmega328 make sure that you don't select a board that is configured for an external clock as this will cause the chip to no longer work until you have connected an external clock.

Thanks for the detailed response. I assume if I get the clock speed wrong, I can't even burn the bootloader / anything to it? The chip I currently have has been programmed for a 14.3mhz (give or take?) external crystal, which I was not planning on using in the circuit. Will that be an issue?

@AndrewP: The clock rate only affects the delay and timing routines; ISP doesn't care about the exact speed provided certain minimums (detailed in the datasheet) are met.

The bootloader only enables serial programming of the device; it is perfectly possible to run Arduino programs without it provided that the code is compiled with the same hardware options (MCU model, clock speed, etc.) that the standalone device/board uses.


text:
neopixel not blinking
I have some neopixels, and I have one hooked up to my teensy.
I want to have the color change, when the push button is pressed vs not pressed. The LED will change colour when I upload the code, if I have the button pressed, green, if the button is not pressed, red.
The serial monitor reports changing button press statuses, so I'm not sure why the neopixel isn't changing.
The adafruit website is confusing to me, they have wonderful and involved project examples, but they never have just a basic IO example.
I would appreciate it, if someone could point out where Im going wrong with this code:
#include <Adafruit_NeoPixel.h>

#define PIN            0

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      1

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
const int buttonPin = 2;
int buttonState = 0;

void setup() {
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
  pinMode(0,OUTPUT);
  Serial.begin(9600);
  pixels.begin(); // This initializes the NeoPixel library.

}

void loop() {

buttonState = digitalRead(buttonPin);
Serial.println(buttonState);

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
      if (buttonState == LOW) {
          pixels.setPixelColor(PIN, pixels.Color(0,33,0)); // green
          pixels.show();

      }else{
          pixels.setPixelColor(PIN, pixels.Color(66,0,0)); // red
          pixels.show();
        }
        delay(500);
  }

this code compiles, without errors, and uploads just fine, but pressing the button won't change the LED color.

I'm not a Teensy Pro but the neopixel library requires a PWM pin. Pin 0 doesnt seem to be PWM on the Teensy. Try another pin.

NeoPixels most certainly don't require a PWM pin. Although they use PWM for signaling, they don't need a persistent PWM signal.

NeoPixels use assembly instructions to carefully time the signals. It's a weird kind of PWM, that can't be done with hardware PWM, since the width times for a 1 or 0 are different. It's like using PWM but setting the frequency for every bit, but this 1000's time per sec.

@IgnacioVazquez-Abrams . On Arduino, if you do not use a PWM pin with the Adafruit neopixel library, it doesn't work.

@canadiancyborg: Nothing in Adafruit_NeoPixel.cpp requires use of a PWM pin, at least not on AVR. It's all done with loops in assembly.

@IgnacioVazquez-Abrams . well thats just my personnal experience with it. Thanks tought for informing me that I do not to use PWM.

I had a wiring Problem, the device wasn't properly grounded, but still illuminating.
Its working now on pin0, but the idea to use PWM pins is valid. Duly noted.

It could be that if I were to string another neopixel in, it might not still work. I guess Ill have to test that.

No, the idea isn't valid. I've used them on non-PWM pins plenty of times.