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
Collateral Damage
Jun 13, 2009

huhu posted:

I misread the pinout and assumed that two of the pins weren't required for the camera to run. They were.
Vcc and Gnd? :v:

Adbot
ADBOT LOVES YOU

simplefish
Mar 28, 2011

So long, and thanks for all the fish gallbladdΣrs!


I thought that I might ask the thread - as my concept of what I want to do with my brand spanking new Arduino begins to take form, it's becoming more and more apparent that I will probably need to use a scanned matrix for the inputs. However, searching 'scanned matrix arduino' seems to get me a lot of LED natrix controllers, but not the inputs that I want.

Could someone more experienced in the arduino community please point me in a slightly more productive direction, perhaps?

Sagebrush
Feb 26, 2012

Look at how numerical keypads are traditionally read, and the code used to do that. Adafruit has a nice tutorial: https://www.adafruit.com/products/419

simplefish
Mar 28, 2011

So long, and thanks for all the fish gallbladdΣrs!


Sagebrush posted:

Look at how numerical keypads are traditionally read, and the code used to do that. Adafruit has a nice tutorial: https://www.adafruit.com/products/419

Ooh yes, thanks, that's exactly the sort of thing I was looking for!

huhu
Feb 24, 2006

Ha luckily no. SDA and SCL.

huhu
Feb 24, 2006
I have this diagram:
http://electronics.stackexchange.com/questions/101409/how-to-debouce-six-buttons-on-one-analog-pin-with-arduino

Why are the blue wires and the resistors diagonally across from each other on the push button? Judging from my attached image, wouldn't they be able to be vertical from each other as well? I tried to rig them up vertical from each other and it doesn't work.

Edit:
Another issue, I've got the 4 buttons setup like the example setup. Button 1 prints out 538-539, button 2 prints out 714-715, button 3 prints out 735-780, button 4 prints out 772-774. What could be causing button 3 to be varying so wildly? I've swapped wires, push buttons, resistors, moved the push buttons down the bread board, and it's still happening.

Only registered members can see post attachments!

huhu fucked around with this message at 18:45 on Mar 1, 2016

Sagebrush
Feb 26, 2012

1: Some buttons have different internal wiring from others. Always double check what you've got with a multimeter. The pins could be any combination of normally connected, normally open, straight through shorted, and parallel circuits.

2: 735-780 translates to a fluctuation of about 0.2 volts if you're using the standard voltage scale. Cheap buttons may have wonky internal contacts that show a variable resistance as you push them with varying amounts of force.

huhu posted:

Ha luckily no. SDA and SCL.

Soooo...you had the thing plugged in but no data wires connected? :v:

Then again, I spent like 5 minutes debugging every aspect of a student's project yesterday before realizing that the breadboard wasn't powered, so

huhu
Feb 24, 2006
Could anyone take a look at this sample sketch and tell me if there are any bad coding practices I should be aware of?

https://github.com/ArduCAM/Arduino/blob/master/ArduCAM/examples/mini/ArduCAM_Mini_2MP_TimeElapse2SD/ArduCAM_Mini_2MP_TimeElapse2SD.ino

I'm referring to stuff like using
code:
#if defined(__SAM3X8E__)
  Wire1.begin();
intsead of:

code:
#if defined(__SAM3X8E__){
  Wire1.begin();
}
I've had a hell of a time trying to integrate another part of my project into this sample sketch and that's been one of my issues. I want to make sure I'm not missing anything else.

Combat Pretzel
Jun 23, 2004

No, seriously... what kurds?!
Macros are handled different than regular C-ifs and need to be ended with #endif.

Goes pretty much like this:
code:
#if condition
    hurrdurrdurr();
    hurrdurrdurr();
    hurrdurrdurr();
    hurrdurrdurr();
#endif
Can do else-if, too with #elif and #else.

They're also resolved at compile time. Means if the condition for the section doesn't resolve, the code isn't compiled in.

In your case, it looks whether __SAM3X8E__ is defined in one of the header files, and if it is, the code in the #if section applies. It it won't, the #else section will apply. This is one way of creating portable code. Depending on what platform you'll be compiling the project, different defines will be set.

Combat Pretzel fucked around with this message at 02:19 on Mar 5, 2016

huhu
Feb 24, 2006

