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
Scottw330
Jan 24, 2005

Please, Hammer,
Don't Hurt Em :(
I hope this is a good thread to ask this:

I just got a little robot kit from adafruit: https://www.adafruit.com/products/3216

Which comes with two little DC motors (drive with 3-6VDC, 200-400 mA run, 1.5A hard stall).

I want to control the motors with an arduino with a few sensors (In total less than <200mA).

What would be the best way to power this stuff? I'm currently thinking of a 3s 1000mA lipo (11.1V-12.6V) into a 5V 3A pololu step-down switching regulator for the motors, and maybe a separate 5v 1A step down regulator for the digital voltage? I'm thinking they need to be separate regulators since the motors might be very noisy?

Adbot
ADBOT LOVES YOU

Hadlock
Nov 9, 2004

I did a similar project, same motors

My power supply was 2 X 18650 (Samsung R25 are under $5 a cell these days) in a 2 cell holder for ~7 volts nominal, a 500 ma step down for the Pi A+ and direct battery current in to the motor controller

Two suggestions, get a 12v car battery volt meter to keep an eye on the batteries (mine is a tiny $3 digital read out that shows on tenths of a volt) and add in a physical kill switch between the positive terminal and everything else for when you realize you've wired up the batteries wrong and oh god

18650 are standard laptop battery cells, Tesla Model S cells etc etc so chargers, replacement batteries etc are easy to come by.

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
Is there anyway, using a Arduino, to make a pulsating push button that when you press it sends a keyboard command? There must be a way right? Similiary a way to have a motion detecter send a keypress on motion detection

Empress Brosephine fucked around with this message at 01:38 on Oct 23, 2016

Sagebrush
Feb 26, 2012

Only some of the Arduinos can behave natively as an HID device like a keyboard. The Leonardo, Micro and Due can do it, and some third-party boards like the Teensy can as well, but the basic UNO can't.

If you have a Leonardo etc., then the code to do what you want is trivial:

code:
#include <Keyboard.h>

void setup() {
  pinMode(2, INPUT_PULLUP);
  Keyboard.begin();
}

void loop() {
  if(digitalRead(2)==LOW){
  Keyboard.print("x");
  delay(200);
  }
}
When you run the sketch, your Leonardo will connect to your computer as a USB keyboard, and when you pull pin 2 low (by pressing a connected button) it will send the "x" character 5 times per second, just as if you were tapping that key.

Hobnob
Feb 23, 2006

Ursa Adorandum
I believe you can also convert other Arduinos (e.g. the Uno) to a HID device by changing the firmware, however you will lose the ability to do usual programming via the USB port until the firmware is flashed back to the default.

Another option is use a standard Arduino, but with a windows-side driver to insert keystrokes from serial input (i.e. a software keyboard wedge), but you might need to experiment to find one that works with the standard virtual com port drivers.

Sagebrush
Feb 26, 2012

I don't think you can flash the UNO to work that way. It has an FTDI USB/serial chip that does the USB communication, and that chip's behavior can't be changed with the Arduino code (which only runs on the ATMega). Your computer is always going to see an FTDI USB/serial device, not a keyboard.

A custom driver that interprets properly formatted serial data and inserts keystrokes would work, though. Or a piece of background software that does the same. Or you could be really smart about it and write a driver for the FTDI chip that hooks into the HID system, so that your computer does see it as just another keyboard.

Writing custom device drivers is just a little more advanced than buying a SainSmart Leonardo and #including <Keyboard.h>, though.

Scottw330
Jan 24, 2005

Please, Hammer,
Don't Hurt Em :(

Hadlock posted:

I did a similar project, same motors

My power supply was 2 X 18650 (Samsung R25 are under $5 a cell these days) in a 2 cell holder for ~7 volts nominal, a 500 ma step down for the Pi A+ and direct battery current in to the motor controller

Two suggestions, get a 12v car battery volt meter to keep an eye on the batteries (mine is a tiny $3 digital read out that shows on tenths of a volt) and add in a physical kill switch between the positive terminal and everything else for when you realize you've wired up the batteries wrong and oh god

18650 are standard laptop battery cells, Tesla Model S cells etc etc so chargers, replacement batteries etc are easy to come by.

Oh, cool, I didn't think of 18650 batteries. Don't they get to 4.2V each when charged? I would be worried that 8.4V would be too much for these motors?

UberVexer
Jan 5, 2006

I like trains

Sagebrush posted:

I don't think you can flash the UNO to work that way. It has an FTDI USB/serial chip that does the USB communication, and that chip's behavior can't be changed with the Arduino code (which only runs on the ATMega). Your computer is always going to see an FTDI USB/serial device, not a keyboard.

The UNO R3 ships with an AtMega16u2 as the communication chip. It can be reflashed to act as a HID, projects like UnoJoy take serious advantage of this.

It can be flashed to act as an HID that takes commands from the 328 on the board, but as mentioned above, you can't program the 328 while it's in that mode.

If you're going to bother doing it, you might as well get a Leonardo.

UberVexer fucked around with this message at 17:38 on Oct 23, 2016

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
Hmm okay thanks guys

Hadlock
Nov 9, 2004

Scottw330 posted:

Oh, cool, I didn't think of 18650 batteries. Don't they get to 4.2V each when charged? I would be worried that 8.4V would be too much for these motors?

I think mine are rated 12v and had no problem; either way electric motors are big dumb copper coils, They're pretty durable; just don't drive them past 50%. Think of 60% as 120% throttle and 100% as brief burst to 200% throttle. For pushing around a 3lb robot on flat ground it's going to be hard to burn up the motors.

Second, they charge to 4.2v, but pretty rapidly discharge to ~3.8 and then slowly ramp down to 3.2, where they start discharging rapidly again. During normal use the nominal voltage was about 7.6v from what I remember.

Sagebrush
Feb 26, 2012

UberVexer posted:

The UNO R3 ships with an AtMega16u2 as the communication chip.

Durr, I should have remembered that. Too many different board variants these days.

I've still got my original Arduino from 2006 sitting around somewhere. Built it from the kit, all through-hole parts, with an ATMega8 and a full-size DB9 serial port. Hell yeah

Sagebrush fucked around with this message at 02:32 on Oct 24, 2016

evil_bunnY
Apr 2, 2003

I just got a bitching hall effect 3 axis gimbal to make a mouse emulator. At some point it might get changed to xbox360 (Xinput) spoofing since modern games tend to like that more. I have no idea what I'm doing.

UberVexer
Jan 5, 2006

I like trains

evil_bunnY posted:

I just got a bitching hall effect 3 axis gimbal to make a mouse emulator. At some point it might get changed to xbox360 (Xinput) spoofing since modern games tend to like that more. I have no idea what I'm doing.

https://github.com/AlanChatham/UnoJoy

I've mentioned this project earlier in the thread, but it lets you turn an Arduino UNO (they have it for leonardo also) into a Joystick device for computers or PS3.

I used it a bunch to make accessibility controllers in 2013 for one of my friends with CP.

It should give you some idea of what you're doing.

evil_bunnY
Apr 2, 2003

That's one of the options. The game I'm building it with has stupid mouse controls requiring constant input (and I have a finite mousepad, unfortunately), so for now it's going to emulate a straight HID mouse.

Other option is something like this: http://www.zlittell.com/2015/07/fightstick/

ReelBigLizard
Feb 27, 2003

Fallen Rib
Not specifically Arduino but might be useful to you guys, I'm developing a super cheap robot battle series for my local school district and I wanted to control some small DC motors for as cheap as possible. Found a guide online about repurposing busted servos (with stripped gears or w/e).

It works:
https://www.youtube.com/watch?v=80z1tE-i5VQ

It works really well.

mbt
Aug 13, 2012

I'm looking for the absolute cheapest (and smallest) board (arduino or otherwise) to put a speaker on and play a 5 second sound

Is it the arduino micro? I think it's the micro. I think that's like $20 which might be a bit much though

ReelBigLizard
Feb 27, 2003

Fallen Rib
What kind of sound are we talking? just need beeps/8-bit stuff?

Arduino probably isn't what you need.

CommieGIR
Aug 22, 2006

The blue glow is a feature, not a bug


Pillbug
Yeah, you'll need an actual codec chip to do actual audio.

mbt
Aug 13, 2012

ReelBigLizard posted:

What kind of sound are we talking? just need beeps/8-bit stuff?

Arduino probably isn't what you need.

a 5 second fairly high quality audio played very loudly

ReelBigLizard
Feb 27, 2003

Fallen Rib
Pi Zero plus a cheap USB audio adapter and a kit amp.

Not a very elegant solution but it would get you there.

JawnV6
Jul 4, 2004

So hot ...

Meyers-Briggs Testicle posted:

a 5 second fairly high quality audio played very loudly

$16, still might need to boost the output though.

Sagebrush
Feb 26, 2012

