We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [sketch]

A sketch is compiled code that is uploaded to an Arduino board.

Filter by
Sorted by
Tagged with
44
votes
5answers
125k views

Is there any way to download a sketch from an Arduino?

I made a sketch, but then I lost it. However, I uploaded it to the Arduino before losing it. Is there any way I can get it back?
19
votes
13answers
79k views

Arduino Nano uploading gives error: avrdude: stk500_recv(): programmer is not responding

I have a Arduino Nano (Sainsmart) that I'm trying to upload a sketch to. Under the Arduino IDE, the device selected was Arduino Nano w/ ATmega328. However uploading the sketch gives me the error ...
17
votes
6answers
11k views

What happens if there is a runtime error?

What happens if there is a runtime error in a program? Will execution of the program just stop? Is there some way I get get the Arduino to tell me what the error is?
14
votes
7answers
15k views

Loading local libraries

I'm new to Arduino/C development (coming from a JavaScript/Ruby environment), but I was wondering if it was possible to include a library from a custom folder within a sketch? So this is my situation;...
14
votes
2answers
23k views

Asynchronous function calls in Arduino sketch

In an Arduino sketch, is there a way to make asynchronous function calls within the loop? Like listening to requests through http server and process them in a non-blocking way.
9
votes
4answers
7k views

How to really shrink a sketch

I want to make a sketch that is as small as possible, for test purposes. The problem is, when i compile the BareMinimum sketch (with an empty setup and loop), i get 466 bytes for the Uno and a ...
6
votes
4answers
6k views

ATtiny85 minimum setup to blink led

What would be the (very) minimum schematic to make a ATtiny85 blink a led? Restrictions are: There must be a C program compiled and uploaded to it, just like an Arduino board would have. The code ...
6
votes
1answer
3k views

strange behaviour of dtostrf()

