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
Bad Munki
Nov 4, 2008

We're all mad here.


huhu posted:

Decided what better way to spent Saturday night then to get out the Arduino. :science: Made a dimmer that goes through the full range of the RGB colors. Was rather confusing to setup because I used PWM pins as grounds so all the values were inverted so that 0 was high and 255 was low. Any suggestions for another way to do this?

Use the pwm pins to control transistors. Or if you're only driving a couple LEDs, put the pwm pin on the LEDs anode...depends on if your rgb led is common-anode or common-cathode, of course...I can never remember which is more common.


And if you want to smooth the brightness "spikes" where you have two of the internal LEDs on simultaneously, build your color vector in HSV space (just give it max S and V with the H being the only variable, directly controlled by your knob) and then convert to RGB, makes for really nice smooth transitions around the color wheel. :)

Bad Munki fucked around with this message at 17:37 on Feb 10, 2013

Adbot
ADBOT LOVES YOU

evensevenone
May 12, 2001
Glass is a solid.

huhu posted:

Was rather confusing to setup because I used PWM pins as grounds so all the values were inverted so that 0 was high and 255 was low.

This is the normal way to do it because most micros can sink more current than they can source, but actually the atmega328 is rated for the same current as a source or a sink.

If you need more current (I think the limit is 40ma per pin, 200ma total) then a transistor is definitely the answer.

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

huhu posted:

Decided what better way to spent Saturday night then to get out the Arduino. :science: Made a dimmer that goes through the full range of the RGB colors. Was rather confusing to setup because I used PWM pins as grounds so all the values were inverted so that 0 was high and 255 was low. Any suggestions for another way to do this?

View My Video

Just do any brightness calculations treating 0 as dark and 255 a light if it makes more sense that way. Then just set PWM to 255-brightness

TVarmy
Sep 11, 2011

like food and water, my posting has no intrinsic value

huhu posted:

Decided what better way to spent Saturday night then to get out the Arduino. :science: Made a dimmer that goes through the full range of the RGB colors. Was rather confusing to setup because I used PWM pins as grounds so all the values were inverted so that 0 was high and 255 was low. Any suggestions for another way to do this?

View My Video

You could do 255 - value you'd use if it were 255 = high, I think.

This could be a total brain fart, though. I'm a write and test, then check kind of coder.

rustybikes
Mar 12, 2004

TVarmy posted:

Am I the only person who doesn't like using shields? I'd rather just use discrete components so that if I want to keep the project, I can solder everything to a perfboard and use a bare Atmega to control everything.

You're not the only one. I use Arduinos with shields to prototype a thing, and when I'm happy with it, break out a naked 328 to reproduce it. The only exception I've encountered is with a specialised shield, like the CAN-BUS one that Sparkfun's got.

Acid Reflux
Oct 18, 2004

For lack of anything better to do on a cold, snowy Sunday, I built an LED cube based on this Instructable. Of course I didn't have a single usable scrap of perfboard left in the house, but I *did* have a Seeed ProtoShield kit. Adapt and overcome! To my delight (and somewhat to my surprise) it worked on the first try.



And a dark grainy video, just in case you've never seen one of the other five trillion dark grainy LED cube videos: http://youtu.be/-Sh972dMumY

porktree
Mar 23, 2002

You just fucked with the wrong Mexican.
Ha, great minds think alike... Although you did more fancy soldering.

Goon Matchmaker
Oct 23, 2003

I play too much EVE-Online
Is there any way to tell if I've horked the boot loader on my rainbowduino? I was messing with it earlier today, uploading various sketches to see what they did, and now my computer no longer recognizes it as a USB-Serial device. As far as I know I didn't tell the IDE to flash the boot loader. Do these things get messed up randomly or something?

huhu
Feb 24, 2006

Goon Matchmaker posted:

Is there any way to tell if I've horked the boot loader on my rainbowduino? I was messing with it earlier today, uploading various sketches to see what they did, and now my computer no longer recognizes it as a USB-Serial device. As far as I know I didn't tell the IDE to flash the boot loader. Do these things get messed up randomly or something?

