# Question
Title: Is there a way of turning a computer into a Arduino type board?
The Arduino's processing power is not sufficient for some of the tasks I would like it to perform...

I'm thinking of making a Home Automation System and would like some serious processing power at the center of it all.

So I'm wondering if I can just use standard PC parts to essentially put together my own board?!?

Is this possible???

# Answer
> 2 votes
A regular Arduino uses an AVR, more "pimped" Arduino might go to ARM. Some special versions of Arduinos uses other chips, such as the ever iconic ESP8266.

For home automation, an ESP8266 is WAY enough. Using an ARM is quite and overkill for home automation. But I've never seen anybody using a full PC for it. Why? Because it is around 10-20 times more expensive. They require much more components and many other things.

Something close to a full PC that you can get is a Raspberry Pi (any version would do). They act like a small PC, some even use it as a laptop. See PiTop. The Raspberry Pi is stronger, more powerful, and much faster then any Arduinos. The Pi also has ethernet, a graphic interface, and an audio interface built in. That means that you can pretty much connect it to a monitor and it will work as a normal PC running either Windows or Linux. You can then watch a video, with graphics and sound, from the inthernet without external modules like you would need on an Arduino. Their only weakness is that it is harder to program them to read may sensors. That is why the Arduino is popular for covering that.

At the end of the day, it is your choice. I would personnally suggest an ESP8266. This module has many GPIOs, depending on the breakout that you have, and has WiFi built in. This is a great feature for home automation. Most home automation builders use this module.

If you have any questions about the informations I just gave you, comment it, I'll reply.

# Answer
> 2 votes
You could simply opt for a different platform? A Raspberry Pi or Beagle Bone? Either would probably have enough processing power and ram. The Onion Omega2 is a SoC with a 400Mhz CPU, 64MB of DDR2 RAM, 16MB of on-board flash storage, 802.11b/g/ WiFi at 150 Mbps, 18 digital GPIOs, I2C, SPI, and USB2.0, a full Linux Operating System, and it costs $5. The Onion Omega

# Answer
> 1 votes
Adding to Candice the Cyborg's answer I would go for esp8266-12 (for a specific breakout board) if you choose to go down that route-where Candice the Cyborg writes " "pimped" Arduino" this does not refer to the esp8266. But if you're using a PC to begin with you might as well get a PC based hardware to do the home automation. Arduino can't compete with PC for power and features-but it was never designed to.

You could try linking multiple Arduino's together communicating through the serial port pins-essentialy it would work something like a parallel processor. If it's just run of the mill home automation things then this can be broken down into a parallel problem. If you update your question with more info I can give you a more specific answer. I mean if your tasks only require a little extra processing power then it may be possible to do using an addition Arduino for example.

The cheapest way to set up a PC for home automation is probably add in a parallel port card-there are project around the internet that show how to use a PC for home automation with parallel port-if you don't have a parallel port then you can get a parallel port card for less than $5-so its cheap way to get IO pins-this was the way things could be done before the days when Arduino existed.

Using an Arduino UNO or the like is not a good idea for interfacing to USB devices -like cameras -if you has that in mind- that's because the ATMEGA chip does not natively support USB host and it's non-trivial to implement USB interface host yourself on Arduino-it would take deep knowledge of USB protocol as a minimum.

Sorry to say it on an Arduino site- but it may turn out cheaper to use a full PC (if your project can be run on an old PC you can get cheap or free) with no Arduino- a PC after all has much more hardware already built into it -lots more ports, video output and so on. Adding the cost of shields to do something similar on Arduino could cost a lot-it depends on the specifics of your question -which you don't give.

# Answer
> 1 votes
One thing a PC lacks, which is kind of critical for working with sensors and things, is easy access to IO.

A PC has a number of buses, but no GPIO pins. To get any form of GPIO you will have to add extra hardware in the form of PCI cards, etc. Those kind of things, since they are not widely used, are rare and hence expensive.

People have "hacked" their PC hardware before now to add I2C devices to the I2C bus that is present on all DDRx DIMM slots (used for module identification) and using that you could add I2C IO expanders to get some GPIO pins - however that is not easy to do, and then you have the problem of programming it on top of that.

The most flexible solution is to use USB. Using the PC as the "core" processor for heavy data processing, image capture, network communication, etc is simple enough and commonly done. Then using USB you interface to the devices you want to work with - cameras, etc. You can get USB-based IO boards which provide different forms of IO communication, such as TTL UART (FT232 boards, etc), parallel GPIO, I2C buses, SPI, etc. Of course, programming those things becomes somewhat tricky, and you may end up with a massive number of dongles on your computer to interface with the large number of things you want to connect to.

So a more flexible and sensible approach is to create your own USB interface to your sensors and other items. And one of the best and easiest systems to do that is, of course, the Arduino and Arduino-like boards.

An Arduino, or multiple Arduinos, become a sensor interconnect board which you program to communicate with whatever you need to communicate. That can then pass data back to the PC through USB which then performs the heavy number-crunching and what have you. Data can then be passed back through the USB to the Arduino for controlling other things (fans, lights, heaters, whatever).

So yes, you *can* use a PC as a powerful processor system in a larger plan, but the PC itself cannot replace an Arduino.

Of course, all this is assuming you have a PC to waste on the project, or you have the requirements of massive amounts of processing power that you can't get from any decent micro-controller or SoC.

One thing to remember: there are micro-controllers available cheaply today with considerably more power than the first pentium PCs - I regularly work with 200MHz MIPS based MCUs with embedded FPU - that's 3.33 times more powerful than the first pentiums (and without the floating point bug ;) )

The current Raspberry Pi embedded Linux computers provide all the GPIO and interfacing you should need at a tiny fraction of the price of a PC. They are (as of version 3) a quad-core 1.2GHz 64-bit SoC. The same quad-core 1.2GHz core that is used in many smart phones. That's more powerful than my laptop.

# Answer
> 0 votes
One approach that I am using in a project right now is to use *both* an Arduino Mega 2560 (for interfacing the hardware, as it has many 5 V GPIO pins, analog inputs and very predictable timings) and a Raspberry Pi (for running a Node.js-based Web server). They communicate through a level-shifted serial link, using a protocol roughly shaped on this command line interpreter.

This way I have both the ease of interfacing hardware provided by the Arduino and the power of a real computer.

Not saying it is the right solution for you, but as you did no provide details on your project's requirements, we can only make suggestions.

---
Tags: software
---


# Question
Title: The use of 4.7kOhm resistor with DS18B20 temperature sensor
I was using a temperature sensor DS18B20 with Arduino.

I've read that you should connect the digital input line and the 5V line with a 4.7kOhm resistor - like in the picture.

Can someone explain why do we need to do this? And why this resistance? What happens if we don't put a resistor at all or use a different resistance?