Arduino Pro Micro + WTV020 audio decoder + some kind of suitable amplifier and speaker system for whatever loudness you require, there are zillions of options there

Total cost ~$5 with free shipping if you're willing to wait a couple of weeks, maybe $15 all in if you buy them both on Amazon instead of AliExpress. You'll need an old <2GB MicroSD card as well which you can almost get for free.

e: but yeah, while the Arduino and sound decoder give you tons of flexibility and reasonably high quality (I think it does 22KHz), it might be overkill for your purpose. if you literally just want to play a single sound clip as cheaply as possible, you can get the board from one of those talking greeting cards and just use that. e.g. this

Sagebrush fucked around with this message at 02:04 on Nov 8, 2016

goodness
Jan 3, 2012

When the light turns green, you go. When the light turns red, you stop. But what do you do when the light turns blue with orange and lavender spots?
What is a good kit to get for a complete beginner, I also need any basic tools and soldering equipment.

TheresaJayne
Jul 1, 2011

goodness posted:

What is a good kit to get for a complete beginner, I also need any basic tools and soldering equipment.

Find a local Hackspace and then go there, they will have tools and people to help you learn how to use them properly.

in the uk http://www.hackspace.org.uk/wiki/Main_Page

in the usa https://wiki.hackerspaces.org/United_States_of_America

edmund745
Jun 5, 2010

Sagebrush posted:

Arduino Pro Micro + WTV020 audio decoder + some kind of suitable amplifier and speaker system for whatever loudness you require, there are zillions of options there

Total cost ~$5 with free shipping if you're willing to wait a couple of weeks, maybe $15 all in if you buy them both on Amazon instead of AliExpress. You'll need an old <2GB MicroSD card as well which you can almost get for free.

e: but yeah, while the Arduino and sound decoder give you tons of flexibility and reasonably high quality (I think it does 22KHz), it might be overkill for your purpose. if you literally just want to play a single sound clip as cheaply as possible, you can get the board from one of those talking greeting cards and just use that. e.g. this
The generic "arduino MP3 sound modules" sold on the China-direct sites are generally pretty crappy.
They all claim to play MP3 and wav files, but many people can only get them to play low-res WAV files. Many of them will ONLY accept 2 meg SD cards, they cannot seem to read anything larger even tho the sellers claim they can.
The chips are Chinese manufacture and the documentation is incomplete and in Chinese besides.
Don't take my word for it--do some Google hunting for people trying to make these things work. They are crap, not worth bothering with.
,,,
What's much better (if you want to play a lot of different sounds) is to just get one of the little $2 stand-alone 4-button MP3 players and then wire the buttons up to the arduino pins as you need to. You must program the arduino to manipulate the "buttons" properly, but that is easy to do.

The greeting cards I don't recommend either. A lot of them are limited to 4-bit sound, and only a few seconds. The doll voice-boxes are the same way (short sound and very low quality).

If you want to do this quick and easy, and have it sound nice, go cough up the $15 for one of the 2mb flash Adafruit stand-alone sound player boards. It costs more but it works the way they say it does. PRODUCT ID: 2342
It does need an external amp, but they sell those, or you can get that elsewhere.

Sparkfun has one for $20 but it is low-res (4-bit) only. Their "good" audio module costs $50.

mbt
Aug 13, 2012

edmund745 posted:

The generic "arduino MP3 sound modules" sold on the China-direct sites are generally pretty crappy.
They all claim to play MP3 and wav files, but many people can only get them to play low-res WAV files. Many of them will ONLY accept 2 meg SD cards, they cannot seem to read anything larger even tho the sellers claim they can.
The chips are Chinese manufacture and the documentation is incomplete and in Chinese besides.
Don't take my word for it--do some Google hunting for people trying to make these things work. They are crap, not worth bothering with.
,,,
What's much better (if you want to play a lot of different sounds) is to just get one of the little $2 stand-alone 4-button MP3 players and then wire the buttons up to the arduino pins as you need to. You must program the arduino to manipulate the "buttons" properly, but that is easy to do.

The greeting cards I don't recommend either. A lot of them are limited to 4-bit sound, and only a few seconds. The doll voice-boxes are the same way (short sound and very low quality).

If you want to do this quick and easy, and have it sound nice, go cough up the $15 for one of the 2mb flash Adafruit stand-alone sound player boards. It costs more but it works the way they say it does. PRODUCT ID: 2342
It does need an external amp, but they sell those, or you can get that elsewhere.