Following along with this question. If you do something like plug in a 9V battery into a battery clip and then let the wires accidentally fall onto the board and create a current could that cause the Arduino to fail? Also, could using a center positive, 12V/1A output wall wart into the Arduino cause it to fail? Somehow I believe I hosed my board up and those are the two things I think might have caused it to fail.

TVarmy
Sep 11, 2011

like food and water, my posting has no intrinsic value

huhu posted:

Following along with this question. If you do something like plug in a 9V battery into a battery clip and then let the wires accidentally fall onto the board and create a current could that cause the Arduino to fail? Also, could using a center positive, 12V/1A output wall wart into the Arduino cause it to fail? Somehow I believe I hosed my board up and those are the two things I think might have caused it to fail.

A reverse power supply is not such a big deal, as there is a diode to stop current from flowing backwards.

The 9V battery could be problematic, though.

If you have a DIP (dual inline pin) socket Arduino with a chip inside a socket, like this:



You can replace the ATMega328 chip with one that comes with the arduino bootloader, or burn the bootloader on a bare one using another Arduino or AVR programmer. Adafruit and Sparkfun sell the ATMega 328s pre-programmed. They're actually quite cheap, as the ATMegas are mass-produced for commercial purposes, and can be bought from sites like Digikey for about $4. This is part of why Arduinos replaced hobbyist microcontrollers like the BASICStamp so handily, because aside from being about 1/4 the cost for the whole board, the "brains" of the board could be replaced cheaply and easily. This meant hobbyists could experiment and do things outside their comfort zone, as if they killed the chip, say by doing something that overloads an IO pin with too much current like driving a motor, they would only be out $6 instead of $130 (The price BASIC Stamps were when I took a robotics class in high school).

When replacing the chip, or taking it out for whatever reason, carefully pry it out gently, alternating sides. I like to use an eyeglasses screwdriver. The pins bend really easily if you aren't careful.

However, if your Arduino looks like this (unlikely, these were only sold for a short period at the same price as the other Arduino solely due to a brief chip shortage, and it was a while ago now):



Your chip is soldered on very finely to the board using a smaller package than what is typically used on this generation of arduinos (SMD). As the chip is surface mount, it's not possible to replace without good solder skills and a quality solder station. If I saw this type for sale, I'd avoid it. I've never burnt out an ATMega, but I don't want to be out $30 if it does happen.

I'm assuming you have an Arduino Uno. I think the Arduino Mega is only SMD, and the Arduino Leo and Due come in chips that don't come in DIP, IIRC.

TVarmy fucked around with this message at 02:13 on Feb 16, 2013

huhu
Feb 24, 2006
Thanks for the reply I'll look into it in a bit.

In the meantime, all your 3x3x3 cubes are poo poo. :smug:
Edit: So I thought a 8x8x8 cube was pretty :aaaaa:, here is a 16x16x16 cube... why?
https://www.youtube.com/watch?v=Aj3_v7xCyJ0



Thanks for the advise. I tried taking the chip out of my new board and putting it into the old one and it didn't recognize it. I placed it back in to the new board and it was recognized. Is there something else special I need to do to get it to work? Could the boards be different? They're both Arduino UNO I'm not sure what other things could distinguish them though.


New one is on the left broken one is on the right.

Edit: Just plugged the "broken" chip into the new Arduino and it works, so it's not that.

huhu fucked around with this message at 04:19 on Feb 16, 2013

TastyShrimpPlatter
Dec 18, 2006

It's me, I'm the
I just picked up my first Arduino (Uno R3) today, only to find out that the chip is either borked, or the firmware needs to be re-installed. Whenever I plug it in via USB, Windows only sees "ATmega16u2 DFU" under Other Devices. I was able to manually install the correct driver, but I get "This device cannot start. (Code 10)" in the properties. Also, the L led blinks a couple times, and then stays lit. Not sure exactly what the problem is. Any ideas?

Acid Reflux
Oct 18, 2004

huhu posted:


Edit: So I thought a 8x8x8 cube was pretty :aaaaa:, here is a 16x16x16 cube... why?
https://www.youtube.com/watch?v=Aj3_v7xCyJ0

Christ, I was ready to stab my eyes out with the hot soldering iron after doing a 3x3x3. And I *like* to make things. That's just absurd.

I need one.