# Answer
The product page FAQ \[https://www.maximintegrated.com/en/support/faqs/ds18b20-faq.html\] has an entry:

```
Q: Is the 4.7kΩ resistor needed for 5V and 3.3V operation?
A: Yes, the 4.7kΩ pullup resistor is required for both 5V and 3.3V applications.

```

The 1-wire bus requires that the control signal be pulled high so the master device can pull it low to ask for data, and the slave device can pull it low to give the data. This allows you to have multiple 1-wire devices on the same "one wire".

The data sheet notes another purpose:

```
Another feature of the DS18B20 is the ability to operate
without an external power supply. Power is instead
supplied through the 1-Wire pullup resistor through the
DQ pin when the bus is high. The high bus signal also
charges an internal capacitor (CPP), which then supplies
power to the device when the bus is low. This method of
deriving power from the 1-Wire bus is referred to as “parasite
power.” As an alternative, the DS18B20 may also be
powered by an external supply on VDD.

```
> 14 votes

# Answer
Adding to jose's answer above to answer your other two questions

And why this resistance? When the device doesnt have its own power supply it uses the power going through the pull up resistor-thus with this resistance it is powered properly. Also the other reason- as Jose wrote is because it the value which differentiates high or low bits.

What happens if we don't put a resistor at all or use a different resistance? If you are going to you an out of spec value-dont expect the device to work properly because its using the wrong resistance-e.g. it may not work because if the resistance is too high-then according to ohms law it may not receive enough parasitic power. Though it should be able to tolerate the error tolerance of the resistor-so changing it by a few ohms either way from 4700 ohms will not make a difference. You may damage the device without a resistor.
> 6 votes

---
Tags: sensors, temperature-sensor
---


# Question
Title: Use digital pins as analog - Arduino Micro
I have an Arduino Micro and I want to use pin 6 and 8 as an analog pin, according to the manual this is possible:

> The Micro has a total of 12 analog inputs, pins from A0 to A5 are labelled directly on the pins and the other ones that you can access in code using the **constants** from A6 trough A11 are shared respectively on digital pins 4, 6, 8, 9, 10, and 12.

What exactly do they mean by constants? I am aware what a constant is in the scope of programming, however I'm not sure what I should use to assign pins 6 and 8 as an analog pin? I assume I cannot just do an `analogRead(6)`?

# Answer
> 2 votes
Constants are variables that cannot change. They are constant.

In this case they are variables that have been set up in the board definition files (in pins\_arduino.h in case you're interested) and are named just as they have said - `A6` through `A11`. This complements the existing `A0` through `A5` that are normally there anyway.

So you just use those names and it chooses the right pin for you:

```
int val = analogRead(A8);

```

The definitions of the pins are:

```
static const uint8_t A0 = 18;
static const uint8_t A1 = 19;
static const uint8_t A2 = 20;
static const uint8_t A3 = 21;
static const uint8_t A4 = 22;
static const uint8_t A5 = 23;
static const uint8_t A6 = 24;   // D4
static const uint8_t A7 = 25;   // D6
static const uint8_t A8 = 26;   // D8
static const uint8_t A9 = 27;   // D9
static const uint8_t A10 = 28;  // D10
static const uint8_t A11 = 29;  // D12

```

So no you cannot just use the number `8`, you have to use `A8` which points to pin number `26`. The Arduino core then interprets that number as an analog pin (as opposed to the digital pin, which is 8) and performs an analog read on it.

---
Tags: analogread, arduino-micro
---


# Question
Title: Why does exit status 1 stray '\302' in program pop up around Serial.println ( "-> Second Service load");?
```
/*
 Controlling a servo position using a potentiometer (variable resistor)
 by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>

 modified on 8 Nov 2013
 by Scott Fitzgerald
 http://www.arduino.cc/en/Tutorial/Knob
*/

#include <Wire.h>
#include "ds3231.h"
#include <Servo.h>
int potpin = 0; // Analog pin is used to connect the potentiometer
int val; // Variable to read the value from the analog pin
int pause = 800; // Delay in open feeders (feed amount)

Servo myservo;  // create servo object to control a servo

#define BUFF_MAX 256

// First Service
uint8_t wake_HOUR1 = 12;
uint8_t wake_MINUTE1 = 56;
uint8_t wake_SECOND1 = 0;

// Second Service
uint8_t wake_HOUR2 = 18;
uint8_t wake_MINUTE2 = 30;

// How often to update the information to the standard output (ms)
unsigned long prev = 5000, interval = 5000;

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  myservo.write (0); // Set the position to 0

  Serial.begin (9600);
  Wire.begin ();
  DS3231_init (DS3231_INTCN);
  DS3231_clear_a1f ();
  DS3231_clear_a2f ();
  set_alarm ();
}

void loop()
{
   char buff [BUFF_MAX];
  unsigned long now = millis ();
  struct ts t;

  // Output through time (5000ms) The time and alarm clocks ustanovlennnye
  if ((now - prev> interval) && (Serial.available () <= 0)) {
    DS3231_get (& t);

    // Display current time
    snprintf (buff, BUFF_MAX, ".% d% 02d% 02d% 02d:.% 02d:% 02d", t.year,
             t.mon, t.mday, t.hour, t.min, t.sec);
    Serial.println (buff);

    // Display a1 debug info
    DS3231_get_a1 (& buff [0], 59);
    Serial.println (buff);
    DS3231_get_a2 (& buff [0], 59);
    Serial.println (buff);

    if (DS3231_triggered_a1 ()) {
      // INT has been pulled low
      Serial.println ( "-> First Service load");

  myservo.write(10);                  // sets the servo position according to the scaled value
  delay(1000);                           // waits for the servo to get there
  myservo.write(170);                  // sets the servo position according to the scaled value
  delay(1000);                           // waits for the servo to get there

      // Clear a1 alarm flag and let INT go into hi-z
      DS3231_clear_a1f ();
    }
    if (DS3231_triggered_a2 ()) {
      // INT has been pulled low
      Serial.println ( "-> Second Service load");

  myservo.write(10);                  // sets the servo position according to the scaled value
  delay(1000);                           // waits for the servo to get there
  myservo.write(170);                  // sets the servo position according to the scaled value
  delay(1000);
}

```

# Answer
> 0 votes
As Gerben notes, the stackoverflow question *error: stray '\302' in program* is about this issue. Basically, your file contains one or more characters not valid in the current character set. The character is either non-printing or a multi-byte unicode character.

How did the character get there? Some of the ways mentioned in the stackoverflow question are pressing ctrl-space or shift-space.

How to find the character and get rid of it? You can look at output from hex-dumping the file, which will identify all characters definitively. Or by trial and error you can delete and retype spaces in the region of the error.

---
Tags: serial, servo, rtc
---


title: Arduino Uno + aRest + ESP8266

text:
# Question
Title: Arduino Uno + aRest + ESP8266
So, I can use the aRest library to program to the ESP8266 standalone, but if I have the ESP8266 connected to the Arduino Uno, can I still use the aRest library? Or will this no longer work? I am trying to send a request to the Arduino unit that will toggle a pin to turn on/off via the aRest library. Thanks!

aRest can be found here: https://github.com/marcoschwartz/aREST

# Answer
> 1 votes
Why don't you just try it? :)

In overview of GitHub repo, first sentence, it says: "A simple library that implements a REST API for **Arduino** & the ESP8266 WiFi chip." Next paragraph confirms it.

---
Tags: arduino-uno, esp8266
---


title: Setup arduino uno with ESP8266 ESP-1

text:
# Question
Title: Setup arduino uno with ESP8266 ESP-1
Iam trying to set up the `arduino uno` with the wifi module `ESP8266`. I use this schematic setup:

I have followed this tutorial: Tutorial ESP8266

Thereby I removed the `Mega328P Chip` like it says above, I can communicate trough my terminal in the `arduino IDE` with the `ESP-module` but when I want to upload an simple test file like this:

```
#include <SoftwareSerial.h>

SoftwareSerial ESP8266(0, 1); // RX = 8 en TX = 9

boolean FAIL_8266 = false;

void setup() {
  // put your setup code here, to run once:
   do {
    ESP8266.begin(115200); // start communicatie met esp8266

    //Wait Serial Monitor to start
    while (!Serial);

    ESP8266.print("AT\r\n");

    delay(500);

    if (ESP8266.find("OK")){
        ESP8266.print("ready");
    }

   } while (FAIL_8266);
}

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

}

```

Than it keeps throwing me this error: `avrdude: stk500_getsync() attempt x of x: not in sync: resp=0x20` is it because I removed the `Mega328P Chip`?

Thereby I've tried the test code from the tutorial here is an link to the code: LINK.

There it keeps saying that `Serial2 was not declared in scope`

I'll hope someone can help me out on this one and run an simple test script to communicate with the `ESP8266 WIFI Module`

# Answer
You must have your microcontroller in place if you are uploading code to it.

You can talk to ESP8266 via serial monitor because you are connected directly to the pins of your USB-UART bridge.

Place your uC back, change this line of code:

SoftwareSerial ESP8266(0, 1);

to this one:

SoftwareSerial ESP8266(8, 9);

and change your wires accordingly(what was on pin 0, now connect to pin 8, pin 1 to pin 9). Now your Atmega can talk to ESP8266 after you upload the code.

btw. "Serial2" is Serial port for more advance Arduino boards, it won't work on Atmega328 based board.
> 2 votes

# Answer
The first, most obvious issue (besides needing the MCU on the Arduino board!) is that you need to cross-connect the RX and TX lines between the two boards. You have both RXes connected together, and both TXes connected together. The ESP's RX has to listen to the Arduino's TX, and vice-versa.

An easy way to remember which ESP pins are RX and TX is that the pin nearest the free ends of the antenna is the RX pin; the TX pin is diagonally opposite it.

A second, potential problem, is that the ESP board may draw more power than the Arduino's 3.3v regulator can provide. If it is making brief and not too frequent transmissions, you may get away with it, but the ESP can easily out-draw the regulator and it's 3.3v supply will sag.
> 1 votes

---
Tags: arduino-uno, esp8266, wifi, softwareserial
---


title: Speed up the Arduino

text:
# Question
Title: Speed up the Arduino
I wrote a code that controls a stepper motor using the AccelStepper library. When it receives a serial signal from Visual Basic that contains a coordinate value, the Arduino will control the stepper motor by this value. The code works very well but it runs 1 second after receiving the value over the serial port. I want the code to run faster. Here is the code:

```
#include <AccelStepper.h>
#include <MultiStepper.h>
#include <AccelStepper.h>
#include <MultiStepper.h>
#include <AccelStepper.h>

// Define a stepper and the pins it will use
AccelStepper stepper(1, 9, 8);

int pos = 0;

void setup()
{
  Serial.begin(115200);
  stepper.setMaxSpeed(90);
  stepper.setAcceleration(90);
}

void loop()
{
  if (Serial.available()) {
    int steps = Serial.parseInt();
    stepper.moveTo(steps);

    if (stepper.distanceToGo() == 0) {
      stepper.moveTo(stepper.currentPosition());
      stepper.setSpeed(100);
    }
  }
  stepper.run();
}

```

# Answer
As others have said, this issue is created because the parseInt function reads in characters until it receives a non numeric character or until it reaches the timeout value, which is set at 1000 ms (1 second). There are a couple of ways to fix this, order most difficult to least:

1. Instead of just sending a number, send a number and then a letter at the end. So instead of sending "123", you would send "123x". `parseInt()` will immediately return when it hits the x. However, you'll still have the x in the stream so you'll need to manually read it and discard it.
2. Make the value that is sent a set number of digits - say 4 for example. Since you know it will be four digits, use a for loop to read in four characters and build it into a number by multiplying. If you read in digit1, digit2, digit3, digit4 then the number is `1000 * digit1 + 100 * digit2 + 10 * digit3 + digit4`.
3. Make the timeout value for `parseInt()` smaller. `parseInt()` inherits from the Stream class so you would use `Serial.setTimeout(50)` in the setup function to change it to a 50 ms timeout.
> 3 votes

# Answer
Do not use parseInt(): it will wait for one second to make sure there are no digits pending.

-Edgar Bonet
> 0 votes

---
Tags: arduino-uno
---


# Question
Title: Alter baud rate after being certain events
I'm using my HC-05 (Master) to receive strings from a sensor (Slave). Each string is supposed to have 7 items divided by ',' like so:

> a,b,c,d,e,f,g

But it isn't always received in such a manner. Sometimes it's 1.5 of a string or 2 strings in 1. I have tested the sensor with its native software and others, so the sensor shouldn't be the problem. So I believe it may be a baud rate issue. I tried to increase the HC-05's baud rate to 115200, but wasn't able to test anything because I need to use AT commands at the beginning of the program and for that the baud rate has to be 38400.

Is there any way to change the baud rate for Serial after the fact?

PS: I'm using a Mega 2560 and the sensor has a sample rate of 8Hz.

```
#include <SoftwareSerial.h>
#include <SD.h>

String test="";
char aux;
File myFile;

void setup() {
  pinMode(22, OUTPUT);
  digitalWrite(22,HIGH);
  Serial1.begin(38400);
  Serial.begin(38400);
  Serial.println("To begin capture press any key and enter");
  while(!Serial.available());
  Serial1.println("AT+INIT");
  while(!Serial1.available());
  Capture();
}

void Capture() {
  while(!Serial1.available());
  for(int i=0;i<2;i++) {
    delay(125);
    while(Serial1.available()) {
      aux=Serial1.read();
      Serial.print(aux);
    }
  }
  Serial.println("END");
}

void loop() {
}

```

# Answer
To answer your specific question, yes you can alter the baud rate after an event. Just use a `Serial.end()` then a `Serial.begin()` with the new baud rate.
> 1 votes

---
Tags: arduino-mega, hc-05, baud-rate
---


# Question
Title: How to connect a varying output voltage to the Arduino?
I have a smart meter and I want to connect my output pulse meter to the Arduino in order to count the pulses, but the problem is my output pulse voltage is varying (between 1V to 17V approximately) and the Arduino accepts only a stable voltage (5V).

Therefore, how can I make my output pulse voltage stable to connect it to the Arduino?

# Answer
> 1 votes
If “what I want is counting the pulses of my meter” means that you want to count the number of pulses the meter produces, you can use a circuit like the following to clip the voltage into the 0-to-5V range (as acceptable for inputs on Uno digital pins).

simulate this circuit – Schematic created using CircuitLab

Then, to count pulses, write a sketch that repeatedly reads the selected input pin. Each time it changes from low to high, add one to your count of pulses.

If you don't have 5.1V zener diode like the 1N4733A, you could instead attach the anode of an ordinary diode to the junction of R1,R2 and its cathode (the cross-bar end) to 3.3V on the Uno. This will clamp the voltage on the input pin to at most about 4V. (Note, with such a diode clamp, there would be high-current problems if you subsequently changed the pin to a high output. You could of course put a 100Ω resistor in series with the clamp diode if you are concerned about that.)

---
Tags: arduino-uno
---


title: Switch case problem in Arduino code

text:
# Question
Title: Switch case problem in Arduino code
I am trying to develop an IR remote for appliances. I have written Arduino code for this purpose. I have used switch case to determine an action from the corresponding IR decode result (HEX), but I am not getting the output.

My code is:

```
#include <IRremote.h>

int RECV_PIN = 6;
int led = 13;//1FE50AF
int led1 = 12;//1FED827

boolean previousState=LOW;
boolean previousState1=LOW;
boolean state;
boolean state1;
IRrecv irrecv(RECV_PIN);

decode_results results;

void setup() {
  Serial.begin(9600);
  pinMode(13,OUTPUT);
  pinMode(12,OUTPUT);
  irrecv.enableIRIn();// Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    switch(results.value) {
       case '0x1FE50AF':
       if (previousState == LOW) {
         state=HIGH;
         digitalWrite(led,state);
         Serial.println("LED ON");
         previousState=state;
       } else {
         state=LOW;
         digitalWrite(led,state);
         Serial.println("LED Off");
         previousState=state;
       }
       break;

       case '0x1FED827':
       if (previousState1 == LOW) {
         state=HIGH;
         digitalWrite(led1,state1);
         Serial.println("LED ON");
         previousState1=state1;
       } else {
         state1=LOW;
         digitalWrite(led1,state1);
         Serial.println("LED off");
         previousState1=state1;
       }
       break;
    }
    irrecv.resume(); // Receive the next value
  }
}

```

# Answer
Replace all:

```
case '0xZZZZZZZZ':

```

with:

```
case 0xZZZZZZZZ:

```

That's because `value` in `decode_results` structure is declared as `unsigned long`, `0xZZZZZZZZ` is an `unsigned long`, but `'0xZZZZZZZZ'` is not (actually, it should not even compile).
> 1 votes

---
Tags: ir, switch
---


# Question
Title: Problem with executing a function in the middle of a 'nested for loop'
New to Arduino here. I was wondering if there was anything wrong about my utilization of the nested 'for loop'. What i wanted is the execution of the 'looper4' and 'looper6' function if any of my Togglestates condition are met during the looping process. My Togglestates reads the state of my Togglepins which are linked to my toggle switches. Funny enough, the program executes the 'looper6' function immediately when i flip the switch. However, does not execute the 'looper4' function until the whole nested 'for loops' are finished even when the switch is flipped. All my outputs are to LEDs.

```
int ledPins[] = { 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 26, 28};
int pinCount = 12;
int patternCount = 24;
int ledLevel = 0;
int Togglepin = 7;
int Togglestate = 0;
int Togglepin2 = 2;
int Togglestate2 = 0;
int Togglepin3 = 4;
int Togglestate3 = 0;

void setup()
 {

  for(int thisPin = 0; thisPin < pinCount; thisPin++)
    {
      pinMode(ledPins[thisPin], OUTPUT);
    }
  for(int thisPin = 0; thisPin < pinCount; thisPin++)
    {
      pinMode(ledPins[thisPin], OUTPUT);
    }
      pinMode(Togglepin, INPUT);
      pinMode(Togglepin2, INPUT);
      pinMode(Togglepin3, INPUT);
  }

 void loop()
 {
 looper3();
 }

 void looper() //All my loopers(1,2,6,7) execute a similar coding with
                 difference in arrays and toggling conditions(found below)
 {

  byte AOM0[]={0,0,0,0,0,0,0,0,0,0,0,0};
  byte AOM1[]={1,1,1,1,1,1,1,1,1,1,1,1};
  byte AOM2[]={1,1,1,1,1,1,1,1,1,1,1,1};
  byte AOM3[]={1,1,1,1,1,1,1,1,1,1,1,1};
  byte AOM4[]={1,1,1,1,1,1,1,1,1,1,1,1};
  byte AOM5[]={1,1,1,1,1,1,1,1,1,1,1,1};
  byte AOM6[]={1,1,1,1,1,1,1,1,1,1,1,1};
  byte AOM7[]={1,1,1,1,1,1,1,1,1,1,1,1};
  byte AOM8[]={1,1,1,1,1,1,1,1,1,1,1,1};
  byte AOM9[]={1,1,1,1,1,1,1,1,1,1,1,1};
  byte BOM0[]={1,1,1,1,1,1,1,1,1,1,1,1};
  byte BOM1[]={1,1,1,1,1,1,1,1,1,1,1,1};
  byte BOM2[]={1,1,1,1,1,1,1,1,1,1,1,1};
  byte BOM3[]={1,1,1,1,1,1,1,1,1,1,1,1};
  byte BOM4[]={1,1,1,1,1,1,1,1,1,1,1,1};
  byte BOM5[]={1,1,1,1,1,1,0,0,0,0,0,0};
  byte BOM6[]={1,1,1,1,1,1,1,1,1,1,1,1};
  byte BOM7[]={1,1,1,1,1,1,0,0,0,0,0,0};
  byte BOM8[]={1,1,1,1,1,1,1,1,1,1,1,1};
  byte BOM9[]={1,1,1,1,1,1,0,0,0,0,0,0};
  byte COM0[]={1,1,1,1,1,1,1,1,1,1,1,1};
  byte COM1[]={1,1,1,1,1,1,0,0,0,0,0,0};
  byte COM2[]={1,0,1,0,1,0,1,0,1,0,1,0};
  byte COM3[]={1,1,1,1,1,1,1,1,1,1,1,1};

  byte* All[24] = { AOM0, AOM1, AOM2, AOM3, AOM4, AOM5, AOM6, AOM7,
                    AOM8, AOM9, BOM0, BOM1, BOM2, BOM3, BOM4, BOM5,
                    BOM6, BOM7, BOM8, BOM9, COM0, COM1, COM2, COM3 };

    for (int Pattern = 0; Pattern < patternCount; Pattern++)
      {
      delay(500);
        for (int thisPin = 0; thisPin < pinCount; thisPin++)
          {
             Togglestate3 = digitalRead(Togglepin3);
             Togglestate = digitalRead(Togglepin);
             digitalWrite(ledPins[thisPin],All[Pattern][thisPin]);
             if (Togglestate3 == HIGH && Togglestate == HIGH)
                 {
                for (int thosePin = 0; thosePin < pinCount; thosePin++)
                    {
                    digitalWrite(ledPins[thosePin],LOW);
                    }

                 looper4();

                 }
             else if (Togglestate3 == HIGH && Togglestate == LOW)
                 {
                for (int thatPin = 0; thatPin < pinCount; thatPin++)
                    {
                    digitalWrite(ledPins[thatPin],LOW);
                    }
                 looper6();

                 }

             }
        }
  }

```

These are the functions that i used to read and toggle between the different 'looper' functions.

```
 void looper3()

 {
  Togglestate = digitalRead(Togglepin);

       if(Togglestate == HIGH)
         {
         looper4();
         }
        else if(Togglestate == LOW)
         {
         looper5();
         }

 }

 void looper4()

 {
  Togglestate2 = digitalRead(Togglepin2);
  Togglestate = digitalRead(Togglepin);

         if(Togglestate2 == HIGH && Togglestate == HIGH)
          {
          looper1();
          }
         else if(Togglestate2 == LOW && Togglestate == HIGH)
          {
          looper2();
          }

  }

 void looper5()

 {
  Togglestate3 = digitalRead(Togglepin2);
  Togglestate = digitalRead(Togglepin);

         if(Togglestate3 == HIGH && Togglestate == LOW)
          {
          looper6();
          }
         else if(Togglestate3 == LOW && Togglestate == LOW)
          {
          looper7();
          }

  }

```

Here is the toggling conditions for all my looper functions

```
 // Togglestate is the toggle switch i use to interchange between my 2 other
    toggle switches

 Looper1() - if (Togglestate2 == LOW && Togglestate == LOW) -> looper5();
           - if (Togglestate2 == LOW && Togglestate == HIGH) -> looper2();

 Looper2() - if (Togglestate2 == HIGH && Togglestate == LOW) -> looper5();
           - if (Togglestate2 == HIGH && Togglestate == HIGH) -> looper1();

 Looper6() - if (Togglestate3 == LOW && Togglestate == HIGH) -> looper4();
           - if (Togglestate3 == LOW && Togglestate == LOW) -> looper7();

 Looper7() - if (Togglestate3 == HIGH && Togglestate == HIGH) -> looper4();
           - if (Togglestate3 == HIGH && Togglestate == LOW) -> looper6();

```

This would be pretty much the whole program. I appreciate and welcome any response. Thanks!

# Answer
You can nest for loops fine. What you cannot do is neat for loops in loops where you name the variables the same thing.

```
For thisPin ...
   For thisPin ...
   For thisPin...

```

It gets the compiler confused - or at the very least it gets me confused. You can use the same have if the loops are next to each other, but not if they are nested:

```
For thisPin...
    For otherPin...
    For otherPin...

```

Also, without seeing your whole code I cannot be sure, but you may be suffering from unexpected recursion. This is where function a calls function b which calls function a again. With no limiting factor on the call depth you end up with a stack a mile high, or on chips with a limited hardware stack you loose lots and lots of old stack data and can never get back again.
> 1 votes

---
Tags: switch
---


# Question
Title: How to run multiple functions one after another?
I want to fade a red LED up and down, then a green LED up and down, and repeat the whole cycle indefinitely.

I've been trying to run multiple functions one after another. However my current code seems to have them both fading in parallel.

I tried using a `switch case`, `do while` and the `while` loop but the code runs the two functions at once. So what is wrong with the code below?

This is my code:

```
void setup() {
    Serial.begin(9600);
    DDRD |= (1<<DDD6)|(1<<DDD5);
    TCCR0A = 0xF1;
}

uint8_t fade_seq;

void loop() {
    loop1:
    fade_seq++;
    while (fade_seq==1)
    {
        fade_red(1);
    }
    Serial.println(fade_seq);
    while (fade_seq==2)
    {
        fade_green(1);
    }
    if (fade_seq==3)
    {
        fade_seq=0;
        goto loop1;
    }
}

void fade_red(uint8_t cnt)
{
    uint8_t i,k;
    for (k=0;k<cnt;k++)
    {
        OCR0A+=1;
        _delay_ms(10);
        if (OCR0A == 255)
        {
            for (i=0;i<255;i++)
            {
                OCR0A--;
                _delay_ms(10);
            }
        }
    }
}

void fade_green(uint8_t cnt)
{
    uint8_t i,k,c;
    for (c=0;c<cnt;c++)
    {
        for (k=0;k<255;k++)
        {
            OCR0B+=1;
            _delay_ms(10);
            if (OCR0B == 255)
            {
                for (i=0;i<255;i++)
                {
                    OCR0B--;
                    _delay_ms(10);
                }
            }
        }
    }
}

```

# Answer
I did not quite understand what you are *actually* trying to accomplish. Neither you question nor your code is very clear in this respect. And your code is probably buggy anyway, since it does not do what you expect.

Then, I am just guessing: you may just want to fade a red LED up and down, then a green LED up and down, and repeat the whole cycle indefinitely. I am guessing right?

First of all, I would recommend you stick with the functions provided by the Arduino core library, as they will make your life easier. The kind of low level AVR programming you are attempting here is for advanced users. You should learn the basics first before moving to that realm.

Here is how I would write that using the plain `analogRead()` function:

```
const uint8_t RED   = 6;  // pin connected to the red LED
const uint8_t GREEN = 5;  // pin connected to the green LED

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

// Fade an analog pin up and down.
void fade(uint8_t pin)
{
    for (int i = 1; i <= 255; i++) {
        analogWrite(pin, i);
        delay(10);
    }
    for (int i = 254; i >= 0; i--) {
        analogWrite(pin, i);
        delay(10);
    }
}

void loop()
{
    Serial.println(F("Fading RED."));
    fade(RED);
    Serial.println(F("Fading GREEN."));
    fade(GREEN);
}

```

Each LED fading up and down takes roughly 5 seconds: 2 ramps × 255 steps/ramp × 10 ms/step.
> 4 votes

# Answer
It simply is not possible for the processor to run both functions at once. What probably is happening is that the sequence of functions executes too fast to distinguish it as two sequential processes. You'll need to do something like call them with a delay in between. It could be as simple as:

```
void loop() {
   fade_red();
   delay(500);

   fade_green();
   delay(500);
}

```

The while loops surrounding your calls do nothing at all. The effect of each one is to call its respective function once. Your code is pretty much equivalent to a switch/case statement using fade\_seq as the selector, but without any control over the timing of your calls, the functions will happen in rapid sequence.
> 4 votes

# Answer
> Why my loops are very complicated?

OK, here is your loop:

```
uint8_t fade_seq;   // <--- initially zero

void loop() {
loop1:
fade_seq++;
while (fade_seq==1)
{
  fade_red(1);
}
Serial.println(fade_seq);
while (fade_seq==2)
{
  fade_green(1);
}
if (fade_seq==3)
{
  fade_seq=0;
  goto loop1;
}
}

```

So you add 1 to `fade_seq` and then:

```
while (fade_seq==1)
{
  fade_red(1);
}

```

So `fade_seq` is always 1 so that loops indefinitely. Therefore you can forget about everything else after it.

So you may as well write:

```
void loop() {
   while (true)
    {
    fade_red(1);
    }
 }

```

And since `loop`, well, loops, that simplifies to:

```
void loop() {
    fade_red(1);
   }

```
> 4 votes

# Answer
try this-and add to it calling a function in between-as discussed in comments that gives a visible delay-note I increased the delays as its probably going too fast

```
uint8_t fade_seq=1;
 void setup() {
DDRD |= (1<<DDD6)|(1<<DDD5);
TCCR0A = 0xF1;
}

void loop() {
fade_seq++;
if (fade_seq==1)
{
  fade_red(1);

}

if (fade_seq==2)
{
  fade_green(1);

}
if (fade_seq==3)
{
fade_seq=0;
}
}

void fade_red(uint8_t cnt)
{
  uint8_t i,k;
  for (k=0;k<cnt;k++)
  {
    OCR0A+=1;
    _delay_ms(100);
    if (OCR0A == 255)
    {
      for (i=0;i<255;i++)
      {
        OCR0A--;
        _delay_ms(100);
      }
    }
  }
}

void fade_green(uint8_t cnt)
{
  uint8_t i,k;
  for (k=0;k<cnt;k++)
  {
    OCR0B+=1;
    _delay_ms(1-0);
    if (OCR0B == 255)
    {
      for (i=0;i<255;i++)
      {
        OCR0B--;
        _delay_ms(100);
      }
    }
  }
}

```
> 2 votes

# Answer
OK I did it :)

```
void setup() {
DDRD |= (1<<DDD6)|(1<<DDD5);
TCCR0A = 0xF1;
}

void loop() {
  fade_red(255);
  fade_green(255);
}

void fade_red(uint8_t cnt)
{
  uint8_t i,k;
  for (k=0;k<cnt;k++)
  {
    OCR0A++;
    _delay_ms(10);
    if (OCR0A == 255)
    {
      for (i=0;i<255;i++)
      {
        OCR0A--;
        _delay_ms(10);
      }
    }
  }
}
void fade_green(uint8_t cnt)
{
  uint8_t i,k;
  for (k=0;k<cnt;k++)
  {
    OCR0B++;
    _delay_ms(10);
    if (OCR0B == 255)
    {
      for (i=0;i<255;i++)
      {
        OCR0B--;
        _delay_ms(10);
      }
    }
  }
}

```
> 0 votes

---
Tags: led, pwm, c
---


# Question
Title: Getting inverse values of acceleration and tilt for the MPU 6050
I'm using the I2C library to connect to a GY-521 board and, when executing the getAcceleration() methods I get gyro values and viceversa..

This is my setup (I'm using a proto shield but that shouldn't change anything as far as I understand):

It follows this schematic:

And this is the code I'm testing:

```
#include "Wire.h"

#include "MPU6050.h"

MPU6050 accel;

int16_t ax, ay, az;

void setup() {
    Wire.begin();
    Serial.begin(9600);
    Serial.println("Initializing I2C devices...");
    accel.initialize();
    Serial.println("Testing device connections...");
    Serial.println(accel.testConnection() ? "Connected" : "Connection failed");
}

void loop() {
    accel.getAcceleration(&ax, &ay, &az);
    Serial.print("acc x:    ");
    Serial.println(ax);  // This prints the gyro value of the Y axis!
    delay(1000);
}

```

I don't think it has to do with the wiring since inverting the 4 and 5 analog pins yields zero values.

Is this a problem with the library? Or with my chip?

# Answer
> -1 votes
There are a lot of libraries, I wouldn't use the accelerometer library in wire, download and add the I2Cdev library, you can get it on a variety of different sites like github.com

---
Tags: i2c, mpu6050
---


title: Mini Voice Recorder for Arduino

text:
# Question
Title: Mini Voice Recorder for Arduino
I am trying to find a small voice recorder that I can use with my Arduino Micro, and I found this. It is exactly what I am looking for, but it is now a retired product. I googled `ISD1932`, but many other sites are out of stock or not selling it anymore. Is there something of this size that does the same things, and why is it retired?

# Answer
> 1 votes
ISD 1820 voice recorder module for arduino. Or ISD series or ISD 1700 series voice recorder module. Which I think you can still buy these. Will work with 8bit CPU. Or can be interfaced to 8 bit CPU. You could use multiple modules to increase recording times. I can give you more of an answer if you tell me more about your problem. ISD4004 IC can record for 8 minutes.

# Answer
> 2 votes
FYI, these ISD chips sample audio and store a variable charge on a single flash like cell. They do not convert a sample to a numerical value. There is no data to be read from the chips nor (AFAIK) is there an opportunity to write data to play back to the chips. AFAIK, for us common people, each ISD chip needs to have its recording entered individually. Think of it like duplicating cassette tapes. Think about this when considering how to go about building your project.

# Answer
> 1 votes
It's retired because there is no market for it any more. Modern microcontrollers are more than powerful enough to handle simple audio without the need for external chips like that.

Some can even do full blown multi-channel HD audio with just the addition of a CODEC chip (that's a fancy name for a DAC to you and me).

Even a lowly 8-bit Arduino can play audio directly (though at low quality) through PWM from an SD card.

---
Tags: sensors, arduino-micro, audio, sound
---


# Question
Title: The Mysterious Case of the Mostly-Vegetable Servo
## Story:

I was playing around with my Uno along with a servo.

To my stupidity (or more appropriately: ignorance), I set the voltage to my servo with `analogWrite()`, rather than `servo.write()`. It worked for a bit; but once it reached it's limit, it kept trying to move, to no avail.

Realizing what I had done, I pull the power source from my Uno.

Then, I went to change the code, and tested my servo once more.

The servo's casing is transparent (there is a sticker blocking the motor and circuit; but I can see 4 of the gears).

The bottom 2 gears are ticking ever so slightly (and the top 2 even less so), resulting in the propeller to move at most 5 degrees. At this threshold, none of the mentioned gears are ticking, but something is heard (probably a whirring gear not in sight).

At this point, I would've come to the conclusion that a tooth of the third gear had broken.

However, after I pull the power plug and put it back in, it spins (backwards) into it's initial position and begins the process mentioned above again.

---

## Mystery:

Is my servo indeed broken?

What's not functioning correctly?

**Can it easily be repaired?**

# Answer
> Is my servo indeed broken?

Yes.

---

> What's not functioning correctly?

As you said, some of the gears must have shifted in some way hindering the smooth mouvement of the servo or making it simply not working correctly.

---

> Can it easily be repaired?

Well, it depends on you. Do you like repairing EXTREMELY small things? Are you skilled at that. I would say no, because it requires a lot of knowlage on the servo to be able to remove it, fix it, and not to forget, replace it into its original case. Simply buying a new one is quite cheaper and simpler.
> 2 votes

---
Tags: arduino-uno, programming, servo
---


title: How to track revolution of DC motor?

text:
# Question
Title: How to track revolution of DC motor?
I am currently trying to build a line follower robot that is designed to solve maze. This maze has a loop, thus it needs to know distance it already travelling (or at least I assume so, please let me know otherwise).

I am aware of a rotary encoder motor from Polulu (for example) but it's not available in my country and shipping price is too expensive.

So I need to find way around it. Should I use Stepper motor? Is there any other way? Thanks in advance.

# Answer
> 5 votes
You can Use wheel encoders. You can even make your own wheel encoders with general parts like photoTransistor and lasor or led light. you can make your encoder or print it out in paper. The use little math to calculate the distance. It will give you measurement with good level of precision.

Basic principle:

more information at

wheel Encoder

another encoder

# Answer
> 1 votes
You could add a rotary encoder to a motor yourself. Thought this is not as convenient as buying an all in one solution.

You can even build your own by making a disk with holes at regular intervals, and using an IR led, phototransistor pair on either side of the disk. You can even get all in one photo-interruptors. You could get them from an old computer-mouse. You might even be able to use the wheel/disk in it.

Another option is to add a magnet to the wheel, and a hall-effect sensor to the body. That way you can count the number of revolutions. (Though you probably want higher resolution than once per revolution).

# Answer
> 1 votes
An optical encoder would be the best solution in my opinion. The next best thing would be to use a stepper motor. You can find plenty of stepper motors in old printers - which is good if the budget is tight.

The problem with a stepper motor is that you have no feedback on where the motor actually is. You drive it forward say 100 pulses, but without any feedback you have no idea if there was any slip or overrun. This is called open loop control.

However, both of these methods are measuring/driving the rotation of the motor. What happens if the wheel doesn't have enough grip and slips and does a sort of burnout. For this reason, I have seen some maze robots use an old mouse to measure the distance the robot has actually travelled. This was not necessarily very accurate over long distances but was a cheap way of measuring distance travelled.

---
Tags: arduino-uno, sensors, motor
---


title: How fast can I drive a stepper motor?

text:
# Question
Title: How fast can I drive a stepper motor?
I have a 28BYJ 48, 5V stepper motor. After some trial and error I got it working with the all the sample examples in Arduino IDE.

However when I increase the speed of the motor using setSpeed() beyond 15, the motor stopped rotating. Following is the configuration in which I am running the motor.

```
const int stepsPerRevolution = 2048;
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
myStepper.setSpeed(15);

```

I wanted to understand what factors limit the speed. And how fast can I rotate this motor?

Thanks,

Manish

# Answer
*"I wanted to understand what factors limit the speed. And how fast can I rotate this motor?"* Read through the data sheet for your motor-the answers are there. Each different motor has its own data sheet. This will require some work on your part to find the data sheet and the info from it you require. Which can be used to deduce the answer your question.
> 0 votes

---
Tags: stepper
---


title: Compiling Error

text:
# Question
Title: Compiling Error
I am trying to compile this code on arduino IDE...It showing error code is

```
#include <IRremote.h>

int RECV_PIN = 6;
int led = 12;//1FE50AF
int led1 = 10;//1FED827
int led2 = 9; //1FEF807
int led3 = 8;//1FE3087
int led4 = 7;//1FEB04F
boolean previousState=LOW;
boolean previousState1=LOW;
boolean previousState2=LOW;
boolean previousState3=LOW;
boolean previousState4=LOW;
boolean state;
boolean state1;
boolean state2;
boolean state3;
boolean state4;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
  Serial.begin(9600);
  pinMode(12,OUTPUT);
  pinMode(10,OUTPUT);
  pinMode(9,OUTPUT);
  pinMode(8,OUTPUT);
  pinMode(7,OUTPUT);
  irrecv.enableIRIn();// Start the receiver
}
void loop() {
  if (irrecv.decode(&results))
  {
    Serial.println(results.value, HEX);
    switch(results.value)
    {
       case 0x1FE50AF:
       if (previousState == LOW)
       {state=HIGH;
        digitalWrite(led,state);
       previousState=state;}
       else
       {state=LOW;
       digitalWrite(led,state);
       previousState=state;}
       break;
        case 0x1FED827:
       if (previousState1 == LOW)
       {state=HIGH;
        digitalWrite(led1,state1);
       previousState1=state1;}
       else
       {state1=LOW;
       digitalWrite(led1,state1);
       previousState1=state1;}
       break;
       case 0x1FEF807:
       if (previousState2 == LOW)
       {state2=HIGH;
       digitalWrite(led2,state2);
       previousState2=state2;}
       else
       {state2=LOW;
       digitalWrite(led2,state2);
       previousState2=state2;}
       break;
        case 0x1FE30CF:
       if (previousState3 == LOW)
       {state3=HIGH;
        digitalWrite(led3,state3);
       previousState3=state3;}
       else
       {state3=LOW;
       digitalWrite(led3,state3);
       previousState3=state3;}
       break;
        case 0x1FEB04F:
       if (previousState4 == LOW)
       {state4=HIGH;
        digitalWrite(led4,state4);
       previousState4=state4;}
       else
       {state4=LOW;
       digitalWrite(led4,state4);
       previousState4=state4;}
       break;
    }
    irrecv.resume(); // Receive the next value
  }
}

```

**Error massage which I Getting during compiling**

> Arduino: 1.6.5 (Windows XP), Board: "Arduino/Genuino Uno"
>
> Using library IRremote in folder: C:\Documents and Settings\Santanu Mandal\My Documents\Arduino\libraries\IRremote (legacy)
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard -IC:\Documents and Settings\Santanu Mandal\My Documents\Arduino\libraries\IRremote C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\IRrecvDemowithled.cpp -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\IRrecvDemowithled.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard -IC:\Documents and Settings\Santanu Mandal\My Documents\Arduino\libraries\IRremote -IC:\Documents and Settings\Santanu Mandal\My Documents\Arduino\libraries\IRremote\utility C:\Documents and Settings\Santanu Mandal\My Documents\Arduino\libraries\IRremote\IRremote.cpp -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\IRremote\IRremote.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -x assembler-with-cpp -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\wiring\_pulse.S -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring\_pulse.S.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\hooks.c -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\hooks.c.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\WInterrupts.c -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\WInterrupts.c.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\wiring.c -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring.c.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\wiring\_analog.c -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring\_analog.c.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\wiring\_digital.c -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring\_digital.c.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\wiring\_pulse.c -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring\_pulse.c.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\wiring\_shift.c -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring\_shift.c.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\abi.cpp -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\abi.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\CDC.cpp -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\CDC.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial.cpp -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HardwareSerial.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial0.cpp -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HardwareSerial0.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial1.cpp -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HardwareSerial1.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial2.cpp -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HardwareSerial2.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial3.cpp -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HardwareSerial3.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\HID.cpp -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HID.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\IPAddress.cpp -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\IPAddress.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\main.cpp -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\main.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\new.cpp -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\new.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\Print.cpp -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\Print.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\Stream.cpp -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\Stream.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\Tone.cpp -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\Tone.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\USBCore.cpp -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\USBCore.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\WMath.cpp -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\WMath.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF\_CPU=16000000L -DARDUINO=10605 -DARDUINO\_AVR\_UNO -DARDUINO\_ARCH\_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\WString.cpp -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\WString.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring\_pulse.S.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\hooks.c.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\WInterrupts.c.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring.c.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring\_analog.c.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring\_digital.c.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring\_pulse.c.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring\_shift.c.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\abi.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\CDC.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HardwareSerial.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HardwareSerial0.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HardwareSerial1.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HardwareSerial2.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HardwareSerial3.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HID.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\IPAddress.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\main.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\new.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\Print.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\Stream.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\Tone.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\USBCore.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\WMath.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\WString.cpp.o
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-gcc -Os -Wl,--gc-sections -mmcu=atmega328p -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/IRrecvDemowithled.cpp.elf C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\IRrecvDemowithled.cpp.o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\IRremote\IRremote.cpp.o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a -LC:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp -lm
>
> collect2.exe: error: ld returned 5 exit status Error compiling.

# Answer
> 1 votes
You have been bitten by a bug in the compiler toolchain. The bug has already been reported. Suggested workarounds:

* add a few unused global variables
* add some unused functions.

---
Tags: ide, avr-gcc, compiler
---


# Question
Title: How to display an entire incoming string from the serial monitor in arduino ide?
this is my first question in this forum.

I need to receive a string from the Arduino serial monitor and display it when the communication is over. I have a similar problem like the one discussed in this thread:

https://electronics.stackexchange.com/questions/45543/how-do-i-receive-an-entire-string-as-opposed-to-1-character-at-a-time-on-the-ard

Only I'm using the Arduino serial monitor instead of a RaspberryPi to send strings so I can't program the sender to attach an identifier like '\n' at the end of the string.

```
char inData[20];
char inChar=-1;
byte index = 0;

while (Serial.available() > 0){
  ending[1]=ending[1]+1;
  if(index < 19){

      inChar = Serial.read();
      inData[index] = inChar;
      index++;
      inData[index] = '\0';
      Serial.flush();
  }
  Serial.print(inData);Serial.print("\t");Serial.println();
}

```

What I receive in the console looks like this:

```
M
Me
Mes
Mess
Messa
Messag
Message

```

I need to display only the final string

```
Message

```

The code has to know when the incoming string ended and then display it once.

I'd really appreciate any help I can get.

# Answer
If you really want a string. Try using `Serial.readString()`. It will return the full string.

The code could look like this:

```
if(Serial.available()  > 0)
{
  String message = Serial.readString();
  Serial.println(message);
}

```
> 2 votes

---
Tags: arduino-uno, serial, arduino-ide
---


title: Ethernet shield not working

text:
# Question
Title: Ethernet shield not working
I have an ethernet shield on an Arduino Mega 2560. I am running the code below. This is a slightly modified version of the DHCP ip printer example, namely I am setting a static IP instead of DHCP.

I was expecting to get:

```
Start Ethernet
My IP address: 192.168.178.163.

```

on the serial monitor. Instead I got:

```
Start Ethernet
My IP address: 0.237.237.237.

```

Any idea what the reason might be? If I am using DHCP (the unmodified example, commented lines in the code below), the code seems to freeze on the Ethernet.begin() call.The "Failed to configure ..." is not even printed.

Here is the sketch:

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

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {
  0x90, 0xA2, 0xDA, 0x10, 0xC1, 0x2C
};
byte ip[] = {192, 168, 178, 163};

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  // this check is only needed on the Leonardo:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Serial.println("Start Ethernet");
  // start the Ethernet connection:
  Ethernet.begin(mac, ip);
  /*if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    for (;;)
      ;
  }*/
  // print your local IP address:
  printIPAddress();
}

void loop() {

  switch (Ethernet.maintain())
  {
    case 1:
      //renewed fail
      Serial.println("Error: renewed fail");
      break;

    case 2:
      //renewed success
      Serial.println("Renewed success");

      //print your local IP address:
      printIPAddress();
      break;

    case 3:
      //rebind fail
      Serial.println("Error: rebind fail");
      break;

    case 4:
      //rebind success
      Serial.println("Rebind success");

      //print your local IP address:
      printIPAddress();
      break;

    default:
      //nothing happened
      break;

  }
}

void printIPAddress()
{
  Serial.print("My IP address: ");
  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(Ethernet.localIP()[thisByte], DEC);
    Serial.print(".");
  }

  Serial.println();
}