Sparkfun has one for $20 but it is low-res (4-bit) only. Their "good" audio module costs $50.

this is the kind of post I read SA for

thank you very much to everyone, I'll post results from this super top secret project when I finish it

Hadlock
Nov 9, 2004

Out of curiosity, with a 160mhz esp8266 over gpio, can you play uncompressed 48khz audio? That's how the arduino audio library works, right? There's not enough memory to take advantage of it on the arduino, but the esp8266 should be able to stream in data?

Orthogonalus
Feb 26, 2008
Right angles ONLY
Bought an Arduino starter kit a while ago and have been having lots of fun with that, but I'm missing some wireless stuff to play with, and I'm not really sure what to look for. I'd like a simple battery driven remote to send simple signals to some sort of receiver, but the stuff I've seen seems weirdly expensive considering how cheap wireless doorbells and such are in generic home electronics stores.

Any tips on what to look for?

Sagebrush
Feb 26, 2012

edmund745 posted:

The generic "arduino MP3 sound modules" sold on the China-direct sites are generally pretty crappy.
They all claim to play MP3 and wav files, but many people can only get them to play low-res WAV files. Many of them will ONLY accept 2 meg SD cards, they cannot seem to read anything larger even tho the sellers claim they can.
The chips are Chinese manufacture and the documentation is incomplete and in Chinese besides.
Don't take my word for it--do some Google hunting for people trying to make these things work. They are crap, not worth bothering with.

No, you need to read the descriptions more closely.

https://www.amazon.com/WTV020-SD-WTV020SD-20SS-WTV020-SD-16P-Atomic-Market/dp/B01ACK62T0/

quote:

Support plug-largest-capacity of 1G SD card
Automatically identify audio files
Can load WAV audio at 6KHz ~ 16KHz sample rate
Operating voltage: DC2.5 ~ 3.6V
High Quality Atomic Market Brand Product

They don't play MP3s and none of them claim to. They say "MP3" in a misleading way because the chips have something that the chinese manufacturers refer to as "MP3 Mode", where there are dedicated lines that you can toggle for next/previous track, play/pause, and volume control, like an MP3 player. However, all of the datasheets and the detailed product descriptions say they play WAV and AD4 files only.

The sound quality is decent; 16KHz is plenty for sound effects and recordings of voices, and if you convert to AD4 it can hit 36KHz, which is approaching CD quality.

All of them also say they only read 2GB or smaller SD cards (the one linked above says 1GB specifically). Plenty of people online saying "I put in a 32GB card and it didn't work, such crap!" when the very product page says clearly what size is required.

Pay attention to these things before slagging a product that doesn't work when you don't use it right.

politicorific
Sep 15, 2007
I also have one of those wtv020 boards and have tried many times getting it to work with a 2GB SD card by following this website:
http://www.buildcircuit.com/example-1-using-wtv020sd-16p-music-module-with-arduino/

I stand with Edmund745, it's garbage. Plus it's getting harder tracking down smaller SD cards.