On the subject of swapping chips and burning bootloaders and such...since I'll always be more of a hardware than software guy, I ordered all the requisite materials to make a few standalone boards. So far I'm having zero luck programming with the FTDI adapter I picked up, but using these instructions I managed to prep 5 new breadboarded 328s with a bootloader and the "blink" sketch. Now I'm just looking for a nice compact layout to build them on. I have all the stuff on hand to etch my own boards, so I might give both the DIY Arduino and the Nanino a shot.

Oh, and if anyone's been looking at the cheap Chinese clone boards on eBay, I can attest to the fact that at least the Mega2560 seems to work fine. Getting into this right at tax refund time was a very, very bad idea. :D

Acid Reflux
Oct 18, 2004

Later that day...




Didn't turn out half bad, considering that's the first board I've etched in almost 20 years. My $5 yard sale laser printer performed quite admirably. I used 2 parts hydrogen peroxide/1 part muriatic acid as the etchant, already had the stuff on hand from trying out some aluminum etching last fall.

It works like a champ and is spaced correctly for shields, although the electrolytic cap stands a bit proud of the headers. I also figured out my problem with the FTDI adapter - my breadboard circuit (and this board, initially) didn't have a .1uF cap between the 328's reset pin and the DTR pin on the programming header. Apparently that's required for the board to auto-reset itself for programming, otherwise you have to manually mash the reset button at the right time to start the serial communication. You can see where I tucked the cap on the bottom of the board. Ugly but effective. Now I just need to remember where my package of little stick-on rubber feet is...

Zuph
Jul 24, 2003
Zupht0r 6000 Turbo Type-R
Yeah, I had trouble reversing the image for the Nanino in a way that preserved sizing, so I just redrew the thing in a CAD tool, adding the auto-reset cap. http://www.meatandnetworking.com/projects/nanino-upgrade/

Tossing it into a real CAD tool has the added benefit of being able to modify it a lot more easily!

Acid Reflux
Oct 18, 2004

That's fantastic, Zuph, thanks! I'm going to be making a few more of these for myself and a couple of friends, and your layout is exactly what I would have done if I had any idea how to use PCB/CAD software. :)

DisgruntledPostMan
May 20, 2007
Wuzzat
http://www.digilentinc.com/Products/Catalog.cfm?NavPath=2,892&Cat=18

I recommend getting an uno32 if you're thinking of getting an arduino. They come with the arduino bootloader preloaded and are pin compatible with all arduino shields but allow you the opportunity to code it in straight C with a pickit if you feel like you've outgrown the hand-holdy bootloader.

Zuph
Jul 24, 2003
Zupht0r 6000 Turbo Type-R

DisgruntledPostMan posted:

http://www.digilentinc.com/Products/Catalog.cfm?NavPath=2,892&Cat=18

I recommend getting an uno32 if you're thinking of getting an arduino. They come with the arduino bootloader preloaded and are pin compatible with all arduino shields but allow you the opportunity to code it in straight C with a pickit if you feel like you've outgrown the hand-holdy bootloader.

I'm not going to knock the uno32, since it's a way more powerful chip than the AtMega used on the Arduino, but there is absolutely no reason whatsoever that you can't program an Arduino is straight C.

Acid Reflux posted:

That's fantastic, Zuph, thanks! I'm going to be making a few more of these for myself and a couple of friends, and your layout is exactly what I would have done if I had any idea how to use PCB/CAD software. :)

I'm glad it helps out!

Captain Capacitor
Jan 21, 2008

The code you say?
Atmel is pretty awesome on their free sample shipping. I got a serial EPROM and two AT90USBs in under a day. Now I just need to buy a 64 pin QFN adapter/breakout board and learn how to solder SMDs :ohdear:

Goon Matchmaker
Oct 23, 2003

I play too much EVE-Online
Well. I completed my seeedstudio cube kit today. Probably shouldn't have picked that as a learning project because I managed to mangle it. So far I have assembled one of the layers upside down, burnt the pads on quite a few of the connection points, melted a pcb to the point where a trace came flying out. However it does light up. Well part of it. Looks like I'm going to have to spend another $60 if I want a working cube though. I don't think I can patch this one together.

I'm pretty happy though. This is the first time I've ever built anything beyond just soldering two wires together. Being able to build something and then have it come to life is a great feeling. I like being able to touch what I make.

