Questions tagged [sketch]

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

Filter by
Sorted by
Tagged with
49
votes
5answers
156k 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?
26
votes
12answers
102k 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
12k 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 can get the Arduino to tell me what the error is?
17
votes
2answers
29k 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.
16
votes
7answers
19k 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;...
9
votes
4answers
8k 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 ...
7
votes
2answers
5k 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 ...
6
votes
4answers
8k 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
4answers
25k 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 ...
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
707 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
2answers
59k 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 ...
5
votes
2answers
8k 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
264 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
412 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
24k 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
1k 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 ...
4
votes
1answer
3k 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
29k 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
5k 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
1k 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
1answer
2k 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
987 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
2answers
134 views

Can Arduino Sketch be used for production

There are lot of device support with the help of Boards Manager today and is on going in Arduino IDE. So I am curious to know about can one use those for production purpose. Or it is recommended for ...
3
votes
1answer
1k 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
8k 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
7answers
1k 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
1k 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
3k 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
483 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
79 views

Branchless programing on arduino?

So I've been looking into branchless programming to speed up code and I'm curious as to how exactly Arduino (or rather atmega328) actually reads machine instructions. Does it have a memory cache or ...
2
votes
1answer
5k 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
298 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
4answers
7k 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
2answers
491 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
897 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
1answer
35 views

Leds become dimmer after they reach a certain brightness, why?

Even if I don't use buttons and I do an automated thing that makes the led brighter(Even the non-rgb one)after sometime it resets itself to a dimmer light, why?* int Gled = 5; int Bled = 6; int Rv; ...
2
votes
3answers
355 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
4answers
186 views

Is there a way to keep a program on the Arduino after uploading new sketches?

I am looking for a way to keep a program on my Arduino Nano 3.0, after uploading new sketches on it. I would like to have a program on it that will control th screen and buttons at it. The user will ...
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
4k 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
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
6k 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
783 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
959 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
97 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 ...

1
2 3 4 5 6