```

The situation is similar to Ethernet shield not getting IP, but I checked that all pins are connected properly. Also setting pin 10 to high does not change anything.

# Answer
> 2 votes
I found the solution in modrego's answer on Arduino Ethernet Shield 2 stuck on EthernetServer::begin(). I need the **Ethernet2** library for the W5500 Ethernet controller. The Ethernet library is for W5100 only.

This library is not included with the arduino.cc library(as of IDE version 1.6.12 and older, this will likely change in future versions). I had to install it. You can do this by:

1. **Sketch \> Include Library \> Manager Libraries...**
2. Type "ethernet2" in the **Filter your search...** field
3. Click on the **Ethernet2** entry.
4. Click the **Install** button.
5. Click the **Close** button.

You will need to change the line:

```
#include <Ethernet.h>

```

to:

```
#include <Ethernet2.h>

```

Other files included in example sketches for the Ethernet library will need similar modifications.

# Answer
> 0 votes
> Note that because the W5100 and SD card share the SPI bus, only one can be active at a time. If you are using both peripherals in your program, this should be taken care of by the corresponding libraries. If you're not using one of the peripherals in your program, however, you'll need to explicitly deselect it. To do this with the SD card, set pin 4 as an output and write a high to it. For the W5100, set digital pin 10 as a high output.

Ref. https://www.arduino.cc/en/Main/ArduinoEthernetShield

---
Tags: ethernet
---


# Question
Title: Arduino Nano (3.0) Use an USB Bluetooth stick
I was thinking to build a very small USB Audio Streaming device with aux output for an amp (I know they already exist, but I like the self invention). So I bought an Arduino Nano and a USB Bluetooth device with was originally for a computer. But I thought I might use it on the Arduino. After I removed the housing and soldered four wires onto the USB plug:

https://www.dropbox.com/s/ye5vveb98sfz1zq/IMG\_20161030\_132648\_01.jpg?dl=0

I needed to know how to wire them:

https://www.moddiy.com/product\_images/uploaded\_images/patillaje-conector-usb.jpg

So I connected:

* "1" to 5V+ on arduino
* "2" and "3" need to be connected to txd and rxd on the arduino (but I don't know whitch way around)... I read that I need to have 3.3v on "3" or the "+" wire but I have 5V Output on the digital Pins on the arduino (so I need some resistors, but I'm not familiar with calculating them).
* "4" to gnd

Can someone confirm and / or provide some information for me to get this thing running (Bluetooth device enabled and functioning)?

Further steps would be:

* coding the arduino to Use the Bluetooth module for audio streaming - preferrably three Channel.
* configure the arduino to give the stream to an amp.

I know my knowledge of electronics is not very good and I need some education. If you can provide some good learning websites - feel free to suggest.

# Answer
> 1 votes
Interfacing an Arduino with USB is already VERY hard. USB does not use the same Serial as protocol so don't connect it to Tx and Rx. The only way to interface an Arduino and an USB device is trough a USB shield, which is quite complex already.

Just for you information. USB uses 5V so no voltage divider is needed to reduce it to 3.3V. A voltage divider is pretty much 2 resistors in series where the original voltage goes in one end, the output voltages is between the 2 resistors and the other end is connected to ground. Read more about them here.

Now, communicating with Bluetooth is also complicated, but mix USB + Bluetooth and you get something **ALMOST** impossible (I hope the ALMOST is clear enough for any hatters). It is possible, but seeing you level of knowlage, simply don't risk having a severe depression trying to fingure it out!

In the end of the day, your plan of using that Bluetooth USB module is just going to be crazy complicated and big.

A more effective solution would be to use a module such as the HC-05 Bluetooth module. It is quite cheap if you get it from sites such as Amazon. Link here for this product on Amazon.com. It is designed with the Arduino in mind thus making programming easier. You project could also be a little smaller, because this module pretty much has the size of your Arduino Nano.

Hope it was helpful!

---
Tags: bluetooth, arduino-nano, usb
---


title: relay working problem

text:
# Question
Title: relay working problem
I am using circuits.io with Arduino. my program is to blink the led with 2 seconds delay. The led in the circuit blink according to program but the bulb does not blink. I am very weak in electronics. This is what i starting to learn from the scratch. the problem here is the bulb doesnt blink according to the program. which is meant to blink. i have uploaded the circuit image below.. . thanks in advanced.

# Answer
> 1 votes
If you wire up your circuit as shown below, the bulb and the LED should flash together.

---
Tags: relay
---


# Question
Title: What is the datatype of the pinMode function?
I just tried it, but the Arduino IDE crashed, I hope its not related. I want to declare a datatype like this:

```
int a = pinMode(pin, OUTPUT);