Combat Pretzel posted:

Macros are handled different than regular C-ifs and need to be ended with #endif.

Goes pretty much like this:
code:
#if condition
    hurrdurrdurr();
    hurrdurrdurr();
    hurrdurrdurr();
    hurrdurrdurr();
#endif
Can do else-if, too with #elif and #else.

They're also resolved at compile time. Means if the condition for the section doesn't resolve, the code isn't compiled in.

In your case, it looks whether __SAM3X8E__ is defined in one of the header files, and if it is, the code in the #if section applies. It it won't, the #else section will apply. This is one way of creating portable code. Depending on what platform you'll be compiling the project, different defines will be set.
Thanks.


Another question. I've got my setup running a 16x2 LCD, an SD card reader, and an ArduCAM (Arduino Camera). The sketch is coming up to 30,936 bytes, roughly 95%. Any more and I start to get issues with saving pictures from the camera. Is there anything that isn't too complicated that I can do at this point or am I pretty much out of luck unless I get rid of the LCD screen?

I wanted to add code for lots of custom settings for the camera to be controlled by the LCD screen and buttons but I'm thinking I've run out of memory.

Sagebrush
Feb 26, 2012

Aside from rolling your own version of the LCD or camera libraries that only have the features you need, yeah, you're pretty much stuck with that. If you want to stick with an 8-bit chip and Arduino compatibility, you can always use the ATMega 1280 or 2560 as in the Arduino Mega.

Seat Safety Switch
May 27, 2008

MY RELIGION IS THE SMALL BLOCK V8 AND COMMANDMENTS ONE THROUGH TEN ARE NEVER LIFT.

Pillbug
Does the Arduino IDE invoke GCC with -Os? I would assume it's the default, but if not, you might be able to get some size optimization by stripping unused functions.

You could probably run the binary through objdump and try to figure out if there's something internal that takes up a lot of code space and then simplify it but that's not really all that easy.

Seat Safety Switch fucked around with this message at 05:11 on Mar 5, 2016

huhu
Feb 24, 2006
I'll call it a project success. I wouldn't even know where to begin removing functions.

Enjoy a video no one asked for:

(The button is semi-broken, I know.)
https://www.youtube.com/watch?v=xecbKr4nb_E

huhu fucked around with this message at 05:23 on Mar 5, 2016

Star War Sex Parrot
Oct 2, 2003

huhu posted:

I'll call it a project success. I wouldn't even know where to begin removing functions.

Enjoy a video no one asked for:

(The button is semi-broken, I know.)
https://www.youtube.com/watch?v=xecbKr4nb_E
Neat. Reminds me of the intervalometer I made a year or so ago:



Could set number of shots, time before beginning the sequence, time interval between shots, and exposure time (since camera was in Bulb mode).

huhu
Feb 24, 2006

Star War Sex Parrot posted:

Neat. Reminds me of the intervalometer I made a year or so ago:



Could set number of shots, time before beginning the sequence, time interval between shots, and exposure time (since camera was in Bulb mode).

How are you connected to the camera? My Sony RX100 doesn't seem to support remote triggers so I'd have to rig up a custom shutter release.

Star War Sex Parrot
Oct 2, 2003

huhu posted:

How are you connected to the camera?
I bought a compatible shutter release cable on eBay for like 5 bucks and just clipped the remote off. It was 3 wires inside: a ground, a focus wire, and a shutter release wire. Short the first two and the camera would focus. Short all three and the shutter would release. It was pretty straightforward.

huhu
Feb 24, 2006

Star War Sex Parrot posted:

I bought a compatible shutter release cable on eBay for like 5 bucks and just clipped the remote off. It was 3 wires inside: a ground, a focus wire, and a shutter release wire. Short the first two and the camera would focus. Short all three and the shutter would release. It was pretty straightforward.

drat, now I'm even more bummed my camera doesn't support electrical remotes.

durtan
Feb 21, 2006
Whoooaaaa
Is this a good place to ask Netduino questions? I'm pretty new with automation in general and I'm struggling to run a servo on it.

General_Failure
Apr 17, 2005
Stupid question here. How can I safely connect a set of amplified PC speakers, or even just headphones to a PWM pin on an UNO? I wanted to try out an example from a TTS library but apparently with my ridiculous stash of misc electronics I don't have anything like a piezo speaker kicking around currently.
I now the demo code works, but I want to hear it. In a fit of unwarranted optimism I connected a passive piezo buzzer to the pin. While the sound it makes is awesome it of course doesn't work.

