Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
huhu
Feb 24, 2006

arduino.cc posted:

Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.
Arduino can sense the environment by receiving input from a variety of sensors and can affect its surroundings by controlling lights, motors, and other actuators. The microcontroller on the board is programmed using the Arduino programming language (based on Wiring) and the Arduino development environment (based on Processing). Arduino projects can be stand-alone or they can communicate with software running on a computer (e.g. Flash, Processing, MaxMSP).
Read more here: http://arduino.cc/

Video Examples
https://www.youtube.com/watch?v=hJIkJ9x0-JQ
https://www.youtube.com/watch?v=v56zLOqhjV4
https://www.youtube.com/watch?v=6mXM-oGggrM
https://www.youtube.com/watch?v=zE5PGeh2K9k

Where to buy?
SparkFun Electronics- Great store for from parts, to boards, to entire kits.
Adafruit Industries - Haven't purchased here yet but they look comparable to SparkFun.
EBay - If you look around you can get some great deals off of Ebay. A decent bit can be had from China for lower prices but quality drops and shipping times increase.
RadioShack - From what I've gathered, RadioShack used to be a great place to get parts but they've deteriorated in recent years. They're good for random small parts that you need ASAP but I would suggest any of the other resources first.

Resources
Arduino.cc Reference Page - This page explains many of the basic functions used in coding.
Bildr - Great website for tutorials with different components.
SparkFun Electronics - On almost every product page there is a link to at least one guide using that part.

Goon Projects (Post in here or PM me)

huhu fucked around with this message at 00:42 on Apr 8, 2013

Adbot
ADBOT LOVES YOU

huhu
Feb 24, 2006
Just kidding, have my first two questions.

Here is the first thing I'm working on:
http://www.oomlout.com/oom.php/products/ardx/circ-01

What is the purpose of the resistor in the setup? I see that it goes Pin 13 -> LED -> Resistor -> Ground.

Also, there is a wire between 5V on the Arduino board and the + on the bread board. However, there is nothing else connected to the + and with or without this wire the light still works. What is the function of this?

Arcsech
Aug 5, 2008

huhu posted:

Just kidding, have my first two questions.

Here is the first thing I'm working on:
http://www.oomlout.com/oom.php/products/ardx/circ-01

What is the purpose of the resistor in the setup? I see that it goes Pin 13 -> LED -> Resistor -> Ground.

Also, there is a wire between 5V on the Arduino board and the + on the bread board. However, there is nothing else connected to the + and with or without this wire the light still works. What is the function of this?

The resistor limits the current through the LED - the Arduino can only push like... 50mA or so, I want to say, so you can just use the pins straight if you need to, but it's a good idea anyway. If you used an LED with no resistor and something that is capable of putting out more current at 5V (like a power supply), then you'd blow out your LED.

I don't understand your second question, it looks like the resistor is connected to the + rail on your breadboard.

Also this kind of stuff is usually a function of the learning electronics megathread, so I don't know if Arduinos all by themselves deserve a thread.

Delta-Wye
Sep 29, 2005

huhu posted:

Just kidding, have my first two questions.

Here is the first thing I'm working on:
http://www.oomlout.com/oom.php/products/ardx/circ-01

What is the purpose of the resistor in the setup? I see that it goes Pin 13 -> LED -> Resistor -> Ground.

Current through the resistor-led circuit is determined by R using Ohms Law. Ohm's Law is V = IR. The total voltage drop is 5V, but the drop across the resistor is actually 5V minus the forward voltage of the diode, if you assume an ideal diode. Rearranging to find I,
code:
V = I*R,
where V = (5 - Vf);
(5 - Vf)/R = I
A 'normal' diode usually has a forward voltage on the order of 2V or so, meaning the current is 3V/560 = 5.3 mA, roughly speaking. I wouldn't push any single pin on the microcontroller much past 40mA or so, and often times you have total current for a set of outputs (Don't know if that is the case with the arduino's microcontroller). LED brightness is related to the current through the device (although this isn't a linear relationship) so you can even experiment with some different R values and see the change. Just stay about 3.5V/30mA = 120ohms or so to stay on the safe side.

If you've taken calculus, you should recognize that as R goes to zero, I balloons to infinity. At some point a nonlinear effect is going to take over because we're dealing with nonideal components, but no guarantee that will happen before something blows up. You can see this occasionally with LED circuits, like this LED throwy: http://www.instructables.com/id/LED-Throwies/ The current is self-limiting even though the battery is connected directly to the LED without a resistor; I wouldn't count on this for your arduino board.

Do check out the Black Smoke thread though, tons of additional information in there!

(As an aside, I looked into it a bit and the arduino supposedly has symmetrical sink/source limitations which strikes me as unusual. So much for my habit of using I/O pins as low-side switches!)

huhu posted:

Also, there is a wire between 5V on the Arduino board and the + on the bread board. However, there is nothing else connected to the + and with or without this wire the light still works. What is the function of this?

Habit, probably. I'm sure it will be used later on. Most of the breadboards I use have red/black wires connecting the LR side buses together permanently because I rarely (if ever!) want them separated. I'm sure you will find the same thing and that wire will always be there regardless if you are really using it or not.

Delta-Wye fucked around with this message at 10:18 on Sep 6, 2012

some kinda jackal
Feb 25, 2003

 
 
Is anyone familiar with Fritzing?

I'm trying to fab up a PCB with an ADXL325 accelerometer, only I have the accelerometer as a base chip, not a pre-supplied breakout board.

I'm trying to maybe just do a generic part, but the ADXL325 is a LFCSP-16 chip which I can't find a "generic" PCB component for.

I'm aware that I might have to create one myself, but I'm hoping someone knows where I can find one before I have to learn to create custom ICs.

nogthree
Jun 28, 2008

Martytoof posted:

Is anyone familiar with Fritzing?

I'm trying to fab up a PCB with an ADXL325 accelerometer, only I have the accelerometer as a base chip, not a pre-supplied breakout board.

I'm trying to maybe just do a generic part, but the ADXL325 is a LFCSP-16 chip which I can't find a "generic" PCB component for.

I'm aware that I might have to create one myself, but I'm hoping someone knows where I can find one before I have to learn to create custom ICs.

Unfortunately at this point in time the Fritzing parts library and parts creation interface are atrociously bad. I have a few friends who swear by it but really don't use anything more than common through hole components and so don't run into these common issues.

The best luck I've had so far is looking through the 'issue' that fritzing has set up for people to submit their additions to at http://code.google.com/p/fritzing/issues/detail?id=875

some kinda jackal
Feb 25, 2003

 
 
Are there any viable alternatives for Fritzing that won't cost an arm or a les and will run ether under OSX or Linux? Honestly after playing with Fritzing I'm hitting a bunch of walls. It's no big deal or anything.. I bought e accelerometer chips for next to nothing so if I have to break down and buy the breakout bard version I will probably live to fight another day.

KaiserBen
Aug 11, 2007

Martytoof posted:

Are there any viable alternatives for Fritzing that won't cost an arm or a les and will run ether under OSX or Linux? Honestly after playing with Fritzing I'm hitting a bunch of walls. It's no big deal or anything.. I bought e accelerometer chips for next to nothing so if I have to break down and buy the breakout bard version I will probably live to fight another day.

EAGLE is what I use for PCB layout, as do many (most?) hobbyists. It runs on OSX just fine.

I don't think it has your accelerometer in the standard library, but creating a part isn't very hard, and there are a lot of tutorials out there for it.

some kinda jackal
Feb 25, 2003

 
 
Awesome, thank you :)

Zuph
Jul 24, 2003
Zupht0r 6000 Turbo Type-R
KiCad is also good, and gaining popularity.

Delta-Wye
Sep 29, 2005

Martytoof posted:

Awesome, thank you :)

That accelerometer, or a very similar one, is probably available in sparkfun's libraries. The time put into Eagle now will pay off later if you keep designing PCBs, fyi. It's a little awkward but once you get up the learning curve it can be sort of fun.

Jonny 290
May 5, 2005



[ASK] me about OS/2 Warp
New board!

http://arduino.cc/en/Main/ArduinoBoardDue



Lookit all that friggin' I/O.

Cortex M3 at 84 MHz, native USB, 54 GPIO pins, 12 analog ins and 2 12-bit DAC outs!


Music makers, this is your fuckin' jam.
Looks like it's going to go for $50ish.

Arduino 1.5 will support compiling to it, and has some other nice usability bumps.

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome
i was at radio shack the other day and noticed they actually have a bunch of arduino stuff all up in there, which i think is a good thing.

Pompous Rhombus
Mar 11, 2007
Came in here hoping there'd be a dedicated thread for Arduino's!

I've been kind of passively following Arduino news for a while (have only the most basic knowledge of programming/soldering, but interested in learning a bit), and am interested in finally trying something out. It really appeals to my imaginative/creative side, and it seems like there's a lot of community support and information out there to help me on my way.

One project I think might be kinda neat is being able to control my apartment's lights/climate control through the internet, as both have remotes (:japan:). I see that people have written sketches that will read/record the IR protocols from a remote, I assume once you've got those it's pretty straightforward to output them through an IR transmitter?

ANIME AKBAR
Jan 25, 2007

afu~

Jonny 290 posted:

New board!

http://arduino.cc/en/Main/ArduinoBoardDue



Lookit all that friggin' I/O.

Cortex M3 at 84 MHz, native USB, 54 GPIO pins, 12 analog ins and 2 12-bit DAC outs!