```

or something like that, but I'm not sure what datatype the `pinMode` function uses. I looked on the pinMode documentation page, of the Arduino website, and I see basic usage, but not a more clear definition of the source code for that function.

# Answer
> 2 votes
`pinMode(pin, Mode);` is a `void`. It doesn't return anything. It simply sets a pin as an `OUTPUT` or an `INPUT`.

It says it in the link you posted.

> Returns
>
> None

That means that the function doesn't return any value.

---
Tags: pins, digital, data-type
---


# Question
Title: All of the sudden the Nano will not accept programming
I have been working merrily along with CH340 to make Com10 work. It has been working flawlessly but now I am getting various messages like it can't open the port then the programmer is not responding. It tries several times before giving up.

This was working fine yesterday.

I tried uploading to a raw board not connecting to anything and am getting the same result.

Suggestions?

# Answer
> 1 votes
OK, problem solved. I wish I knew enough to be able to say why it worked, but here is what did the trick:

I uninstalled the IDE.
THEN REBOOTED.
Then installed the IDE (version 1.6.10) again, this time not selecting the USB driver.
THEN REBOOTED.

In Device manager it still shows the CH340 driver on COM14

All my sketches and the two libraries (DHT and LCD) in the documents/Arduino directory were unaffected.

And now it will upload to my boards just fine.

This is one of those times where I can't explain why, but I can tell you for sure that it worked for me. I had tried uninstalling/reinstalling, but without the rebooting in between. Perhaps that was the crucial step that needed to be taken.

# Answer
> 1 votes
This problem occurs quite often with all the boards. Here is how to troubleshoot it.

1 - Unplug the Arduino.

2 - Upload the program **WITHOUT** any boards connected to your computer.

3 - Replug your Arduino.

4 - Upload the program **WITH** your Arduino connected to your PC.

If this doesn't work, read this post by Nick Gammon.

---
Tags: arduino-nano, usb
---


title: Get Battery voltage on raw

text:
# Question
Title: Get Battery voltage on raw
I power my Arduino Mini with 3 AA batteries on `RAW` input. Is it possible to get the voltage on `RAW` and therefore the expected longevity of the batteries?

# Answer
No. Not directly. You can use voltage divider and measure the result with using internal reference. But it's another current consumption and you can't reduce it by (for example) entering one of the sleep modes.

And if you have `5V` Arduino Mini variant, you can power it directly through `5V` power pin. Otherwise you are losing about `1.5V` on voltage regulator. On `3.3V` variant it might be better, but it also depends on used regulator voltage drop and would be better to power it directly (if you don't have connected anything strictly with `3.3V` power, and for `AVR` based Arduinos it's not a problem)

Anyway, if you power it directly, you can measure the power source voltage by measuring internal bandgap voltage reference against power as reference. But, as far as I know, it can't be done by `analogRead`, as it doesn't support other sources than analog pins.
> 3 votes

---
Tags: voltage-level, battery
---


# Question
Title: code for line following robot not working perfectly
I have made a line following robot using 2 IR sensor. My line following robot was working successfully with this code.

```
#define LS 2      // left sensor
#define RS 3      // right sensor