Mono one one side is fine. I just want to be able to hear it. Surely some decoupling is needed.

Sagebrush
Feb 26, 2012

For a 1/8" audio TRS connector, wire the sleeve of the connector to the Arduino's ground, and the tip or ring (or both) to the PWM pin. That's all you need. Alligator clips work fine. I use a cheap little 63-ohm speaker for Arduino sound testing (like this ), and without a resistor it's unpleasantly loud.

I suppose you could add some decoupling capacitors but I wouldn't worry about it. The square wave isn't exactly a hi-fi output.

Aurium
Oct 10, 2010

durtan posted:

Is this a good place to ask Netduino questions? I'm pretty new with automation in general and I'm struggling to run a servo on it.

Eh, just post.

Skunkduster
Jul 15, 2005




I've been playing around with basic stuff on the arduino and talked to my dad about it and he was interested in learning it too, but is running into a problem getting his code to load. I told him I would post his question here to see if I could find some help. Here's the catch - he writes in assembly language from a DOS prompt. He's 73 years old and pretty set in his ways, so learning a high-level language is out of the question, but I could convince him to use a GUI program if that's what it takes. I'm not sure if it would be better to ask here or in the embedded programming thread, but here is his question:

A question on programming an Arduino Uno R3 from Command Line (DOS Prompt) processing using utilities from the Atmel Studio:

I've written a test program that only contains a few instructions just to see if I could get it to assemble and load into the Arduino board.
It's not intended to do anything useful. I've included it below.

The command line I used to do the assembly is:
avrasm2 model.asm -o model.obj -l model.lst -v 3

The program (model.asm) assembled with no errors.

I then input model.obj into avrdude to cause it to load into the Arduino using the command line:
avrdude -U flash:w:model.obj -p m328p -c arduino -P com5

Avrdude fails with the following messages:
avrdude: input file model.obj autodetected as invalid format.
avrdude: invalid input file format: -1
avrdude: read from file 'model.obj' failed.

Thinking that model.obj might have to be fed through the Link Editor as would be the case for assembly language programs to run on a PC, I ran it through the linker and was told that the file format was unrecognized.

Could you assist me with the correct commands, input parameters and possible additional assembler directives to allow my program to load into the Arduino?

code:

Model.asm is shown here:
^^^^^^^^^^^^^^^^^^^^^^^^
;                     Basic Structure for an assembly program
;                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.device atmega328p

.org 0x0000           ;Org to initial jump.
.cseg
     rjmp     start   ;Jump over Interrupt Vectors to beginning of code.

.org 26*2             ;move past the vector area.

.dseg
.def   temp=R16
.equ   SPL     = 0x3d
.equ   SPH     = 0x3e
stkhi: .db     0
stklo: .db     0

.cseg
start:
;                     Initialize a stack area
       ldi     temp,0xff
       out     SPL,temp
       ldi     R16,0x07
       out     SPH,R16
here:
       rjmp    here

Captain Cool
Oct 23, 2004

This is a song about messin' with people who've been messin' with you

Sagebrush posted:

For a 1/8" audio TRS connector, wire the sleeve of the connector to the Arduino's ground, and the tip or ring (or both) to the PWM pin. That's all you need. Alligator clips work fine.
That will work for headphones, but amplified speakers may need a DC blocking cap if both the Arduino and the speakers are plugged into the wall. The guidelines I remember from years ago: film cap, 0.1 to 1uF, in line with the signal.

edit: Those numbers are for input caps, output caps form a different filter. Looks like 0.01-0.1uf is fine for feeding a high impedance sink.

edit2: For headphones you care about, you need output caps or a buffered midpoint ground to avoid giving the headphones a DC offset. The capacitor value is a huge number for headphones, big enough that you need to resort to electrolytics. Adding smaller film caps in parallel supposedly helps the sound quality.

Captain Cool fucked around with this message at 16:05 on Mar 10, 2016

politicorific
Sep 15, 2007
I need some advice on inputs/buttons.

I bought a TTP229, but it's not really what I need (garbage) http://www.amazon.com/TTP229-Channel-Digital-Capacitive-Arduino/dp/B00KSUKES0
http://goods.ruten.com.tw/item/show?21529158972102

I also bought a cheap 4x4 button matrix, but it's also terrible. http://goods.ruten.com.tw/item/show?21503286755138

I'm building a wi-fi pager system consisting of 5 units. It needs a total of 5 buttons: 4 individual call buttons and a "call everyone" button.
I'm thinking about just buying 25 cherry mx switches, soldering to a breadboard, and housing them all in an acrylic enclosure... is this overkill? ends up being 40-50 cents/switch w/o keycap.
Is there something better already out there?

Sagebrush
Feb 26, 2012

I'd just buy a bag of 50 panel-mount pushbuttons from AliExpress for $12 and wire them up manually. If you're only building 5, not a big deal. From a UX standpoint if you're only using 5 buttons you don't want to have 16 of them available -- that just confuses users.

Sylink
Apr 17, 2004

I have an arduino mega, and now i realize i have gently caress all for actual parts around. Is Aliexpres the go to place for random poo poo?

I need some switches, small breadboard etc, really just a grab bag of random crap so I can play around with it.

Hadlock
Nov 9, 2004

Just remember, you get what you pay for with switches and buttons. There is a lightyear of difference between a $15 arcade button and a $2 momentary switch from China/eBay

That board of switches posted over in the KSP thread probably had $250 worth of equipment bolted to it.

Sylink
Apr 17, 2004

I'm working on salvaging stuff locally, I just need some cheap poo poo to test setups more so than permanency. So I guess I'll start with chinese fire hazards.

huhu
Feb 24, 2006

Sylink posted:

I'm working on salvaging stuff locally, I just need some cheap poo poo to test setups more so than permanency. So I guess I'll start with chinese fire hazards.

Amazon/ebay are good too.

http://www.amazon.com/dp/B00D9M4BQU/ref=sr_rp_1?m=ADHH624DX2Q66&ie=UTF8&qid=1457745562&sr=sr-1&keywords=arduino+starter+kit
http://www.amazon.com/uxcell%C2%AE-...dboard+wire+kit
http://www.amazon.com/Resistor-1120...ds=resistor+kit

Really whatever you need.

Sagebrush
Feb 26, 2012

Hadlock posted:

Just remember, you get what you pay for with switches and buttons. There is a lightyear of difference between a $15 arcade button and a $2 momentary switch from China/eBay

Unless you're a fighting game dork, though, you won't care.

Dr. Despair
Nov 4, 2009


39 perfect posts with each roll.

was having trouble getting the heater in my little shrimp tank dialed in, so I wound up hooking up a temp probe to an arduino so that I could monitor things. This quickly snowballed and now I have a temp probe and a dust sensor both logging data to a mysql database that I setup and displayed on a fancy plot I made using highcharts. Just need to add an ambient temperature and then package it all up.

:feelsgood:



e. Nifty real time (well, within 5 minutes) data output is the best part.

Dr. Despair fucked around with this message at 05:48 on Mar 12, 2016

Hadlock
Nov 9, 2004

1) Are you measuring the dust in the air? In the water?
2) Where did you get that google finance chart stuff?
3) Well done, sir!

Dr. Despair
Nov 4, 2009


39 perfect posts with each roll.

Hadlock posted:

1) Are you measuring the dust in the air? In the water?
2) Where did you get that google finance chart stuff?
3) Well done, sir!

In the air, and http://www.highcharts.com/

Technically it's highstocks to get the time selectors, but it's good poo poo either way. Real easy to use and free for personal use.

Sir Bobert Fishbone
Jan 16, 2006

Beebort

SkunkDuster posted:

I've been playing around with basic stuff on the arduino and talked to my dad about it and he was interested in learning it too, but is running into a problem getting his code to load. I told him I would post his question here to see if I could find some help. Here's the catch - he writes in assembly language from a DOS prompt. He's 73 years old and pretty set in his ways, so learning a high-level language is out of the question, but I could convince him to use a GUI program if that's what it takes. I'm not sure if it would be better to ask here or in the embedded programming thread, but here is his question:

A question on programming an Arduino Uno R3 from Command Line (DOS Prompt) processing using utilities from the Atmel Studio:

I've written a test program that only contains a few instructions just to see if I could get it to assemble and load into the Arduino board.
It's not intended to do anything useful. I've included it below.

The command line I used to do the assembly is:
avrasm2 model.asm -o model.obj -l model.lst -v 3

The program (model.asm) assembled with no errors.

I then input model.obj into avrdude to cause it to load into the Arduino using the command line:
avrdude -U flash:w:model.obj -p m328p -c arduino -P com5

Avrdude fails with the following messages:
avrdude: input file model.obj autodetected as invalid format.
avrdude: invalid input file format: -1
avrdude: read from file 'model.obj' failed.

Thinking that model.obj might have to be fed through the Link Editor as would be the case for assembly language programs to run on a PC, I ran it through the linker and was told that the file format was unrecognized.

Could you assist me with the correct commands, input parameters and possible additional assembler directives to allow my program to load into the Arduino?

I don't have an answer for you, but I hope someone does, cause your dad sounds awesome.

simplefish
Mar 28, 2011

So long, and thanks for all the fish gallbladdΣrs!


I didn't want to post with a 'sorry dunno' but I would say ask the question wherever you can, YOSPOS maybe? I'm not a computer guy so I don't go there, the arduino is actually to teach myself how to code

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

SkunkDuster posted:

I've been playing around with basic stuff on the arduino and talked to my dad about it and he was interested in learning it too, but is running into a problem getting his code to load. I told him I would post his question here to see if I could find some help. Here's the catch - he writes in assembly language from a DOS prompt. He's 73 years old and pretty set in his ways, so learning a high-level language is out of the question, but I could convince him to use a GUI program if that's what it takes. I'm not sure if it would be better to ask here or in the embedded programming thread, but here is his question:

A question on programming an Arduino Uno R3 from Command Line (DOS Prompt) processing using utilities from the Atmel Studio:

I've written a test program that only contains a few instructions just to see if I could get it to assemble and load into the Arduino board.
It's not intended to do anything useful. I've included it below.

The command line I used to do the assembly is:
avrasm2 model.asm -o model.obj -l model.lst -v 3

The program (model.asm) assembled with no errors.

I then input model.obj into avrdude to cause it to load into the Arduino using the command line:
avrdude -U flash:w:model.obj -p m328p -c arduino -P com5

Avrdude fails with the following messages:
avrdude: input file model.obj autodetected as invalid format.
avrdude: invalid input file format: -1
avrdude: read from file 'model.obj' failed.

Thinking that model.obj might have to be fed through the Link Editor as would be the case for assembly language programs to run on a PC, I ran it through the linker and was told that the file format was unrecognized.

Could you assist me with the correct commands, input parameters and possible additional assembler directives to allow my program to load into the Arduino?

I don't really have much experience using the command line tools directly, but i think avrdude is typically called with a .hex file as input, not the .obj
This can apparently be done using the avr-objcopy tool.

Here some documentation explaining this step:
http://www.atmel.com/webdoc/AVRLibcReferenceManual/group__demo__project_1demo_ihex.html

And another example where avr-objcopy is used https://www.pololu.com/docs/0J36/4.b

Seat Safety Switch
May 27, 2008

MY RELIGION IS THE SMALL BLOCK V8 AND COMMANDMENTS ONE THROUGH TEN ARE NEVER LIFT.

Pillbug
How does the link script get entered when you use that assembler? Some embedded boards (STM32) are really picky about their executable format.

Poffo
Oct 26, 2005
Rawr!

SkunkDuster posted:

The command line I used to do the assembly is:
avrasm2 model.asm -o model.obj -l model.lst -v 3

http://www.atmel.com/webdoc/avrassembler/avrassembler.wb_Command_Line_Options.html

I think you need to specify -fI to get a hex-file.

cultureulterior
Jan 27, 2004
I've got one of those dust sensors, but I haven't used it yet- how hard was it to get going?

Adbot
ADBOT LOVES YOU

Dr. Despair
Nov 4, 2009


39 perfect posts with each roll.

cultureulterior posted:

I've got one of those dust sensors, but I haven't used it yet- how hard was it to get going?

Took less than 5 minutes, just followed the example here http://www.waveshare.com/wiki/Dust_Sensor and the waveshare version I got was nicely packaged up already.

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