arduino

How can I perform pre-main initialization in C/C++ with avr-gcc?

In order to ensure that some initialization code runs before main (using Arduino/avr-gcc) I have code such as the following: class Init { public: Init() { initialize(); } }; Init init; Ideally I'd like to be able to simply write: initialize(); but this doesn't compile... Is there a less verbose way to achieve the same effect?...

Appending ints to char* and then clearing

I'm working on a project using an Arduino and as such, I'm reading from a serial port (which sends ints). I need to then write this serial communication to an LCD, which takes a char*. I need to read several characters from the serial port (2 integers) into a string. After both have been received, I then need to clear the string to prep...

toggle two bits with a single operation in C?

Lets say I have a byte with 6 unknown values: ???1?0?? and I want to swap bits 2 and 4 (without changing any of the ? values): ???0?1?? But how would I do this in one operation in C? I'm performing this operation thousands of times per second on a microcontroller so performance is the top priority. EDIT It would be fine to "toggle...

Getting an input/output error from python with pyserial

I have a python script that writes data packets to an arduino board through pyserial. Sometimes while writing the code to the board pyserial raises an input/output error with errno 5 Some research says that this indicates an error while writing in the file representing the connection to the arduino board. The code that sends, sends on...

analogRead() returns junk when I print via serial [Arduino]

I'm making a clock with the Arduino and I want to make a button to set the time. So, just to test, I pluged a wire in the Analog Input pin 0 and wrote two lines of code to read the pin an print it via Serial, but all I get is junk. valm = analogRead(0); Serial.println(valm); And what I get from the serial monitor is this: ?j?d?±µ...

How can I prevent the need to copy strings passed to a avr-gcc C++ constructor?

In the ArduinoUnit unit testing library I have provided a mechanism for giving a TestSuite a name. A user of the library can write the following: TestSuite suite("my test suite"); // ... suite.run(); // Suite name is used here This is the expected usage - the name of the TestSuite is a string literal. However to prevent hard-to-find b...

C/C++ Memory Problem?

Hi there, Programming for my Arduino (in some kind of mix of C/C++), I noticed something weird. Everytime I communicate through the serial port, I keep an eye on the SRAM usage. Normally, it ranges between 300~400 bytes. However, after adding a new routine (see below), I noticed it always jumped from 300~400 bytes of free memory to EXA...

pyserial - How to Read Last Line Sent from Serial Device

So I have an Arduino connected to my Windows XP computer. It's just running a loop, sending a value over the serial port back to the computer every 100ms. I want to make a Python script that will read from the serial port only every few seconds, so I want it to just see the last thing sent from the Arduino. How do you do this in Pys...

Problems controlling a Rainbowduino

Hi guys, Ive just bought a Rainbowduino to control a load of individual LEDs (NOT an RGB matrix). All the documentation so far is aimed towards controlling RGB arrays which is not what I'm after. If youre unfamiliar with the Rainbowduino its an Arduino clone with 24 constant current channels of 120mA, 8 super source driver channel of ...

Bit masking an index to an array, Arduino environment

I'm trying to take a 16 bit unsigned integer from a structure, mask the first 8 bits of it, and use it as an index to an array with the function analogWrite which takes the output pin on the Arduino and the output byte as arguments. The code in question looks something like this: analogWrite(outputPin, my_array[myStructure->data & 0xFF0...

Standard or common arduino library for parsing HTTP requests?

I'm trying to get my arduino with ethernet shield set up as a server to understand GET and POST requests. I found this, and could modify it to meet my needs, but was wondering if something already exists in C++ that is extremely lightweight and might already be commonly used for arduinos with ethernet shields. ...

Bit setting and code readability

I have an Arduino application (well actually a library) that has a number of status flags in it - and originally I simply declared them as ints (well uint8_t so 8 bit unsigned chars in this case). But I could have combined them all into one integer and used bitmask operations to set and test the status. An example of the former: if (_s...

What is the difference of a Relay controller verses a Micro Controller?

What is the difference of a Relay controller verses a Micro Controller? I'm looking into Arduino boards and just getting into this stuff wanted to know the difference. understandable this is not a programming question but I am developing in PHP and would like to know what the difference is before I start to code to make sure I'm going ...

Hardware Programming - Hands-On Learning

Besides Arduino, what other ways are there to learn hardware programming in a hands-on way? Are there any nifty kits available, either a pre-assembled robot, that you can program to move a certain way, or do certain things, or anything similar to that? ...

How to turn on a single Arduino port using C#?

I have an Arduino Duemilanove USB. I have just a single LED wired up to a single port on it. I want to use C# to turn on this LED. Does anyone have a simple example of how to do this? Just the most basic on/off code is what I'm looking for. On a side note, I know there are some libraries written for .NET communication with Arduino. The ...

Arduino + Bluetooth module Help

Does anyone know how to connect the DF Robot Bluetooth module up to the arduino and get it to communicate with the software? I used this tutorial. I managed to get the light flashing on the module and it seems to be able to pair fine but when I run the serial monitor and send a letter (say 'H') which should turn a light on I get a Java...

What's the difference/relationship between avr and Arduino?

I've been interested in hardware programming recently but not started yet. I did some searching working,and have a vague idea: Arduino is a combination of both chip and breadboard. avr is a single chip,and need to buy a breadboard to get started. Can someone ensure or deny this? ...

RAD and BlinkM, how to control a BlinkM, with an Arduino through RAD

So I'm running RAD on my MacBook, I've been able to send serial commands with screen to the device and just light LEDs and simple stuff with the pins connected to the Arduino, however I have been unable to use any of the blinkM methods that RAD offers. They just fail to compile. Does anyone know how to control a blinkM with RAD? ...

Writing Byte Arrays to serial with Ruby

I'm not clear on how to write simple byte code arrays with ruby, more-so I'm absolutely stumped on how to use the Ruby SerialPort library, well to be honest I have it working pretty well however I have only been successful in sending ASCII over the serial port. For example it's really simple to write ASCII: @sp = SerialPort.new "/dev/...

Line Tracking Robot

Me and my friends are building a line tracking robot based on my previous question about how to track white line on a black surface. We settled on using photo resistors and a arduino board. Now all the reflectance sensors I've found are should be placed very close to the line 1 - 2 cm above the line. Now one of my team mates had a heated...