/*-------definning Outputs------*/
int LM1= 5;       // left motor
int LM2= 6;     // left motor
int RM1= 9;       // right motor
int RM2= 10;

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

void loop()
{
  if(digitalRead(LS) && digitalRead(RS))     // Move Forward
  {
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, LOW);
  }
 else if(!(digitalRead(LS)) && digitalRead(RS))     // Turn right
  {
    digitalWrite(LM1,HIGH);
    digitalWrite(LM2, LOW);
    analogWrite(RM1,70);
    digitalWrite(RM2,LOW);
  }
  else if(digitalRead(LS) && !(digitalRead(RS)))     // turn left
  {
    analogWrite(LM1,70);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1,HIGH);
    digitalWrite(RM2,LOW);
  }else{
    digitalWrite(LM1, LOW);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1,LOW);
    digitalWrite(RM2, LOW);
  }
}

```

As I used only two sensor,sometimes it goes out of the line. So I have tried to make an advanced line following robot which could get back to track automatically when it goes out of the line.But the code is taking only the 1st value of tmp.(tmp=1) even when left sensor touches the line after white sensor and the robot goes out of the line.The value of tmp should be 2 when the robot goes out of the line and the left sensor touches the line after the white sensor. Here is the code:

```
/*-------definning Inputs------*/
#define LS 2      // left sensor
#define RS 3      // right sensor