Music makers, this is your fuckin' jam.
Looks like it's going to go for $50ish.

Arduino 1.5 will support compiling to it, and has some other nice usability bumps.

It's nice to see an ARM-duino variant which actually has the Arduino brand to back it up now. Hopefully they give decent support for the DMA and USB, unlike the maple.

Zuph
Jul 24, 2003
Zupht0r 6000 Turbo Type-R

ANIME AKBAR posted:

It's nice to see an ARM-duino variant which actually has the Arduino brand to back it up now. Hopefully they give decent support for the DMA and USB, unlike the maple.

More than anything, I'm excited to see that the Arduino platform now has real support for multiple hardware platforms.

Serjeant Buzfuz
Dec 5, 2009

Sweet! An Arduino thread!

I've got a Mego 2560 and a Uno for a quad copter that I'm building currently.

I really hope that the processing IDE gets updated (or replaced) in the future. I find it to be rather lacking in high end features. Is there any way to replace it with some other development environment?

JesusDoesVegas
Jul 8, 2005

The Funk Ambassador
Lipstick Apathy
I love these little boards. Previously I created a garden lighting setup that used PWM to randomly increase and decrease in brightness (ala the Mac light breathing effect). It made for a very serene lighting experience. I should have taken video... Not hard to make at all, definitely a good first project.

Currently I'm awaiting the arrival of another Uno board and a bunch of pots so I can build my Auduino granular synth. These things are really easy to build and with the addition of an echo can sound really rad. https://www.youtube.com/watch?v=q9tmbrG7D-o

My plan is to attempt to add a metronome that pulses an IR LED so I can drive my Space Baby echo module. https://www.youtube.com/watch?v=qCax1eCkP8U

I want to drive power to the space baby through the arduino, and put them both in the same enclosure. The Auduino's pitch control pot will be played with a softpot, so it will sort of resemble a stylophone only you can play with just your finger.

It would be nice to be able to add a way to tune the thing on the fly (change key and scale), but I lack the programming knowledge to do this. I'll post pics/vid as progress is made if anyone cares.

JesusDoesVegas
Jul 8, 2005

The Funk Ambassador
Lipstick Apathy
I'm going to double post here to ask a question...

My programming knowledge is very limited... I did some Vbasic in highschool almost a decade ago. I know Arduino is based around a simplified C+ language. Does anyone have any suggested resources for learning what I would need to actually get up and running with the software end of one of these?

I purchased the getting started with arduino book, which gives the quick and dirty basic basics, but It doesn't really set out to teach someone to be self sufficient with their coding. For my previous project I basically banged my head against the wall attempting to write the code for what I wanted, and after a while I found a program someone else already wrote that worked for me. That's part of what's awesome about the platform, but at the same time it seems like a crutch. For example, my previous post describes my want to add novel functionality to the Auduino. I'd be on my own with that one. I know learning a programming language isn't easy but I'm not currently in school, so I've got time to kill.

Edit - Would learning Processing be helpful/easier than jumping head first into C+?

JesusDoesVegas fucked around with this message at 08:44 on Oct 26, 2012

Delta-Wye
Sep 29, 2005
My experience with both Processing and Arduino makes me lean towards "learn by example". Do as many projects as possible using other people's code as a 'crutch'. By crutch I don't mean just use it whole-sale, I mean read it, understand it, and customize it to your particular needs. After a while you will have a pretty good feel for what either platform can do, what simplifying functions are available to you, etc.

That said, if you don't know C-style syntax at all, some basic programming tutorials/lessons/etc may be in order to get you up to speed so you can comfortably digest what you're seeing in other people's projects. I walked into both platforms with a strong set of programming skills and so understanding the gist of what someone else's code was doing was easy, I just had to look up the occasional library call that wasn't clear. If that is not the case for you, understanding the syntax is important to being able to reverse engineer code samples.

JesusDoesVegas
Jul 8, 2005

The Funk Ambassador
Lipstick Apathy
For anyone in the same boat as me trying to follow Delta-wye's advice, I found a pretty good YouTube series that shows the process of coding various increasingly complicated projects. Search sciguy14 on YouTube (I'd post a link but I'm on my tablet).

It won't teach you to be self sufficient but it will provide insight for why code and circuits are set up the way they are, which is perhaps vital for those of us on this intro "script-kiddie" level.

Delta-Wye
Sep 29, 2005

JesusDoesVegas posted:

For anyone in the same boat as me trying to follow Delta-wye's advice, I found a pretty good YouTube series that shows the process of coding various increasingly complicated projects. Search sciguy14 on YouTube (I'd post a link but I'm on my tablet).

It won't teach you to be self sufficient but it will provide insight for why code and circuits are set up the way they are, which is perhaps vital for those of us on this intro "script-kiddie" level.

Yeah, there is also the electronics aspect which is a whole other beast (and can be somewhat avoided when working in Processing). What kind of projects does the youtube channel walk you through?