I think my next project will be a 12V PWM fan controller for my computer. My mobo already has one but I hate it with a passion and I have a pretty good idea how I want an arduino to do the task without requiring any software to make it work.

ANIME AKBAR
Jan 25, 2007

afu~

huhu posted:

Thanks for the reply I'll look into it in a bit.

In the meantime, all your 3x3x3 cubes are poo poo. :smug:
Edit: So I thought a 8x8x8 cube was pretty :aaaaa:, here is a 16x16x16 cube... why?
https://www.youtube.com/watch?v=Aj3_v7xCyJ0

http://www.seekway.com.cn/e/3D/ledsys28.htm

I think they're up to 64x32x32, fully tricolor.

I wonder how many arduinos they use??

ANIME AKBAR fucked around with this message at 04:30 on Feb 20, 2013

TVarmy
Sep 11, 2011

like food and water, my posting has no intrinsic value

ANIME AKBAR posted:

http://www.seekway.com.cn/e/3D/ledsys28.htm

I think they're up to 64x32x32, fully tricolor.

I wonder how many arduinos they use??

It says something about an "sd card controller," but I'm guessing you could probably manage a decent refresh rate still with a ton of cascading shift registers and one arduino and a bunch of jumper wires, assuming you splice out the "SD card controller."

Captain Capacitor
Jan 21, 2008

The code you say?

Goon Matchmaker posted:

Well. I completed my seeedstudio cube kit today. Probably shouldn't have picked that as a learning project because I managed to mangle it. So far I have assembled one of the layers upside down, burnt the pads on quite a few of the connection points, melted a pcb to the point where a trace came flying out. However it does light up. Well part of it. Looks like I'm going to have to spend another $60 if I want a working cube though. I don't think I can patch this one together.

I'm pretty happy though. This is the first time I've ever built anything beyond just soldering two wires together. Being able to build something and then have it come to life is a great feeling. I like being able to touch what I make.

I think my next project will be a 12V PWM fan controller for my computer. My mobo already has one but I hate it with a passion and I have a pretty good idea how I want an arduino to do the task without requiring any software to make it work.

Sounds like a good opportunity to do what I did and use a messed-up soldering job to learn how to use desoldering braid. A few burnt fingats and copper pads later and I've recovered a partly usable PCB.

Goon Matchmaker
Oct 23, 2003

I play too much EVE-Online

Captain Capacitor posted:

Sounds like a good opportunity to do what I did and use a messed-up soldering job to learn how to use desoldering braid. A few burnt fingats and copper pads later and I've recovered a partly usable PCB.