phospete
Jul 4, 2007
So, I think I fried my board. I have a Feather M0 Adalogger (https://www.adafruit.com/product/2796) and was using a piezo buzzer as a knock sensor (like this - https://www.arduino.cc/en/Tutorial/KnockSensor). I had a 1 megaohm resistor in parallel with the piezo as suggested, but the reading still routinely maxed out the analog input pin, so it was definitely still over 3.3V. It worked fine for a while, but now the board's processor gets extremely hot while plugged in, even if nothing is connected to the board. It's drawing about 300 mA unconnected. It also no longer seems to be able to connect via usb serial. I think it's toast.

I'm not 100% certain the piezo fried it, but I don't have any other obvious culprits. Anyone have any experience with a better way to connect piezo sensors?

Captain Cool
Oct 23, 2004

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

politicorific posted:

As I understand it, the DSA & DSB inputs are ANDED together. I'm only using 1 input, so is this why I am having to invert my 0's and 1's in my code to get the LED to light?
LEDs usually want low logic to turn on and high logic to turn off. This is because semiconductors can sink more current than they can source.

quote:

Let's say my CPU usage is at 70% and memory usage is at 30%. I want the display to look like this (0's on, X's off):

pre:
            Link XXXXX00000000000
Power 0 Activity XXXXXXXXXXX00000
The lazy way I see to do this is to build a truth table for each variable and add them together and write that out. Each 6.25 percent is equal to an "LED" so that:
code:
if (x >= 93.75 && x <=100)[{myCPU= {170,170,170,170}]; // 170 in the current state turns on  4 top LEDS on
if (x >= 87.5 && x < 93.75)[{myCPU= {234,170,170,170}];
if (x >= 81.25 && x < 87.5)[{myCPU= {250,170,170,170}];
if (x >= 75  && x < 81.25)[{myCPU= {254,170,170,170}];
if (x >= 68.75 && x < 75)[{myCPU= {255,170,170,170}];
...

if (x >= 93.75 && x <=100)[{myMEM= {85,85,85,85}]; //85 tells all 4 bottom LEDs on
if (x >= 87.5 && x < 93.75)[{myMEM= {213,85,85,85}];
if (x >= 81.25 && x < 87.5)[{myMEM= {245,85,85,85}];
if (x >= 75  && x < 81.25)[{myMEM= {253,85,85,85}];
if (x >= 68.75 && x < 75)[{myMEM= {255,85,85,85}];
...
64 16 4 1
There's got to be a better way.
Think about this in layers. At the top, the application layer wants to send nice readable numbers (0% to 100%). At the lowest layer, the driver needs to send chopped and flipped bits. Write functions to get there one step at a time.

DisplayLoads(float CPUPercentage, float MemoryPercentage); // 0-100 each
SetLEDBars(int LinkLEDBar, int ActivityLEDBar); // 0-15 each
SetLEDs(unsigned int LinkLEDs, unsigned int ActivityLEDs); // bit mask, 1 bit per LED
ClockLEDBytes(byte[] b); // 1 bit per LED in the order they need to be sent out

The first translation is pretty simple. Divide by 6.25 and then round to the nearest int. Clamp the result to the range 0-15 to make sure it's right.

The second is also easy: set the lowest n bits with 2n-1, or (1<<n)-1.

The third is trickier, but you will be starting from a good place: you have 32 bits of input to map to 32 bits of output. It might take you 32 lines at first, but I'm guessing you could reduce it to a loop with 4 lines.

quote:

Related question:
How do I make binary counter using an Arduino nano which will count higher than 65,535?
Use long instead of int.

quote:

Here's my dumb demo code for directly manipulating the ports of my Arduino Nano, I have the clock pin on D6 and datapin on D3... why the hell does this code work this way?
The 16's place should be pin 4, not pin 3
The 128's place should be pin 7, not pin 6
Where are these numbers coming from?

moron izzard
Nov 17, 2006

Grimey Drawer

ReelBigLizard posted:

Not specifically Arduino but might be useful to you guys, I'm developing a super cheap robot battle series for my local school district and I wanted to control some small DC motors for as cheap as possible. Found a guide online about repurposing busted servos (with stripped gears or w/e).

It works:
https://www.youtube.com/watch?v=80z1tE-i5VQ

It works really well.

how about you link the guide as well.

Jamsta
Dec 16, 2006

Oh you want some too? Fuck you!

I tried that ESP WiFi SSID spammer last night, and it worked as advertised.

Now to mess with the guys at work...



The XKCD Larper
Mar 1, 2009

by Lowtax
Do ya'll talk about Raspberry PI in here?

evil_bunnY
Apr 2, 2003

The XKCD Larper posted:

Do ya'll talk about Raspberry PI in here?

https://forums.somethingawful.com/showthread.php?threadid=3468084

The XKCD Larper
Mar 1, 2009

by Lowtax
Thank you.

CommieGIR
Aug 22, 2006

The blue glow is a feature, not a bug


Pillbug

Jamsta posted:

I tried that ESP WiFi SSID spammer last night, and it worked as advertised.

Now to mess with the guys at work...





I have high hopes for the ESP32 :getin:

rawrr
Jul 28, 2007
Speaking of ESP, I picked up an Echo Dot and paired it with this:

https://github.com/kakopappa/arduino-esp8266-alexa-wemo-switch

It was surprisingly straightforward to set up with the NodeMCU; I basically only needed to plug in my wifi credentials and the Echo Dot was able to detect it as a wemo device.

<$10 for iot enabled switches is not bad!

Adbot
ADBOT LOVES YOU

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
Hmmm not sure exactly where to ask this, as perhaps my arduino can do this for me but i'm trying to make something that utilizes a Fan like this:

https://www.amazon.com/gp/product/B00WM7TRTY/ref=ask_ql_qh_dp_hza


that can be turned on or off with a keystroke.


I figured the way to do it would be to somehow manage the power provided to it but I don't even know if something like this is possible. Help me goons!!!!

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