JesusDoesVegas
Jul 8, 2005

The Funk Ambassador
Lipstick Apathy

Delta-Wye posted:

Yeah, there is also the electronics aspect which is a whole other beast (and can be somewhat avoided when working in Processing). What kind of projects does the youtube channel walk you through?

Fairly basic projects that illustrate key concepts of interfacing with the arduino. A bit of tinkering with what the vids showed me and I was able to work out how to make my potentiometer fees only 12 different output values instead of 1024, allowing me to select key on my synth. This from very little previous coding experience is pretty good.

Base Emitter
Apr 1, 2012

?

Jonny 290 posted:

Cortex M3 at 84 MHz, native USB, 54 GPIO pins, 12 analog ins and 2 12-bit DAC outs!

Music makers, this is your fuckin' jam.

Just what I want, and just what I want it for.

I haven't used Arduino or Processing before, can you program this board in C++ easily enough? I've done some stuff with mbed boards, which are really straightforward to program (they just look like flash drives to your PC), and I'd prefer to use a familiar language than learn another niche language...

Pompous Rhombus
Mar 11, 2007

Pompous Rhombus posted:

Came in here hoping there'd be a dedicated thread for Arduino's!

I've been kind of passively following Arduino news for a while (have only the most basic knowledge of programming/soldering, but interested in learning a bit), and am interested in finally trying something out. It really appeals to my imaginative/creative side, and it seems like there's a lot of community support and information out there to help me on my way.

One project I think might be kinda neat is being able to control my apartment's lights/climate control through the internet, as both have remotes (:japan:). I see that people have written sketches that will read/record the IR protocols from a remote, I assume once you've got those it's pretty straightforward to output them through an IR transmitter?

Repostin' this cuz I was hoping for an answer.

Jonny 290
May 5, 2005



[ASK] me about OS/2 Warp

Base Emitter posted:

Just what I want, and just what I want it for.

I haven't used Arduino or Processing before, can you program this board in C++ easily enough? I've done some stuff with mbed boards, which are really straightforward to program (they just look like flash drives to your PC), and I'd prefer to use a familiar language than learn another niche language...

As best as I can tell, it's straight C, with some libraries. When you compile, the Arduino IDE slaps some boilerplate up top and adds a main() at the end before it compiles and sends it over.


Pompous Rhombus posted:

Repostin' this cuz I was hoping for an answer.

There's a lib for that!

Check out the following link, it should get you started.

http://arduinostuff.blogspot.com/2011/05/receiving-and-sending-ir-with-arduino.html

kafkasgoldfish
Jan 26, 2006

God is the sweat running down his back...

Base Emitter posted:

Just what I want, and just what I want it for.

I haven't used Arduino or Processing before, can you program this board in C++ easily enough? I've done some stuff with mbed boards, which are really straightforward to program (they just look like flash drives to your PC), and I'd prefer to use a familiar language than learn another niche language...

You could also get a Netduino which you can program in .NET and they have flavors that are in the 140-160MHz range. It is worth noting that since it is a JIT-compiled language, you're not as close to the raw metal as you are even in an Arduino.

I only mention this because if you're familiar with C++, C# would be reasonably easy to learn and you could continue using OOP concepts. Netduino's accept many Arduino shields.

JesusDoesVegas
Jul 8, 2005

The Funk Ambassador
Lipstick Apathy
Awesome... I figured out how to add a key select knob to my Auduino setup.

http://pastebin.com/WVuaGA2e

A new pot is connected to the analog 5 pin, and it cycles from C major to F major around the circle of fifths. I decided to use the circle of fifths instead of A, A#, B, C, etc because key changes will more reliably follow the circle of fifths.

All keys are oriented to a major scale, but obviously minor keys are available by selecting the relative major scale. I wanted to add augmented and diminished scales as well as a few more by adding another pot, or a switch, however adding any more key maps won't be possible due to Arduino memory limitations (I assume... when they had more than 4 octaves each I had to comment some out for it to work correctly). If someone knows a way around that issue please let me know.

I'd also like to know how the hell to change the output waveform. Right now I think its a tri wave. I don't how how the hell to do that, but then again last week I had no idea how the hell to make the thing change key, so I can hopefully figure it out.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran

I went to Radio Shack, picked up an Arduino Uno, then took a dremel to an old Dreamcast Racing wheel, uploaded some stuff from this page.

$30 rudder pedals with individual toe brakes for my flight sim. $60 if my time is worth $20/hr.

As to the other stuff, I normally program PICs and MSP430s, and most of my stuff is in assembler, so program size and memory has never, ever, ever been a problem. Debugging and time to product, however, could be faster. This Arduino stuff is kinda backwards; throw lots of code at a small problem and let the huge memory cope with the bloat, overhead, and unused stuff, and just not worry because It Works.