I'm trying to program a little bit in Arduino, but I'm stuck with probably something trivial. This is what I have: char ang[3], lat[9]; dtostrf(GPS.angle, 3, 0, ang); dtostrf(GPS.latitude, 9,5, ...
5
votes
5answers
706 views

Should I try to make my sketches as small as possible, even when I have enough room?

There has been a lot of talk about shrinking sketches recently, but if you don't need the room, should it be done? Will it speed up my program? Take this code: int led = 13; int val; void setup() { ...
5
votes
4answers
20k views

How to add hysteresis to threshold values?

This code compares the analog input value against two thresholds, having three voltage regions. Then it will turn on an LED according to what region the read voltage is in. The problem is that when ...
5
votes
2answers
4k views

Is it possible to run a binary from EEPROM?

Say I wrote a compiled sketch to EEPROM then read it. Could I run the program from EEPROM? I guess the question is: Can an Arduino run software not in flash memory in the middle of executing the ...
5
votes
2answers
7k views

How to generate true random numbers over Arduino Uno without any external hardware?

Using a 'random' function in sketch gives same pattern of numbers every-time. But, I need to generate different numbers such that any number to repeat itself should have a very less probability.
5
votes
2answers
2k views

Random(min,max) Function only giving ~50 range no matter what the values?

I can't get the min,max range to function properly. Monitoring the serial, only gives out ~50 difference from the min. I then added truerandom.ino to try to fix, but no help. const int ledPin = 13; //...
5
votes
1answer
255 views

How to add the Wiring S board to Arduino IDE v.1.6.2?

My Arduino Uno is running out of memory to support my script (yes, I've tried several ways of optimize it already: PROGMEM, EEPROM, no Strings, and so on), so I would like to upload my script to my ...
5
votes
1answer
407 views

It is possible to program Linino to send HTTP requests and then use the returned values in sketch?

I am new to using Arduino Yun and I would like to know if it is possible to run a command from the Arduino sketch in order to make (probably, through the Bridge Library) Linino to execute a HTTP ...
5
votes
1answer
2k views

It is possible to run an entire script on the Linux side? If so, how, what and where to do that?

I am new to using Arduino Yun and I would like to know if it is possible to run an entire script on the Linux side. In my case the script should execute a HTTP request to a remote server, parse the ...
4
votes
2answers
2k views

What's taking up so much RAM in an almost empty sketch?

I wanted to check how much memory (RAM) is used by an "empty" sketch. Here is my code: int freeRam() { extern int __heap_start, *__brkval; int v; return (int) &v - (__brkval == 0 ? (int) ...
4
votes
4answers
21k views

What is better: one sprintf() or multiple strcat() and itoa()?

I was creating Arduino function which sends two int and additional chars between them and at the beginning and end of char array - then print that array to the serial port in almost real time. (For ...
4
votes
1answer
2k views

Check contents of buffer after serial read

I would like to test the contents of data received over a serial connection. In my loop() I store the data in bffr; and afterwards I would like to test to see if there are some predefined words in it. ...
3
votes
2answers
27k views

sprintf() to assemble String and float pieces locks up

I'm trying to parse many variables into a URL so that I can update a website through a simple HTTP API with sensor data. After talking to a buddy of mine, he suggested going with the code below. ...
3
votes
2answers
3k views

ino.hex vs ino.with_bootloader.hex

I'm working on a Android App able to update the content of my Arduinos. Start to work (reset the Arduino, communicate with STK500 protocol, get id of ATmega and so on). But I face a question about the ...
3
votes
2answers
916 views

What programming practices should be adopted while coding sketches for Arduino?

What are some of the best programming practices that can be adopted while coding sketches for Arduino, so that it uses the least memory and performance should not suffer from memory outage, and still ...
3
votes
2answers
42k views

“stray '/302' in program error” when compiling

For some weird reason, the following code doesn't compile. I get a "stray '\302' in program" error around volatile unsigned int encoderPos = 0;, and I have no idea what the issue is. I've been trying ...
3
votes
1answer
480 views

Double ## in macros

I was looking at some macro use in an Arduino code. I believe what this macro does is it expands into a state that basically sets a pin to either input or output, but I'm a little confused about ...
3
votes
2answers
965 views

How to implement multiple LED modes in a sketch with potentiometers?

My hardware is 4 potentiometers connected to Arduino Analog 0-3, the output is an RGB led driver connected to Digital outputs 9,10,11. The output channels provide access to PWM control of those pins. ...
3
votes
1answer
865 views

What is the Arduino Uno default sketch?

When I bought my Arduino Uno and connected it to my computer, I tried to make the simple blink circuit (before programming the Arduino) and suddenly the LED started blinking. Is the blink example the ...
3
votes
3answers
7k views

AES Simplified for Arduino - Having hard time achieving desired result

Okay, here's the story. I'm not very familiar with how Arduino works but learning. I have a project that requires AES encryption on the Arduino Uno. As per a previous question we managed to figure out ...
3
votes
2answers
2k views

How can the Arduino check if it is connected to a PC and the PC is on?

I have been searching around the Internet to find if there is a way to check whether an Arduino is connected to a PC or not. For example: if my PC is turned on, the Arduino will listen to any serial ...
2
votes
5answers
878 views

Include Git tag (or SVN revision) in Arduino sketch?

Is there any way to get the current Git tag/commit identifier into an Arduino sketch binary? For normal desktop program development, you can pull some tricks with the Makefile (as pointed out in this ...
2
votes
3answers
787 views

Constructing my own serial command syntax to control arduino

I know this is a basic question, but as a hardware electronics guy and not a programmer I cannot seem to fathom how to do this - so any examples of code would be greatly appreciated: I want the ...
2
votes
3answers
2k views

Wrong data from DS18B20 temperature sensor after long power off

I have my Arduino Uno connected to the PC via USB when prototyping. I am developing a thermometer with memory, using DS18B20 sensors. When PC is shut down, there is no power on the USB and the ...
2
votes
3answers
467 views

What is wrong with my code? RGB potentiometer

Arduino programming has been a huge learning curve for me and I am trying to create a project with an rgb that's color is determined by a potentiometer. To where the further I turn it, the further ...
2
votes
1answer
4k views

A1 was not declared in the scope

I'm trying to put all my settings in a config.h file and then #include it in the Arduino sketch. Here's what my config.h looks like: RobotConfig.h #ifdef BOT //hardware pins int motor1Pin = ...
2
votes
1answer
278 views

How to execute commands on Arduino (via PC) without touching the current sketch?

I am working on my first Arduino project. It's a Reverse Geocache. Basically, it's a puzzle where a battery-powered Arduino is mounted inside a locked box, and is able to unlock the box if the user ...
2
votes
2answers
482 views

What do these operators do?

Going through the "timeouts" example of the elapsedMillis library (https://github.com/pfeerick/elapsedMillis) I found the following statement: digitalWrite(LEDPIN, flashPattern[ledIndex++] ? ...
2
votes
1answer
851 views

How can I use Python from a sketch?

I'd like to be able to use Python from a sketch. According to the Arduino playground, one can use PySerial from a computer to talk with an Arduino via Python. It looks like from that page you can ...
2
votes
3answers
84 views

Set variable value with serial?

so I need to make a arduino program, generates 2 random numbers, makes a + calculation with them and asks user the right answer. If the answer is right AKA Calculation==User Answer, then led is set to ...
2
votes
2answers
1k views

How to program an offbrand arduino uno?

So I recently bought this off brand arduino uno from betemcu.cn. it says its r3 compatible. Can I program this thing with the arduino coder or do I need to use something else? whenever I try ...
2
votes
2answers
3k views

Empty char variable

How do I empty all the values inside a variable char array[256];? I tried a for loop assigning an empty value at each iteration, but it doesn't compile.
2
votes
4answers
5k views

Interrupt fires multiple times

I have a Photo Interrupter which I am using to count the RPM of a motor. I am incrementing an integer to show the amount of interrupts there have been. The issue is that there can be several ...
2
votes
3answers
1k views

Arduino error in code

i'm making a project and i came across the follwing error. Whan i'm trying to compile and upload the code i'm getting those errors: ShiftRegisterTest1.ino:In function 'int* return_pins(int)' displays....
2
votes
1answer
4k views

how to send argument to ESP8266WebServer objects on function

this probably simple thing to do however I can't think of a way to pass argument to function call ESP8266WebServer server ( 80 ); void toggleRelayOne() { char temp[400]; String msg = ""; if (...
2
votes
1answer
663 views

Strobe Frequency Calculation, how its done?

I'm using the Arduino sketch for LED stroboscope found here: http://mehax.blogspot.co.uk/2011/02/arduino-stroboscope.html. Also below, I've inserted the loop part where this calculations are made: ...
2
votes
2answers
872 views

Modify SSID and Passwords in WiFi sktechs

This is a question about modifying sketches other than through the IDE. I'm using an Arduino Uno r3 + Arduino WiFi Shield (not the 101). Up to now I've been using the IDE to manually change the ...
2
votes
1answer
93 views

How does this code move the bird sprite in this sketch?

I'm teaching this sketch in my class. I understand most of the sketch and can see the class that makes the bird move, but I still don't quite understand how the code makes the sprite "move." I can ...
2
votes
2answers
2k views

Exoskeleton Motor Control Code

Background: I have been working on an exoskeleton project with a group of friends, and I need help. I made another post on the robotics.stackexchange site for the drive system: https://robotics....
2
votes
2answers
4k views

Arduino unable to read from XBee Series 2

An XBee Series 2 is set to Router AT whose TX and RX pins are connected to an Arduino Nano's Rx and Tx pins respectively. The Arduino is connected to a Mac OSX via USB. A second XBee Series 2 is ...
2
votes
1answer
158 views

Arduino Simon Says with Midi Controller

I altered code for the Simple Simon says to work with a Midi controller instead of push buttons. i am having trouble with the input of the song sequence with the Midi Controller. during the time where ...
2
votes
2answers
2k views

Upload sketch via Bluetooth using HC-06 module

I'm dealing with an application in which I need to upload sketches remotely to an arduino UNO board. I successufully managed to upload sketches using an HC-06 bluetooth adapter. The only problem is ...
2
votes
0answers
671 views

Unable to upload sketch using Platformio (but Arduino IDE works)

I am using an Arduino Nano (Clone) which I was programming with the Arduino IDE (Version 1.8.5 on Mac OS X 10.10.5). Using the Arduino IDE I need to re-plug the Nano before uploading, but after doing ...