Desoldering wouldn't be able to save this thing. I've literally burned some of the traces off the pcbs. :( When I get a little bit more spare money next month I'll just order the kit again and do it again, this time with 100% less gently caress ups. I did manage to patch the thing together enough over the last few days to get all but 2 of the LEDs to light up. The colors are messed up though due to the PCB I soldered in backwards and then burnt the traces off of... I'm pretty happy about getting most of the LEDs to light up.

huhu
Feb 24, 2006
I'm making a basic control system using the following elements:
- Arduino Uno
- 3x Temp Sensors https://www.sparkfun.com/products/11050
- 2x Float Sensors http://www.aquahub.com/store/ifloatfloatswitch.html
- 1x LCD display https://www.sparkfun.com/products/255
- 2x LEDs

Is it correct to assume that these are the pin usages:

- Temp Sensors 3 pins, 3 Vin, 3 ground
- Float sensors 2 pins, 2 ground
- LCD display 9 pins, 1 Vin, 1 ground
- LEDs 2 pins, 2 ground

Which would mean I'm using 16 pins and will have to get a bigger board than the Arduino Uno? The operation of the system is that thee float sensors will trigger the LEDs and the temperature sensors will display temperature on the LCD. Maybe I could print all the info on the LCD and get rid of the two LED pins. Thoughts?

Bad Munki
Nov 4, 2008

We're all mad here.


Now is the perfect time to do a little reading on multiplexing.

For instance, your float sensors could easily share a pin. Also, they don't actually need two IO pins, they just need a voltage source and a single IO pin (which can still be shared between them.) Without actually reading all the spec sheets, I'm pretty sure ALL your sensors could share a single IO pin with proper multiplexing.

Bad Munki fucked around with this message at 20:48 on Feb 28, 2013

Jonny 290
May 5, 2005



[ASK] me about OS/2 Warp
You could do something like this for your Vcc and Ground lines.


e: (idk if imgur is broken or what, http://i.imgur.com/3ITx52u.png is the pic)

That's an IDE connector with the back snapped off and the cable pulled out. One bare copper wire is soldered almost all the way down the length of each side (I left the far pin on each row unconnected), and two male pins are soldered sticking down, to go into +5 and Gnd.

The last pair of pins is isolated and has a pin soldered to each, so that it will plug into pins 8 and 9 (for structural strength) but will pass them through to the top of the header so that they're not wasted.

I got +5 pins for dayyyyyys.

nightchild12
Jan 8, 2005
hi i'm sexy

huhu posted:

I'm making a basic control system using the following elements:
- Arduino Uno
- 3x Temp Sensors https://www.sparkfun.com/products/11050
- 2x Float Sensors http://www.aquahub.com/store/ifloatfloatswitch.html
- 1x LCD display https://www.sparkfun.com/products/255
- 2x LEDs

Is it correct to assume that these are the pin usages:

- Temp Sensors 3 pins, 3 Vin, 3 ground
- Float sensors 2 pins, 2 ground
- LCD display 9 pins, 1 Vin, 1 ground
- LEDs 2 pins, 2 ground

Which would mean I'm using 16 pins and will have to get a bigger board than the Arduino Uno? The operation of the system is that thee float sensors will trigger the LEDs and the temperature sensors will display temperature on the LCD. Maybe I could print all the info on the LCD and get rid of the two LED pins. Thoughts?

The temp sensors use a 1-wire interface and have unique serials, they can all go on one IO pin.
The LCD display needs 11 IO pins, plus GND and +5V (unless I'm misreading the datasheet when I skim it). This is your big pin hog.

LEDs need a pin each, Float switches need a pin each. If you are just turning the LEDs on based on the float switches, you probably don't need to run them through a microcontroller, though; just hook the LED up directly to the float switch. That brings you down to 12 pins needed: 11 for the LCD and 1 for the temp sensors, with the float switches and LEDs not connected to any IO pins.

edit: You should learn about multiplexing anyways, though. Here's a bit from the Arduino playground on an analog multiplexer/demultiplexer: http://playground.arduino.cc/learning/4051

nightchild12 fucked around with this message at 02:29 on Mar 1, 2013

huhu
Feb 24, 2006
Is multiplexing what you do with a Micro controller? It's actually up next in my book that I'm reading through and I already have the circuit setup, just didn't have the time to start messing around with the code. Also, thank you everyone for your input. I'll be designing the interface with SolidWorks and then printing it with the 3D printer at work so hopefully I end up with something awesome to brag about here later.

Bad Munki
Nov 4, 2008

We're all mad here.


It lets you have multiple signals coming in, and just one coming out, which you select with a few control lines. So say you have 8 float switches. They are all hooked up to +3V at one end, and you want to check each one to see if it's closed. You connect them up to your multiplexer, and connect the output line from there to your one IO pin on your arduino. Since you have eight lines coming into the multiplexer IC, you'll need just three to control which input you let through at any moment, counting them in a binary fashion, so your three control lines will be 000, 001, 010, 011, 100, 101, 110, 111 which maps to input 0, 1, 2, 3, 4, 5, 6, 7 respectively.

Note that that only allows you to check each one at any given instant, but by cycling through the input very quickly, it doesn't matter. You just select input 0, read it, input 1, read it, input 2, read it, etc. Unless your float switches are magically changing states tens of thousands of times a second, it's fine.

In the code on the arduino, it'd just be a matter of one extra line for each time you want to read the switches, which would be a call to a function to select the input on the multiplexer. That is, instead of

code:
for(int i = 0; i < INPUT_COUNT, ++i) {
  status = digitalRead(switches[i]);
  // do some poo poo with that info
}
you'd have
code:
for(int i = 0; i < INPUT_COUNT, ++i) {
  selectSwitch(i);
  status = digitalRead(THE_ONE_MAIN_IO_PIN_FOR_ALL_THE_SWITCHES);
  // do some poo poo with that info
}
with that new function just being something simple like
code:
void selectSwitch(int s) {
  for(int i = 0; i < 3; ++i) {
    digitalWrite(cPins[i], (s>>i)&1); //this just peels off the last bit, or at least that was the intent, but you get the idea
  }
}
cPins is just a 3-element array listing the pins you have your multiplexer control lines hooked up to.

Mind you, that code up there is completely off the top of my head and isn't checked at all for soundness or correctness in functionality or syntax, it's just to give you the gist of what you're going for here. The point here is that instead of your 8 switches needing 8 IO pins, your 8 switches now need 1 IO pin and 3 control pins, for a total of 4.

Bad Munki fucked around with this message at 01:41 on Mar 1, 2013

evensevenone
May 12, 2001
Glass is a solid.
You can use shift registers to drive that LCD display too. You could do the LEDs and the display on two 8-bit shift registers chained together.That would only take 3 pins.

huhu
Feb 24, 2006
Thanks for the in depth replies. Hopefully getting the stuff for my control system in this weekend so I'm going to start messing around with it. Also, I'm headed off to Peace Corps where I'll be unable to order new parts for six months so I'd like to bring a bunch of stuff to mess around with.

I've already got
-LEDs in six colors and Tri Color
- On/Off switches
- Potentiometers
- battery packs for AAA and 9V
- Push button
- temperature sensors
- stepper servo and regular motors
- photocells
- Resistors for 330ohm, 10kohm, 500ohm
- Wire Galore
- flex sensor
- pressure sensor
- Breadboards
- LCD Screens

I'm thinking about picking up a joy stick, various capacitors, various inductors, and 555 timer ICs. I won't be able to bring a soldering kit with me so anything involving soldering is sadly out. Any suggestions for other components worth learning about? Also, I'm in need of a good deep book that is a good overview of everything. I've already started looking at http://www.arduinoevilgenius.com/ and I did the first ten or so projects but I need more. I saw this book pop up in a list as recommended: https://www.sparkfun.com/products/11170 thoughts on this or another?

huhu fucked around with this message at 05:48 on Mar 6, 2013

TVarmy
Sep 11, 2011

like food and water, my posting has no intrinsic value

The Teensy and Digisparks are cool if you're interested in either a smaller/cheaper footprint, which is great for certain projects.

Get some mosfets and an led light strip roll for big led projects.

If you're interested in controlling an appliance, say a rice cooker for sous vide cooking, a relay kit or solid state relay is nice. Be careful of mains power, though. And never plug the Arduino into a bare mechanical relay, as it takes too much power, and if it does switch, when it turns off, it can send a jolt that fries can fry the board.

A raspberry pi is kind of a peripheral, in the way that a tall wags a dog, but the two boards work really well together, and it really simplifies stuff like hosting a server that works with physical input/output, logging data, tweeting, processing images from a camera, etc. Just send the Arduino commands from python or c over serial.

Acid Reflux
Oct 18, 2004

huhu, I've got a discrete component collection that rivals lots of small stores. I'd be *more* than happy to put together a care package for you with a variety of capacitors, diodes, and a wider range of resistors for you if you'd like. Nothing worse than being stuck in the middle of nowhere, unable to complete a project due to lack of materials. :)

Delta-Wye
Sep 29, 2005
I would grab some displays as they would be good practice and give you a neat interface for anything you might build. Do you have any particular projects in mind? It sounds like you have a lot of misc. parts to build oddball stuff so you ought to be well entertained. If you are worried about running out of stuff to do, bring a bunch of atmega328s, a dragon, and a copy of the datasheet and just reproduce all your projects baremetal.

Rat Poisson
Nov 6, 2010

huhu posted:

I'm making a basic control system using the following elements:
- Arduino Uno
- 3x Temp Sensors https://www.sparkfun.com/products/11050
- 2x Float Sensors http://www.aquahub.com/store/ifloatfloatswitch.html
- 1x LCD display https://www.sparkfun.com/products/255
- 2x LEDs

Is it correct to assume that these are the pin usages:

- Temp Sensors 3 pins, 3 Vin, 3 ground
- Float sensors 2 pins, 2 ground
- LCD display 9 pins, 1 Vin, 1 ground
- LEDs 2 pins, 2 ground

Which would mean I'm using 16 pins and will have to get a bigger board than the Arduino Uno? The operation of the system is that thee float sensors will trigger the LEDs and the temperature sensors will display temperature on the LCD. Maybe I could print all the info on the LCD and get rid of the two LED pins. Thoughts?

You should be able to run that LCD using only 6 data pins plus Vin and GND. http://learn.adafruit.com/character-lcds/wiring-a-character-lcd shows the typical setup when using the Arduino LiquidCrystal library.

huhu
Feb 24, 2006
Just setup a multiplex with 4 LEDs. :woop: Too bad there are currently 4 pins being used and 4 LEDs being lit. Will have to make a 3 x 3 cube of my own soon.

evensevenone
May 12, 2001
Glass is a solid.
So I've been working on this:

https://www.youtube.com/watch?v=4rEgWXWPCV8

I actually stopped using the Arduino library and just programming in bare C. It isn't really that hard and avr-gcc has decent documentation, and AVR Studio 6 is pretty nice.

The face detection is just using OpenCV on the laptop, the Arduino just takes position commands and generates the servo signal.

The servos are $10 RC servos, so the whole project was like $50 ($20 arduino, $10 webcam). And no soldering!

Yakattak
Dec 17, 2009

I am Grumpypuss
>:3

I have a programming question for the Arduino. We have a keypad that is used to "dial a phone". We got the numbers working perfectly fine, when you hit 1, it means 1. The problem we're having is we can't get it to act like a phone, in the sense that, when you dial 1, and wait like a second or two, it will go and dial that number, but when you hit 1,2 and 3 within that period, it dials 123. Is this possible at all?

code:
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'#','0','*'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
  Serial.begin(9600);
}

void loop(){
  char key = keypad.getKey();

  if (key != NO_KEY){
    Serial.println(key);
  }
}
So, I'd change "key" to an array, and have that array of numbers print instead.

Yakattak fucked around with this message at 15:42 on Mar 10, 2013

Adbot
ADBOT LOVES YOU

nightchild12
Jan 8, 2005
hi i'm sexy

Yakattak posted:

I have a programming question for the Arduino. We have a keypad that is used to "dial a phone". We got the numbers working perfectly fine, when you hit 1, it means 1. The problem we're having is we can't get it to act like a phone, in the sense that, when you dial 1, and wait like a second or two, it will go and dial that number, but when you hit 1,2 and 3 within that period, it dials 123. Is this possible at all?

So, I'd change "key" to an array, and have that array of numbers print instead.

That is totally possible. Easiest way is probably to use the Metro library as a timer to see if ~200 ms has passed between keypresses. I haven't used it myself so this may not be right, but here's something along the lines of what you want:

code:
Metro keypressTimer = Metro(2000); // set up timer with 2000ms period
char keyArray[10] = {'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'};
int keyArrayIndex = 0;

void loop(){

  if( keypressTimer.check() == 1 && keyArray[0] != '\0' ) { // if timer expired and keyArray has contents
    Serial.println(keyArray); // print keyArray
    keyArray = {'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'}; // clear keyArray
    keyArrayIndex = 0; // reset keyArrayIndex
  }

  char key = keypad.getKey(); // read in key press

  if (key != NO_KEY){ // if we got a value for the key press
    keyArray[keyArrayIndex] = key; // put key press into keyArray
    if(keyArrayIndex < 9) {keyArrayIndex++}; // increment index if it won't overflow
    keypressTimer.reset(); // reset timer
  }
}
The above makes several assumptions. I haven't included most of your keypad code. The length of keyArray should be set to the longest string of characters you expect. The tenth input value will be modified if more keys are pressed before the timer expires but after you've filled the array. I am assuming that \0 is an acceptable way to write a null character. You might be better off using a string object rather than an array for this. I haven't tested this to see if it will run or even checked it very thoroughly for correctness. You can also roll your own timer using millis() instead of using Metro.

But that's a basic way you can do it. Run a timer which resets each time a key is pressed, and only output when the timer expires or reaches a certain value.

nightchild12 fucked around with this message at 19:57 on Mar 10, 2013

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