JesusDoesVegas
Jul 8, 2005

The Funk Ambassador
Lipstick Apathy

babyeatingpsychopath posted:

I went to Radio Shack, picked up an Arduino Uno, then took a dremel to an old Dreamcast Racing wheel, uploaded some stuff from this page.

$30 rudder pedals with individual toe brakes for my flight sim. $60 if my time is worth $20/hr.

As to the other stuff, I normally program PICs and MSP430s, and most of my stuff is in assembler, so program size and memory has never, ever, ever been a problem. Debugging and time to product, however, could be faster. This Arduino stuff is kinda backwards; throw lots of code at a small problem and let the huge memory cope with the bloat, overhead, and unused stuff, and just not worry because It Works.

First off, that's rad. I like the assassin's creed stabby-controller they made on their site. Obviously a gimmick, but still cool. I wonder how the new Leonardo unit will affect this type of use. It's got native USB compatibility instead of USB to serial like the older models had, so it can plug and play as any peripheral depending on what the program says.

Clearly you've got quite a bit more experience with coding and microcontrollers than I do... but it seems as though your statement about the arduino's huge memory conflicts with my experience in my previous post. I'll assume this is because of something I did wrong since I'm a complete novice. I found that when my code got too long it just didn't work. After commenting off large chunks (but being careful to not change any actual behavior) it worked again. This led me to believe I had a memory issue. The specific code was in the area prior to setup where I declare about 128 variables (for specific note values) and 13 maps for analog input (one for each major key, and a smooth logarithmic map for the individual grains).

The 128 variables were amended down to 60, and each scale map was cut to a 4 octave range in order to both save space and enhance playability (too many octaves made finding a specific note too difficult. I went a little overboard). It works now, but I want to add functionality for an LCD screen, and I'd like to add other scale maps (augmented and diminished) so I know I'll need to find a better solution before adding MORE code.

I could save space by getting rid of the variable declarations for each note and actually plugging in the note value in the map, but gently caress that would take forever and probably lead to me messing something up (though I'm not ruling this out if necessary). I've seen other people's code split up across multiple files (see Dr. Bleep's ATMEGA328 based Nebulophone - CODE ). I don't know why he does that but I assumed perhaps it was either to organize the sections of functionality or save space, or both.

I know this post is getting really long, but I figure I'll just get all of my questions out now... With the LCD screen I want to write the note value of the note currently playing. On a guitar or a piano its easy to tell what note you're playing, but on this thing I'm using a softpot as my play surface and the note maps change. Is there a way to write the variable NAME, not the variable VALUE to the LCD? If not the only option I can see is writing a giant 0 - 59 option case function, which I doubt is very efficient (though I could save space by nuking those 60 variable declarations).

Last question - do comments take up space at all? I know they aren't executed, but should I delete them out completely to save space, or are they just not uploaded at all?

EDIT - If what I'm trying to do won't work with one board, I also considered adding another unit, one for synthesis and one for output. I'd prefer not to go that route however as it seems sloppy, and power, cost, and real estate would be come an issue.

JesusDoesVegas fucked around with this message at 19:51 on Nov 3, 2012

Delta-Wye
Sep 29, 2005
Good questions. I'm going to jump in and answer some questions; I don't think babyeatingpsychopath would mind. Hopefully he'll chime in with some additional info as well. I'm going to cut out a bunch of chunks for brevity, but try and keep enough so you can follow along with what I'm addressing.

JesusDoesVegas posted:

It's got native USB compatibility instead of USB to serial like the older models had, so it can plug and play as any peripheral depending on what the program says.
FYI Teensys already provide this functionality. (And have for a while!) You may want to look into playing with one if you are going to do additional USB specific stuff.

JesusDoesVegas posted:

Clearly you've got quite a bit more experience with coding and microcontrollers than I do... but it seems as though your statement about the arduino's huge memory conflicts with my experience in my previous post.
The Atmega328 is an beefy microcontroller. 32KB of flash memory and 2KB of ram. As a point of comparison, I was doing a minimalist thing with a PIC12F629 - 1.75KB of flash and 128B of RAM. 128 bytes disappears pretty fast if you're not thoughtful about things.

JesusDoesVegas posted:

I found that when my code got too long it just didn't work. After commenting off large chunks (but being careful to not change any actual behavior) it worked again. This led me to believe I had a memory issue. The specific code was in the area prior to setup where I declare about 128 variables (for specific note values) and 13 maps for analog input (one for each major key, and a smooth logarithmic map for the individual grains).
Check out this page: http://www.designer2k2.at/home/arduino/49-arduino-ram-overflow.html

A halfway decent development environment should warn you that you are running out of memory resources; however, I've seen really nice packages happily compile binaries that were too big for flash and I wouldn't go as to far to call the arduino stuff "really nice". That page discusses what you may be running into, and I think there is a (relatively) easy solution.

