JesusDoesVegas posted:
I think you want code:
code:
|
|
# ? Nov 24, 2012 05:19 |
|
|
# ? May 15, 2024 03:10 |
|
Time to ask some dumb questions! What exactly is a ground? I've taken elements of electrical engineering for my mechanical engineering major and we did some circuit stuff but I feel the explanation of what a ground is was completely off. I thought all circuits had to be in a loop but supposedly thee ground can sometimes serve as a completion of the loop? I set up some code so that 11, 12, and 13, from the Arduino would power three separate LEDs. One of them was much brighter than the other two. I tried moving the LEDs to different spots on the breadboard, changed the LEDs, and changed the Arduino to 10, 11, and 12 and still got the same thing. Thoughts? How do you go about picking a resistor? Like in the case of 330Ω vs 10kΩ? My kit came with those two values.
|
# ? Nov 24, 2012 06:09 |
|
Delta-Wye posted:
Theoretically "if(thing1== 1 || thing == 2)" is correct, assuming you have only one statement coming after it, that is "if(thing1== 1 || thing == 2) digitalWrite(13,1);" It is just bad practice. huhu posted:Time to ask some dumb questions! - Ground on AC or DC circuits have different meanings, so I will leave that alone as I don't want you to explode, I'm no expert on that. - You probably have the Arduino powered by USB, which is relatively low power, try connecting to a 9-12VDC wall wart. - Ohm's law. V=I*R where I = current, R = Resistance, and V is the voltage. So for the case of an LED you'd use (Source Volts - LED Volts) / (Current / 1000) = Resistance Building on that last point about resistors, you might find you get some weird values, if you feel lazy just pick the easiest one to purchase that is closest to your value, if you get 350 ohms, feel free to use a 330, because you can actually find them; or put them in series. UberVexer fucked around with this message at 06:55 on Nov 24, 2012 |
# ? Nov 24, 2012 06:47 |
UberVexer posted:Theoretically code:
UberVexer posted:- Ground on AC or DC circuits have different meanings, so I will leave that alone as I don't want you to explode, I'm no expert on that. a. Call the - terminal ground, the + becomes 9V. Conversely, if you call the + terminal ground, the - terminal becomes -9V. The 9V is relative between the two terminals, not absolute unless you pick an arbitrary zero point (ground). b. Connect - to +, if we call the leftmost + terminal ground, it's - terminal becomes -9V. The + on the other battery is connected so it is the same (-9V) and the - terminal is 9 volts lower (-18V). c. Here the middle terminal is ground (0V) so one battery's exposed terminal is 9V and the other is -9V. This configuration is common with things like audio, where you need a bipolar supply. d. Here the rightmost - terminal is called ground. One battery up is 9V, and one more battery up is 18V. Keep in mind a-d has different voltage levels, but the same circuit. The voltages contained are all relatively the same, but by changing what we call ground (0V) we change their absolute measurements. e-g are parallel connections. In this case, you either get 9V or -9V out depending on what you call ground. if a-d is the same, why do audio guys usually go with -9V and 9V, where something like an RC car (or power tool with a battery pack) is going to call it 18V? Audio guys need a bipolar swing for the audio signal, and calling ground 0V is mathematically convenient and means 0 signal is in the middle and conveniently halfway between the extremes. Something like an RC car is running 18V directly to the motors and calling +18V-0V for doing those calculations mathematically convenient. The 'ground' in your house is a safety precaution and not the reference, the neutral wire is the reference point. They are usually connected together at the breaker box... blah... GFCI circuits... Long explanation for 'why is this ground and not this' but I hope it was slightly enlightening. UberVexer posted:- You probably have the Arduino powered by USB, which is relatively low power, try connecting to a 9-12VDC wall wart. http://softsolder.com/2012/11/01/arduino-digital-output-drive-vs-direct-connected-leds/ It may work, but slight manufacturing differences between LEDs and pins will be accentuated. Using a current limiting resistor will help moderate any manufacturing differences. UberVexer posted:- Ohm's law. V=I*R where I = current, R = Resistance, and V is the voltage. So for the case of an LED you'd use UberVexer posted:Building on that last point about resistors, you might find you get some weird values, if you feel lazy just pick the easiest one to purchase that is closest to your value, if you get 350 ohms, feel free to use a 330, because you can actually find them; or put them in series. http://mightyohm.com/blog/2009/01/eia-resistor-values-explained/ Delta-Wye fucked around with this message at 07:52 on Nov 24, 2012 |
|
# ? Nov 24, 2012 07:48 |
|
Ya, if you look at my code I used ==... I just typoed here. Would a switch be faster?
|
# ? Nov 24, 2012 16:20 |
|
JesusDoesVegas posted:Ya, if you look at my code I used ==... I just typoed here. It depends on how many comparisons you have and how good your compiler is. If you have something that you're testing, and only one case can ever be true, you could write: code:
If you write code:
If you wrote code:
This is getting into the programming in c of the device more than you probably like, but "small" devices like microcontrollers need a different way of looking at things; they don't have gobs of memory or fast cores, so you, as a programmer, have to know EXACTLY how your code is going to get compiled if you want good performance. babyeatingpsychopath fucked around with this message at 23:10 on Nov 24, 2012 |
# ? Nov 24, 2012 23:07 |
|
Delta-Wye covered the ground concept pretty well but I want to add, An ideal ground is a constant unchanging voltage that can absorb as much current as you throw at it. Conversely, if you are using a bipolar signal (the +9V and -9V with ground at 0V example) it should also be able to provide current. In practice, grounds are not ideal and putting lots of power or fast signals can cause them to shift around, but it shouldn't be something that comes up in most Arduino projects. Also, if you are working with add on boards for your Arduino and you are using the ground for a reference, say driving hobby servos, you will probably need to connect the ground on the Arduino to the ground on the add on board to make sure they have the same voltage. Since signals are commonly referenced against ground, having your grounds not be the exact same can cause problems like oddly performing PWMs, servos that won't sit still, or burnt components.
|
# ? Nov 25, 2012 18:56 |
It bears pointing out one other potential bonus for using switch statements that if() statements don't do as well, and many people forget: you don't have to use a break after each switch case. If you don't, it'll keep executing the other options until the switch is over or a break is hit. For example:code:
Bad Munki fucked around with this message at 19:21 on Nov 26, 2012 |
|
# ? Nov 26, 2012 19:13 |
babyeatingpsychopath posted:This is getting into the programming in c of the device more than you probably like, but "small" devices like microcontrollers need a different way of looking at things; they don't have gobs of memory or fast cores, so you, as a programmer, have to know EXACTLY how your code is going to get compiled if you want good performance. I would argue this isn't the case for the Arduino platform at all. It has a relatively beefy processor and is sort of setup so the dev doesn't need to know what is happening under the hood. What the hell happens when you do an analogwrite? A print? Why does setting up a servo disable some of the PWM ports? Who knows, who cares?! It just works. JesusDoesVegas posted:Ya, if you look at my code I used ==... I just typoed here. Mostly just taking the piss out of you. Keep an eye out for those typos though as they are easy to do and compile fine; you just get unexpected behavior. It can be a pain to figure out, especially on an embedded platform because it even looks right if you just glance at the code. I've taught a few semesters of introductory programming and its an extremely common mistake. I kind of wish gcc's -Wall option would toss warnings for assignments done in comparison blocks, if for no other reason than to make TAing easier JesusDoesVegas posted:Would a switch be faster? Maybe? Probably not? At this point you should be concerned with readability and maintainability over all. I doubt your project is pushing the '328 to the point a few cycles here and there matter that much. Bad Munki posted:It bears pointing out one other potential bonus for using switch statements that if() statements don't do as well, and many people forget: you don't have to use a break after each switch case. If you don't, it'll keep executing the other options until the switch is over or a break is hit. Delta-Wye fucked around with this message at 20:25 on Nov 26, 2012 |
|
# ? Nov 26, 2012 20:22 |
Delta-Wye posted:Hey buddy, my example had fall through Sure, but I wanted it to be obvious what the potential really is there, instead of just an alternative for "if(a || b)".
|
|
# ? Nov 26, 2012 20:31 |
|
I'm using an ATtiny84 chip to run my PWM since I just don't feel like figuring out the timer issues I ran into earlier. The datasheet (http://www.atmel.com/Images/8006s.pdf) says the operating voltage is 2.7v to 5.5v. What is best practice with these ranges? Should I try to shoot for middle ground, say around 4v or would I be safe just giving it the same 5v I'm giving my Arduino?
|
# ? Nov 27, 2012 02:10 |
JesusDoesVegas posted:I'm using an ATtiny84 chip to run my PWM since I just don't feel like figuring out the timer issues I ran into earlier. The datasheet Give it the same 5v as your arduino is using. Typically there is a graph in the datasheet with safe operating clock ranges for the various speeds - I haven't looked at that particular device, but often the max clock rate is only available at higher VCC voltages (5V should be enough for max clock). Again, typically, you are more power efficient at lower clock rates and lower voltages although it takes a bit more time to get things done. Finding the sweet spot depends a lot on your workload, low power modes, etc, and isn't something you need to be worried about in your project which is probably USB or wall powered anyways.
|
|
# ? Nov 27, 2012 02:27 |
|
Bad Munki posted:It bears pointing out one other potential bonus for using switch statements that if() statements don't do as well, and many people forget: you don't have to use a break after each switch case. If you don't, it'll keep executing the other options until the switch is over or a break is hit. code:
|
# ? Nov 28, 2012 00:19 |
makomk posted:Otherwise it's very easy not to notice that there isn't a break - especially if only one or two cases from a complex switch statement don't have them - and even if you do, will you be able to remember whether it was intentional a few months down the line if you come back to the project? Trust me, Future-You will thank you for it. code:
(I have no idea if that would actually "work", might depend on the compiler. Mine didn't complain about the #define itself, anyhow.) Bad Munki fucked around with this message at 00:41 on Nov 28, 2012 |
|
# ? Nov 28, 2012 00:37 |
huhu posted:Time to ask some dumb questions! Your post made me think of this article: http://spritesmods.com/?art=minimalism Interesting read.
|
|
# ? Nov 28, 2012 01:28 |
|
I'm on the fence about buying a complete arduino kit for a project I have, basically I want to do a digital gauge cluster for my bike, the problem is that except the speedo, every sensor is resistance based, so is an arduino able to measure resistance or do I have to apply tension to the sensors and measure voltage changes ? Also I would need a bunch of relays, are the arduino outputs able to drive relays ? Another problem is that LCD screens seems to use a lot of out pins is there a way to have an LCD screen and still have about 10 outputs availlable ? Thanks
|
# ? Dec 13, 2012 20:10 |
Sh4 posted:I'm on the fence about buying a complete arduino kit for a project I have, basically I want to do a digital gauge cluster for my bike, the problem is that except the speedo, every sensor is resistance based, so is an arduino able to measure resistance or do I have to apply tension to the sensors and measure voltage changes ? http://web.cecs.pdx.edu/~eas199/B/howto/thermistorArduino/thermistorArduino.pdf Some of the information will need some tweaking, such as your fixed resistor and your voltage->resistance->measured quantity calculations, but using an ADC and a resistor divider is a pretty easy way to measure resistance. Sh4 posted:Also I would need a bunch of relays, are the arduino outputs able to drive relays ? Sh4 posted:Another problem is that LCD screens seems to use a lot of out pins is there a way to have an LCD screen and still have about 10 outputs availlable ? What LCD screens are you looking at? There are lots of options for outputs and some of them (SPI interfaces, serial backpacks, etc) don't take that many I/O pins to drive.
|
|
# ? Dec 13, 2012 20:31 |
|
Delta-Wye posted:What LCD screens are you looking at? There are lots of options for outputs and some of them (SPI interfaces, serial backpacks, etc) don't take that many I/O pins to drive. This is one of the options I use to reduce the LCD pin requirements to ONE. That's right - one pin to drive the LCD (through SoftwareSerial.h), and it lets you do PWM on the backlight as well. I bought 7 or 8 of these 'cos I use them with pretty much all of my 16x2 character LCDs. Anyway: https://www.sparkfun.com/products/258 - it's stupidly simple to use these, and have minimal overhead with many of the things I work on, 'cos I'm already doing SoftwareSerial for other things. Word of warning - there are OLED versions of the 16x2 displays (Adafruit carries 'em). The OLEDs are only mostly HD44780 compatible, and won't work with the SerLCD backpack (or even the Adafruit i2c/SPI backpack).
|
# ? Dec 13, 2012 20:41 |
rustybikes posted:This is one of the options I use to reduce the LCD pin requirements to ONE. That's right - one pin to drive the LCD (through SoftwareSerial.h), and it lets you do PWM on the backlight as well. I bought 7 or 8 of these 'cos I use them with pretty much all of my 16x2 character LCDs. Anyway: https://www.sparkfun.com/products/258 - it's stupidly simple to use these, and have minimal overhead with many of the things I work on, 'cos I'm already doing SoftwareSerial for other things. You're looking at character displays; I'm hoping for a slick OLED graphical display
|
|
# ? Dec 13, 2012 20:59 |
|
Sh4 posted:Also I would need a bunch of relays, are the arduino outputs able to drive relays ? Not directly. Mechanical relays have two problems for the arduino: They draw more power than the pin can deliver, and they can send back a jolt of current when they switch. This is bad, as either of those things can hurt the pin, or even the whole processor. So, you build a circuit that uses the arduino's pin to switch a transistor, which then draws current from the 5V rail (capable of more amps than the arduino's pin). And a diode prevents that charge from hurting anything. See the schematic on this page for a description of a circuit for this. What do you need the relay for, exactly? I'm not questioning your decision, I'm just curious. Are they components from a car that need a 12V battery?
|
# ? Dec 14, 2012 03:26 |
|
My creation! It lives! This jumbled mass of ugly wires is the synthesizer I've been working on. I plugged everything in and it all worked on the first try... Not sure how that happened. The LCD display changes colors at a seizure inducing rate, and displays the current note, and the selected scale and key. Every god damned thing that lights up on this thing changes colors. Seizures are fun. I used LEDs from Sparkfun that change color on their own... I found them as I was ordering my final components and I figured I may as well get ridiculous with it. As I've stated before, I prototyped this bad boy on my Uno, but I ended up on a Pro Mini 5v. It's super tiny, and has 8 analog inputs. The LCD backlight PWM is controlled by the offboard ATTINY84 chip on bottom. It worked really well, it was super cheap, and it circumvented the annoying timer issues I encountered with PWM and the interrupt routine. Off board Space Baby Echo by Wooster Audio. This thing module is what inspired me to start this project. Next phase is figuring out how to model a case. I'm going to have it printed at Shapeways.com. I'll mave the case done in ABS, and the face in full color sandstone. The design I've come up with should work really well. I'll post video at some point. JesusDoesVegas fucked around with this message at 09:00 on Dec 14, 2012 |
# ? Dec 14, 2012 08:55 |
JesusDoesVegas posted:Next phase is figuring out how to model a case. I'm going to have it printed at Shapeways.com. I'll mave the case done in ABS, and the face in full color sandstone. The design I've come up with should work really well. I'll post video at some point. Please do! I'd love to hear it/see it in action.
|
|
# ? Dec 14, 2012 11:19 |
|
Delta-Wye posted:You're looking at character displays; I'm hoping for a slick OLED graphical display Fair enough. Adafruit has a few OLED graphic displays. Just guessing, but I'd think either of these would be close to what you're looking for: http://www.adafruit.com/products/938 http://www.adafruit.com/products/326 These both use SPI, and the 938 one can do i2c as well. I have the 326 one, and it is absolutely gorgeous. I've the older, non-5V-ready ones, so I have to use an external level-shifter, but as far as the Ardu is concerned, it's just another SPI device. It's not OLED, but the ST7565 LCDs are another possible option. Again, from Adafruit: http://www.adafruit.com/products/438 This is an RGB backlit LCD with the same resolution as the OLEDs, but the display itself is much bigger. It's not SPI, but still only uses 5 pins.
|
# ? Dec 14, 2012 15:23 |
|
https://www.youtube.com/watch?v=AMo98ELDdVc&feature=youtube_gdata_player Here's a poo poo video I made while I was messing with it tonight. The lighting, sound, and playing are all awful, but it gives an idea of what I've created here.
|
# ? Dec 15, 2012 02:27 |
|
Its been a very arduino Christmas for me apparently: Two Unos, two different starter kits, a 4 relay module, and Programming Arduino and Projects for Evil Geniuses, both by Simon Monk. They're my first crack at this sort of thing, I guess its time to start learning
|
# ? Dec 25, 2012 16:28 |
|
Combo posted:Its been a very arduino Christmas for me apparently: Post back when you've created two uno driven kill bots bent on total huan annihilation. I expect nothing less.
|
# ? Dec 25, 2012 17:50 |
|
JesusDoesVegas posted:Post back when you've created two uno driven kill bots bent on total huan annihilation. I expect nothing less. The huan's are a peaceful race, they have done nothing to deserve this
|
# ? Dec 26, 2012 17:24 |
|
I got a Christmas present from Kickstarter. My Digisparks showed up Monday. A full review will follow. So far.. I've run into two things. First, the documentation isn't immediately obvious, and you need a custom version of the IDE. But... that only set me back half an hour. Gunktacular posted:Haha! Damned straight I'm jealous.
|
# ? Dec 26, 2012 17:40 |
|
Nerobro posted:
Finally got to test it out actually, works great on the calibration point. Came with two x10 probes and schematics for all the internal boards and components.
|
# ? Dec 26, 2012 20:56 |
|
Combo posted:Its been a very arduino Christmas for me apparently: Speaking of this, what starter kits do people recommend? I'm a novice who just wants to try it out and see how I like it/if I have the patience to stick with it. I came across this thing which looks pretty neat, although maybe a bit limiting. The Sparkfun Inventor's Kit also looked good, as did their Starter Kit. The Fritzing Kit also looks pretty nice.
|
# ? Dec 28, 2012 11:04 |
|
Pompous Rhombus posted:Speaking of this, what starter kits do people recommend? I'm a novice who just wants to try it out and see how I like it/if I have the patience to stick with it.
|
# ? Dec 28, 2012 16:21 |
|
Yeah, all of those listed sets are really similar to what I got. Just a small breadboard, bunch of wires, a couple of small servos, assorted LEDs, resistors, capacitors, a buzzer, 9V battery plug, etc. I also happen to still have my starter kit from my EET 101 class which has similar things plus a larger breadboard.
|
# ? Dec 28, 2012 18:30 |
|
I got the kit from Make when I started: http://www.makershed.com/Getting_Started_with_Arduino_Kit_V3_0_p/msgsa.htm I also got the book. It has a breadboard, a bunch of resisters, photo resisters, buttons, LEDs, and a fuckton of jumpers. I feel like a variety of capacitors and pots would have been handy too, but a few trips to radioshack and a few orders from mouser stocked me up pretty well. Since components are pretty drat cheap, what I've done is just ordered more than I need when buying from mouser if the component seems fairly common. It helps when you're in the middle of figuring something out and you realize you need a component. You can also strip old electronics for parts. I use the speaker out of an old alarm clock for breadboarding. I also kept its 7 segment display and its time keeping IC, but I've yet to use them.
|
# ? Dec 28, 2012 22:55 |
|
My wife got me this one for my birthday at the beginning of December: http://www.makershed.com/Ultimate_Microcontroller_Pack_p/msump.htm I've done a few of the intro guides, but haven't really had the time to get too far into it due to work and the holidays. She also got me this kit for Christmas, which has a lot of other assorted parts that will work nicely with the Arduino: http://www.thinkgeek.com/product/b80b/?srp=1
|
# ? Dec 28, 2012 23:17 |
|
Is anyone fuxoring around with XBees? I've got a usb xbee explorer to setup the Xbees but I've only detected them once. On any computer I try I get a message telling me to push the reset button on the Xbee (there isn't one on it or the usb board). I can jump rst and ground to reset, but I'm still not able to write to the Xbee. I'm using a fully updated X-CTU, and everything seems to be right. What are the odds that there's something wrong with the usb adapter board?
|
# ? Dec 29, 2012 05:13 |
|
Nerobro posted:I got a Christmas present from Kickstarter. My Digisparks showed up Monday. A full review will follow. So far.. I've run into two things. First, the documentation isn't immediately obvious, and you need a custom version of the IDE. But... that only set me back half an hour. Mine arrived on tuesday, I pulled out my parts bin and found I have jack all in the way of useful components (plenty of resistors, capacitors, transistors and unlabelled LEDs of various colours and sizes, but no solid core wire to hook up any of it). I've so far only bothered modifying the USB2LCD example to autoscroll (ie, move a complete line from the bottom to the top row and start writing on the bottom line) and haven't yet got a daemon running on my pc to send data to it. Eventually I think I'll try make it run standalone with an ethernet module and basic http stack so it can pull data from twitter and display tweets, since that's what all the cool kids seem to do. It'll be interesting to see if I can get that to fit on a digispark solo or if I need to use the eeprom module.
|
# ? Jan 24, 2013 03:41 |
|
So I made this code so that you could enter a value into serial monitor and have it turn that number of steps on a stepper motor. I added the line of code:
code:
|
# ? Jan 24, 2013 17:00 |
quote:Because I couldn't control the steps and say that 0 would turn it 48, 1 would turn it 49, etc. It appears you are sending characters, not numbers. ASCII '0' is decimal 48. http://www.asciitable.com/
|
|
# ? Jan 24, 2013 18:52 |
|
huhu posted:So I made this code so that you could enter a value into serial monitor and have it turn that number of steps on a stepper motor. I added the line of A couple of problems: Serial.read() only reads one byte at a time before returning. It also doesn't parse it as characters or an int, but reads it as a raw byte. So in your loop it's reading the first byte received, trying to use it as a value, then reading the next byte, trying to use it as a value, etc, rather than interpreting the bytes as a single integer. You probably want to be using Serial.parseInt(), which will pull characters off the serial stream until it gets a non-integer character, and then turn them into an int value to return. If you do this, be sure to turn on newline in your serial program on your PC, and/or use Serial.setTimeout() to reduce the serial read timeout, or else you will get long pauses if you enter an int value with no trailing non-int characters. This is because it reads until it gets a non-integer character, and doesn't know that you have finished sending the number you want until it either gets a non-int value or times out (I think by default it's a full second). huhu posted:It's fine now except 10=0, 11=1, 12=2, etc. What is affecting these values? As Delta-Wye said, it's because Serial.read() is interpreting the byte value instead of the ASCII value. For something like "10 11 12" it should be spitting out "49 48 49 49 49 50". nightchild12 fucked around with this message at 19:31 on Jan 24, 2013 |
# ? Jan 24, 2013 19:22 |
|
|
# ? May 15, 2024 03:10 |
|
Success! First program I've made with a purpose. Going to be used for work to replace a $200 setup currently being used.
|
# ? Jan 24, 2013 19:33 |