/*-------definning Outputs------*/
int LM1= 5;       // left motor
int LM2= 6;      // left motor
int RM1= 9;       // right motor
int RM2= 10;  //right motor
int tmp;

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

void loop()
{
  if(digitalRead(LS) && digitalRead(RS))     // Move Forward
  {
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, LOW);
  }
 else if(!(digitalRead(LS)) && digitalRead(RS))     // Turn right
  {
    digitalWrite(LM1,HIGH);
    digitalWrite(LM2, LOW);
    analogWrite(RM1,70);
    digitalWrite(RM2,LOW);
    tmp=1;
  }
  else if(digitalRead(LS) && !(digitalRead(RS)))     // turn left
  {
    analogWrite(LM1,70);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1,HIGH);
    digitalWrite(RM2,LOW);
    tmp=2;
  }
  else//out of the line
  {
    if(tmp=1){
      analogWrite(LM1,70);
      digitalWrite(LM2, LOW);
      digitalWrite(RM1,LOW);
      analogWrite(RM2,70);
    }else if(tmp=2){
      digitalWrite(LM1,LOW);
      analogWrite(LM2, 70);
      analogWrite(RM1,70);
      digitalWrite(RM2,LOW);
    }
  }
}

```

# Answer
This test:

```
if (tmp = 1)