JesusDoesVegas posted:

The 128 variables were amended down to 60, and each scale map was cut to a 4 octave range in order to both save space and enhance playability (too many octaves made finding a specific note too difficult. I went a little overboard). It works now, but I want to add functionality for an LCD screen, and I'd like to add other scale maps (augmented and diminished) so I know I'll need to find a better solution before adding MORE code.
Don't make 60 seperate variables, make an array. The array would be something like
code:
const int pitch[60] = { 
  NOTE1, 
  NOTE2, 
  etc 
};
This should store then nicely in memory, and make it easy to operate on them. You can store the current note in another number (int currentPitch) and just modify currentPitch to the current index you want. analogWrite(pitch[currentPitch]) or something to that effect. The const is important because it keeps all of these values from being copied into RAM; the pitches are never changed (is this correct?) so they don't need to go there. This would save a tremendous amount of space. The Atmega328 has a lot of flash, but RAM is a bit more limited.

JesusDoesVegas posted:

I could save space by getting rid of the variable declarations for each note and actually plugging in the note value in the map, but gently caress that would take forever and probably lead to me messing something up (though I'm not ruling this out if necessary). I've seen other people's code split up across multiple files (see Dr. Bleep's ATMEGA328 based Nebulophone - CODE ). I don't know why he does that but I assumed perhaps it was either to organize the sections of functionality or save space, or both.

I know this post is getting really long, but I figure I'll just get all of my questions out now... With the LCD screen I want to write the note value of the note currently playing. On a guitar or a piano its easy to tell what note you're playing, but on this thing I'm using a softpot as my play surface and the note maps change. Is there a way to write the variable NAME, not the variable VALUE to the LCD? If not the only option I can see is writing a giant 0 - 59 option case function, which I doubt is very efficient (though I could save space by nuking those 60 variable declarations).
I would need to look into your code a bit more, but you should be able to store all the LCD screens in a second const array, and just draw pitchLCD[currentPitch] on the LCD whenever it changes.

JesusDoesVegas posted:

Last question - do comments take up space at all? I know they aren't executed, but should I delete them out completely to save space, or are they just not uploaded at all?
The code you write is compiled into assembly, and turned into machine code. Each variable you declare (each int, float, char, etc) takes RAM, and each instruction takes flash, roughly speaking. Some C lines turn into more than one instruction depending on the hardware. Something like "var = var + 1;" is probably one instruction, other things aren't so clear (http://embeddedgurus.com/stack-overflow/2009/03/efficient-c-tips-7-fast-loops/ for example, has a discussion on how two code snippets with the same behavior take a different amount of instructions). Don't worry about the details too much yet, just be aware that comments are neither of these things, and the compiler just silently drops them.

For the love of god, don't delete them :)

JesusDoesVegas posted:

EDIT - If what I'm trying to do won't work with one board, I also considered adding another unit, one for synthesis and one for output. I'd prefer not to go that route however as it seems sloppy, and power, cost, and real estate would be come an issue.
Yup! Engineering is all about trade offs! I think you can make this work with one arduino, for what it's worth. Trying to will be very educational, at the very least. It seems like you can use some direction on what techniques would make your project work effectively; using const arrays is great if you know they even exist, but if you don't know they exist you don't know what to go look for. I wouldn't mind trying to get your project designed a bit better if you have some additional questions.

EDIT: For the record, a signed int on arduino is 2 bytes. A const array should reside in flash, and the atmega328's 32KB is enough space for over 16000 note values! Obviously, you will only be able to use a portion of this space, but you should be able to fit more than a couple octaves.

Delta-Wye fucked around with this message at 08:01 on Nov 4, 2012

Jonny 290
May 5, 2005



[ASK] me about OS/2 Warp
Our vaporizer project is moving along nicely.

My filthy trick for expanding the gnd and +5 rails for various pots and LEDs and doodads: An IDE connector off an old cable. Hard to photograph this one, sorry.



The last two pins on the far end are not connected to the bus, so that they can pass through pins 8 and 9, which we are using just for structural integrity.



Built connectors out of 2 row headers, pins on one side, wires strain-relieved through the other side. Also laced the harnesses



Yay! It works! And now poo poo doesn't short out when I wiggle it!

phospete
Jul 4, 2007
The arduino was the answer to my dreams when I first found out about them. I couldn't believe that I hadn't discovered them before then, it was exactly the kind of thing I had been hoping to toy around with.

The biggest project I've used them for was to make a device that would prime the hot water line between my master bathroom (which is on the opposite side of my house as the hot water heater) by pumping water from the hot water side to the cold water side, instead of just wasting water down the drain for two solid minutes every time I wanted to take a shower. Water's pretty expensive where I live, and if I use it long enough, it might even pay for itself.

I made two parts, a transmitter section (basically like a garage door opener) that I could press to activate the pump, and a receiver section that received the signal and controlled the pump. I used a 434 Hz transmitter together with an Arduino Pro for the transmitter, and fit it into a small box with on and off buttons.



For the receiver, I used a 434 Hz receiver with a Uno board. It connects to the pump with a PowerTail adapter. In the code, it starts the pump and runs it for either three minutes or until a thermistor that's in contact with the hot water pipe detects the temperature rise to above about 90 degrees F.







I've been using it pretty much every day for several months now, and it's been quite reliable. Probably hasn't exactly paid for itself, but that wasn't the point.

JesusDoesVegas
Jul 8, 2005

The Funk Ambassador
Lipstick Apathy
Things like that are exactly what arduino is for... Guy has a problem, guy wants to turn that problem into a project, guy fixes issue and feels accomplished every time he uses his fix.

Tell me you've done something about the hanging plugs in that last pic.

Rat Poisson
Nov 6, 2010

phospete posted:

The biggest project I've used them for was to make a device that would prime the hot water line between my master bathroom (which is on the opposite side of my house as the hot water heater) by pumping water from the hot water side to the cold water side, instead of just wasting water down the drain for two solid minutes every time I wanted to take a shower.

Is the pump forcing hot water back down the cold water supply line? How well does that work against the line pressure on the cold water line? I would have expected the pump to have a hell of a time fighting against the cold water pressure.

phospete
Jul 4, 2007

JesusDoesVegas posted:

Things like that are exactly what arduino is for... Guy has a problem, guy wants to turn that problem into a project, guy fixes issue and feels accomplished every time he uses his fix.

Tell me you've done something about the hanging plugs in that last pic.

Ya, the pump sits below the sink and it's all fed with an extension cord now so no weight on the plugs. As for the pump pressure, the hot and cold water lines are at exactly the same static pressure since they're both linked through the water heater, so the pump only has to overcome the friction loss in the cold water and hot water lines back to the hot water heater, not the entire line pressure. The pump's suction pressure is approximately the static line pressure (50 psi or whatever).

JesusDoesVegas
Jul 8, 2005

The Funk Ambassador
Lipstick Apathy
Delta-Wye is my new favorite poster. The array suggestion won't work for me since setting the variables was really just making things easier on me. Instead of writing out maps with strings of meaningless (to me) numbers, I could just write out the notes. About 15 minutes with find and replace, and some careful copy and pasting gets rid of the need to declare the variables, so I just bit the bullet and commented them out.