```

is always true. You are assigning `1` to `tmp` and that value (1), when interpreted in a boolean context (i.e. as a truth value), is `true`.

You probably mean

```
if (tmp == 1)

```

and similarly for the next test.
> 1 votes

---
Tags: arduino-uno, programming, arduino-ide
---


# Question
Title: LED won't turn on and serial monitor won't display values
I am trying to use my Arduino to record some values from a photo-resister. The idea is when a character other than g is read the LED will turn on and 512 values will be recorded.

When I type in a character in the serial monitor whether it is g or not it just says 1 or 0 but doesn't not provide me with the values I need from the photo-resistor. My code is as follows:

```
int timeOut = 60000;
int pollTime = 0;
int time = 0;
unsigned long startTime = 0;
unsigned long endTime = 0;
int x = 0;
int Vs[512];
int analogPin = 0;

void setup() {
  Serial.begin(9600);
  pinMode(9, OUTPUT);
  while (!waitFor('g', 200, 60e6)) {}
  analogWrite(9, 128);
  startTime = micros();
  for (x = 0; x < 512; x = x + 1)  {
    Vs[x] = (analogRead(analogPin));
  }
  endTime = micros();
  for (int x = 0; x < 512; x = x + 1)  {
    Serial.println(Vs[x]);
  }
  Serial.println(endTime - startTime);
}

void loop() {
}

boolean waitFor(char in, int pollTime, int timeOut)  {
  boolean done = false;
  char charWait;
  time = micros();
  while (time < timeOut)  {
    if (Serial.available())  {
      charWait = Serial.read();
      done = (charWait == in);
      Serial.println(done);
    }
  }
}

```

# Answer
> 1 votes
Like Edgar says, what you need to do is this:

```
bool waitFor(char in, int pollTime, unsigned long timeOut)
{
  while (micros() < timeOut)
  {
    if (Serial.available())
    {
      if (Serial.read() == in)
      {
        Serial.println("done");
        return true;
      }
    }
    delay(pollTime);
  }
  return false;
}

```

If it still doesn't run after that then change setup() to this:

```
void setup()
{
  Serial.begin(9600);
  Serial.println("Initialising...");
  pinMode(9, OUTPUT);
  while (!waitFor('g', 200, 60e6)) {}
  Serial.println("g command received...");
  analogWrite(9, 128);
  Serial.println("About to start...");
  startTime = micros();
  for (x = 0; x < 512; x = x + 1)  {
    Vs[x] = (analogRead(analogPin));
  }
  endTime = micros();
  Serial.println("Finished...");
  for (int x = 0; x < 512; x = x + 1)  {
    Serial.println(Vs[x]);
  }
  Serial.print("The result is : ");
  Serial.println(endTime - startTime);
  Serial.println("All finished.");
}

```

---
Tags: arduino-uno
---


# Question
Title: void loop followed by other "void" expressions
I hope this is a simple request from a newcomer to Arduino and programming. I have understood that once a program enters a void loop section, it loops round indefinitely. However I have recently seen examples of sketches where another void $$$$$ section follows the closure (by}) of the void loop. As I write this, I am looking at one example concerning a 7 segment display where "void Num\_Write(int)" follows the closure of the void loop. If the "loop" section does just that, as I have been lead to believe, how is a following section accessed?

Thank you, Rob

# Answer
The `void loop()` section is a function, the same as `void setup()` is a function. When you start you Arduino program another function, that you can't see in the IDE, call `setup()` and then calls `loop()` repeatedly.

These other function you have seen, i.e. `void Num_Write(int n)` can be called from either `setup()` or `loop()` and they will execute their instructions before returning to the function that called them. Its also possible the `Num_Write()` may call other functions before it returns controller to the function that called it.

The type `void` is used to represent nothing (its actually more complex than that, but for this level of explanation nothing will do). Other functions may return other types `int`, `char`, `bool` for instance. So if we had a function like this:

```
int theMeaningOfLife(void)
{
  return 42;
}

```

This is a function that returns an `int` (a number) so you would call it like this:

```
void setup()
{
  int number = theMeaningOfLife();
}

```

There is one catch, the function has to be declared BEFORE it is used, this allows the compiler to know what you are referring to. The simplest way of doing this is to write the function above the function that is calling it. The second way is to just write the function's signature above the function using it, i.e.:

```
int theMeaningOfLife(void);

void setup()
{
  int number = theMeaningOfLife();
}

```

The best way (but not always practical on an Arduino) is to have all the function declarations in a header file (.h) and the code in a .cpp file. (Have a look a library to see what I mean).

**Summary**

There is only one function that is called repeatedly and that is the `loop` function. Just because a function returns void doesn't mean its going to loop repeatedly.
> 1 votes

---
Tags: arduino-uno
---


title: HCSR04 Sensor without delay

text:
# Question
Title: HCSR04 Sensor without delay
I've made a code to make a stepper work together with a HCSR04 sensor. The problem here is that the sensor has to use a delay in order to work. This delay messes with the smootness of the stepper.

If I remove the code for the sensor the stepper runs verry smooth, adding the sensor code causes the stepper to run 'shaky'.

**The code:**

```
int trigPin = 11;
int echoPin = 10;

void setup()
{
pinMode(trigPin, OUTPUT); //Sensor
pinMode(echoPin, INPUT); //Sensor
pinMode(6,OUTPUT); // Enable
pinMode(13,OUTPUT); // Step
pinMode(12,OUTPUT); // Dir
digitalWrite(6,LOW); // Set Enable low
digitalWrite(5,LOW); // Set Step low
Serial.begin(9600);
}

void loop()
{
//rotateleft();
//Serial.println("ik draai nu exact een rotatie linksom");
//delay(1000);
//rotateright();
//Serial.println("ik draai nu exact een rotatie rechtsom");
//delay(1000);
//velocity();

 //sensor
 long duration, distance;
 digitalWrite(trigPin, LOW);
 delayMicroseconds(2); //**problem**
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(5); //**problem**
 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);
 distance = (duration/2) / 29.1;
 Serial.print ("cm:");
 Serial.print (distance);

//eigen creatie
if (distance > 20 && distance < 30)
{
  digitalWrite(13,HIGH); // Output high
  delayMicroseconds(1000); // Wait
  digitalWrite(13,LOW); // Output low
  delayMicroseconds(1000); // Wait
}

if (distance > 10 && distance < 20)
{
  digitalWrite(13,HIGH); // Output high
  delayMicroseconds(3000); // Wait
  digitalWrite(13,LOW); // Output low
  delayMicroseconds(3000); // Wait
}

if (distance > 1 && distance < 10)
{
  //digitalWrite(13,HIGH); // Output high
  //delayMicroseconds(1000); // Wait
  digitalWrite(13,LOW); // Output low
}

else
{
 velocity();
}

}

void velocity()
{
 digitalWrite(13,HIGH); // Output high
 delayMicroseconds(500); // Wait
 digitalWrite(13,LOW); // Output low
 delayMicroseconds(500); // Wait
}
 }

```

# Answer
> 4 votes
Have you searched for other libraries or example code for this particular sensor?

I found this NewPing library that claims to have been developed to fix poor performance of such modules due to poor timing methods.

# Answer
> 1 votes
You only have a single thread of execution of an Arduino. So you have limited options:

1. Live with it.
2. Use two Arduinos.
3. Use a microcontroller with 2 cores.
4. Interrupts

2 Is possible, you could have a slave mcu to drive the motor and control it over I2C. You will still have contention when you are driving the I2C bus, but you can time that so it is not when you are scanning.

3 Is a very similar solution to 2, but is all in one chip.

4. You MIGHT be able to use interrupts which will let processing continue whilst you are waiting for something to occur. I can't remember if the Arduino has timer interrupts, if it doesn't an external source could generate the interrupts and changes the state of the lines.,

---
Tags: arduino-uno, stepper, hc-sr04
---


# Question
Title: ATtiny84A support with "Attiny" board manager installed to Arduino IDE
Referring to page http://highlowtech.org/?p=1695, is it possible to program ATtiny84A as well, or just the chip version ATtiny84 (without "A")? Does anybody know?

# Answer
> 1 votes
According to the PDF ATTiny24/44/84 to ATTiny24A/44A/84A Migration AppNote it should be pretty easy as there are only some differences in electrical specifications. No changes in registers or so.

The signature bytes are the same too, so it should be posible even without adding another boards.

---
Tags: attiny
---


title: Input PUK code, when requested

text:
# Question
Title: Input PUK code, when requested
**Problem**:

I'm working with a **GPRS** module (the same as in the Arduino GSMShield). In some cases the PUK code is requested, and the **PIN** is thus **locked**. For this I wrote some code (which can be seen under "Software"). This code is based on the documentation of "GSM PIN Management". The only problem is that the module is telling us that **both** the **PIN & PUK** code is **locked**. The tutorials, however, does not provide an example **how** we should **resolve** this issue from the Arduino itself.

EDIT: When the SIM card is inserted in a smartphone. The PUK code is requested. When the PUK code is provided (and a new PIN) the SIM card is back to normal. But adding the PUK code via the GSM lib. doesn't really work, in contrast to using a smartphone to unlock the PIN code.

**Question**:

* Does anybody have an idea how to resolve this issue? And if it can be done?

**Hardware**:

* Atmega328p
* Quectel M95 (as GPRS module)

**Software**:

```
PINManager.begin();
int pin_query = PINManager.isPIN();
Serial.print(F("Pin Query is: ")); //output: -2
Serial.println(pin_query);
if(pin_query == -1)
{
  #ifdef DEBUG
    Serial.println(F("PUK is requested"));
  #endif

  if(PINManager.checkPUK(PUK_NUMBER, PIN_NUMBER_CORRECT) == 0)
  {
    PINManager.setPINUsed(true); // I also think this must by "false". Both things were tested, none of them worked.

  }
}

```

# Answer
I've resolved the issue by using **AT commands** instead of the GSM library provided through Arduino.

```
if(sendGPRSCommand(F("AT+CPIN?"),100).equals("AT+CPIN+CPIN:SIMPUKOK")){
    Serial.println(F("PUK is requested, entering it now"));
    String cmd = "AT+CPIN=\"";
    cmd.concat(PUK_NUMBER);
    cmd.concat("\",\"");
    cmd.concat(PIN_NUMBER);
    cmd.concat("\"");
    sendGPRSCommand(cmd,100);
  }

```

This code checks if the PUK code is requested, this is the case when the `pin_query` is -1 or -2 (see question). When the PUK code is requested the new PIN (which is still the same pin as the old one) is given in combination with the PUK code. The AT commands were found in this manual.
> 0 votes

---
Tags: arduino-uno, gsm
---


# Question
Title: Can I connect a servo directly to arduino uno without a transistor?
I am going to mount an ultrasonic sensor on the servo.

# Answer
> 5 votes
The Arduino's GPIO pins can drive the signal of most model servos directly, without any extra transistors.

Driving a model servo signal input is not the main problem with driving servos from an Arduino.

The main problem is trying to use the Arduino's power supply to power the model servo. With many model servo's, the amount of current the model servo needs to start, or when it is almost stopped is so big that the Arduino's power supply can't maintain 5V. As the Arduino's power supply voltage drops, the Arduino often gets reset, and the program restarts from `setup`.

---
Tags: servo
---


# Question
Title: How can I play music using a speaker and Micro SD card Module?
I am trying to play music using my Arduino and micro SD card module but can't seem to do it. Can anyone shed some light on this? The SD card module I'm using is a Catalex sainsmart micro SD card module. It has the outputs `VCC`, `GND`, `MISO`, `MOSI`, `CS`, and `SCK`. `VCC` is in `5v`, `GND` is in `GND`, `CS` is in `Pin 4`, `MISO` is in `Pin 12`, and `MOSI` is in `Pin 11`.

# Answer
> 2 votes
> This Arduino project is one of the most simple and fun projects you can build with Arduino in 10-15 minutes. The result of this make will be an Arduino Audio Player which will play “.wav” files. It consist of a speaker, a simple transistor acting as an amplifier and a micro-SD card adapter with a micro-SD in it through which the .wav files are loaded and played.

https://diyhacking.com/arduino-audio-player/

# Answer
> 0 votes
Use an MP3 shield. This includes an SD card reader on the board. Many tutorials are available for this popular board. This shield makes it easier to program the Arduino.

https://www.sparkfun.com/products/12660

---
Tags: arduino-uno
---