As an experiment I added 24 more scale maps (just repeated major scales but named them for diminished and pentatonic scales since that's what they will be in the future) and it only handles 32 total. That's 1 logarithmic chromatic scale for the grain pitch pots, 12 major, 12 diminished, and 7 pentatonic. Those last 5 won't fit.

Delta (or anyone else) do you know of a more concise way to map these scales? Essentially the Auduino assigns a pot to play the instrument (I'm using a softpot for playability). That pot's analog input is mapped to frequencies dictated by the currently selected scale. Here's example of one map:

code:
// Key of C ........C D E F G A B 
uint16_t majorC [29] = {   
    274, 308, 346, 366, 411, 461, 518, 
    549, 616, 691, 732, 822, 923, 1036, 
    1097, 1232, 1383, 1465, 1644, 1845, 2071, 
    2195, 2463, 2765, 2930, 3288, 3691, 4143, 4389
       }; 

uint16_t mapMajorC(uint16_t input) { 
  uint8_t value = (1023-input) / (1024/29); 
  return (majorC[value]); 
I didn't originally write this program, I'm just modifying it, but I think I understand what it's doing. The first uint16_t is declaring the map variable with 29 values (those brackets were actually empty in the original code), and then declaring what the values are. Next it tells the program to turn the analog signal with a 0 to 1023 range into 29 possibilities (incrementing the total number of possibilities by 1 to make the map a percentage of the full pot's range).

I don't think this can be done with an array, and I'm sure it takes up quite a bit of memory for each one. Could I somehow change the way I'm declaring these so they are stored in the relatively plentiful flash memory instead?

If it helps, right now when I compile the sketch it tells me "Binary sketch size: 5,168 bytes (of a 32,256 byte maximum)" which I'm assuming is talking about flash.

Delta-Wye
Sep 29, 2005

JesusDoesVegas posted:

Delta-Wye is my new favorite poster. The array suggestion won't work for me since setting the variables was really just making things easier on me. Instead of writing out maps with strings of meaningless (to me) numbers, I could just write out the notes. About 15 minutes with find and replace, and some careful copy and pasting gets rid of the need to declare the variables, so I just bit the bullet and commented them out.

As an experiment I added 24 more scale maps (just repeated major scales but named them for diminished and pentatonic scales since that's what they will be in the future) and it only handles 32 total. That's 1 logarithmic chromatic scale for the grain pitch pots, 12 major, 12 diminished, and 7 pentatonic. Those last 5 won't fit.

Delta (or anyone else) do you know of a more concise way to map these scales? Essentially the Auduino assigns a pot to play the instrument (I'm using a softpot for playability). That pot's analog input is mapped to frequencies dictated by the currently selected scale. Here's example of one map:

code:
// Key of C ........C D E F G A B 
uint16_t majorC [29] = {   
    274, 308, 346, 366, 411, 461, 518, 
    549, 616, 691, 732, 822, 923, 1036, 
    1097, 1232, 1383, 1465, 1644, 1845, 2071, 
    2195, 2463, 2765, 2930, 3288, 3691, 4143, 4389
       }; 

uint16_t mapMajorC(uint16_t input) { 
  uint8_t value = (1023-input) / (1024/29); 
  return (majorC[value]); 
I didn't originally write this program, I'm just modifying it, but I think I understand what it's doing. The first uint16_t is declaring the map variable with 29 values (those brackets were actually empty in the original code), and then declaring what the values are. Next it tells the program to turn the analog signal with a 0 to 1023 range into 29 possibilities (incrementing the total number of possibilities by 1 to make the map a percentage of the full pot's range).

I don't think this can be done with an array, and I'm sure it takes up quite a bit of memory for each one. Could I somehow change the way I'm declaring these so they are stored in the relatively plentiful flash memory instead?

If it helps, right now when I compile the sketch it tells me "Binary sketch size: 5,168 bytes (of a 32,256 byte maximum)" which I'm assuming is talking about flash.

You need http://arduino.cc/en/Reference/PROGMEM to do this; i did some reading and I don't think just declaring the array as a const is enough :( map() should cleanup your code a bit in reference to identifying keys; it does pretty much exactly what you're already doing but looks cleaner. Something like:
code:
majorC[map(analogRead(0), 0, 1023, 0, 28)] 
maybe? You can also switch to a two dimensional array - you have an array of scales, each scale an array of notes. It would then be something like:
code:
pitch[map(analogRead(0), 0, 1023, 0, 28)][map(analogRead(1), 0, 1023, 0, 28)] 
I would look into doing a two dimensional array if I was doing what you are.

quote:

If it helps, right now when I compile the sketch it tells me "Binary sketch size: 5,168 bytes (of a 32,256 byte maximum)" which I'm assuming is talking about flash.
EDIT: That is referring to flash usage. When the program initializes, I'm pretty sure it copies the array values from flash to RAM so they can be referenced and modified if need be; in your case it would be better to keep them in flash and just reference them there.

Delta-Wye fucked around with this message at 22:59 on Nov 5, 2012

JesusDoesVegas
Jul 8, 2005

The Funk Ambassador
Lipstick Apathy
Whelp... I wanted a project where I could dive in and get my hands dirty. Thanks for pointing me in the right direction, I'll start tinkering. Hopefully I've got this up and working before my orders from mouser and adafruit get here with the components I need to tackle the NEXT hurdle.

EDIT - typos...

EDIT AGAIN - I don't think map will work since the scales aren't linear. That is unless map can be used to focus the input to specific non linear values like I currently have. The note values are derived from the formula value = frequency(Hz) * 65536 / 31250. So the a above middle c is 440 Hz. 440 * 65536 / 31250 = 922.7, rounded up to 923.

This formula is explained by the author of the original auduino here - https://groups.google.com/d/msg/auduino/YWlt6Sd2i-8/Adeb-aHA9JkJ

Currently I'm focusing on storing something similar to my current code in flash using PROGMEM. I actually did use map for my scale selection knob to great effect.

JesusDoesVegas fucked around with this message at 23:44 on Nov 5, 2012

Adbot
ADBOT LOVES YOU

Dolemite
Jun 30, 2005
'Sup Arduino thread! As an excuse to learn C#, I ended up buying a Netduino Plus. It's nice because besides being able to debug with Visual Studio, the actual Netduino kit includes ethernet connectivity right out of the box.

I managed to make it a ghetto web server that will flash LEDs and write out to a LCD screen the IP address of the last person to navigate to the Netduino. So now that I have the ability to light things, etc - I have an idea.

I'm going to make a web-controlled trebuchet. The idea is that you'll tweet a hashtag to fire it. I'll have the Netduino use Twitter's API to check for new Tweets every so often and go from there.

Even more awesome-er: The company I work for is actually encouraging me to do this! As in, they'll reimburse me for the trebuchet kit AND I get to do this on company time! :D

Before the Netduino, I actually started with a kit from Nerdkits.com. This thing was even more barebones than an Arduino. You had to manipulate individual registers, set bits on/off, etc. in straight C. The Netduino is far easier to work with. Although it carries less 'street cred'.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply