|
You can power it elsewhere, but the grounds of the sensor and Arduino need to be tied together. This is so everything is at the same common ground and a 5V difference at the sensor is the same as a 5V difference at the Arduino. There are apparently some pitfalls and issues with grounding a lot of different things, but in general for a couple sensors it shouldn't be a big deal to run the sensor ground to the Arduino ground. You'll also need those sensor grounds attached to the ground of their power supply/battery.
|
# ? Apr 25, 2014 20:54 |
|
|
# ? May 29, 2024 18:51 |
Bad Munki posted:What the everliving hell. I am absolutely stumped by this. So, uhh...I was falling asleep at my computer and was sorta blindly mashing at google and I think I found the answer to my problem with the teensy 3.0 and the keypad that was freaking out. Turns out it's a problem with the Keypad library. I found this post: http://forum.pjrc.com/threads/19003-Teensy-3-0-and-Keypad-arduino-app?highlight=keypad+library quote:So i've got it to act properly: I opened up Keypad.cpp and changed that function call (line 89) and while I don't have the actual installation here to test with, I can jump the row/column wires to simulate key presses and watch the output on the serial monitor, and it seems to work fantastically now. That's a pretty annoying bug, and like the poster who suggested the fix, I don't know why it would behave that way, since pin_read is just a virtual for digitalRead. At least it appears to be working now, though. I can hardly wait to get down there this weekend and re-install it so I can get my uno back once and for all (I prefer the teensy, but I need to use the uno as a programmer for an attiny, since the teensy was having trouble interfacing properly.)
|
|
# ? Apr 26, 2014 04:36 |
|
I'm playing around with some TFT LCD animations with the Uno, both with drawings on the LCD, and with bitmaps loaded from an SD card. The basic animation I am working on is a simple 30x30 pixel square scrolling across the screen. With the rectangle - drawing functions, the animation is fairly smooth. However, trying to move a similarly sized bitmap isn't as smooth. I think the problem is that my code calls the bitmap from the SD card every time. That seems slow. Is there a way to save the bitmap into an object in the arduino code and manipulate its position that way? Would that work faster?
|
# ? Apr 27, 2014 06:16 |
|
Well, I never got my question answered, but I worked around it anyway. Also, I made a neat thing here: https://www.youtube.com/watch?v=Mw6Cf_TSfcA It's a custom multi-gauge indicator system for my car. I'm quite in love with it.
|
# ? May 13, 2014 06:15 |
|
jovial_cynic posted:Well, I never got my question answered, but I worked around it anyway. Nice! Are you going to hook it up to the CAN bus and read the car's sensors? I've been thinking of building a little guage box to display some stats from an IMU, like angle, horizon level, altitude, direction, etc. Would be handy to have in my Jeep for off road driving so I know if I'm at a weird angle or heading in the wrong direction.
|
# ? May 13, 2014 06:21 |
|
mod sassinator posted:Nice! Are you going to hook it up to the CAN bus and read the car's sensors? I do want to read all the sensors in my car... I think there's only 7 or 8 of them, so that does put me above what the UNO will handle on its own. I'm trying to decide if I want to run two of these systems in my car: one for the signals I NEED to see (temp, fuel/oil pressure), and another one for things that are fun to micromanage, but not as interesting. Throttle position sensor, for example. Or... if I want to upgrade to the MEGA or something like that and maintain a single system for everything.
|
# ? May 13, 2014 06:31 |
|
So glad the forums are back. I've had a question that's been nagging me. I've been playing with an Arduino Uno and an LCD screen, working on a little basic program that fades LEDs in a pattern and runs an animation on the screen related to the LED fade variables. So, to put it short, in my code, I declare something like this: code:
It's not a big problem, I still have plenty of space for the program. My first few micro controller programming experiences were with a Basic Stamp though, and from there I learned to make my variables as small as possible. I'm new to using subroutines though, and I'd like to know exactly what the issue was for future programs.
|
# ? Jun 26, 2014 03:06 |
|
It's really hard to say without the actual code, especially if something like variable typing is causing the problem. Those things don't come across in pseudocode.
|
# ? Jun 26, 2014 03:26 |
|
I was really hoping not to have to post my awful code. But here it is: http://pastebin.com/06nCp56p
|
# ? Jun 26, 2014 22:29 |
|
Fanged Lawn Wormy posted:loop:
|
# ? Jun 26, 2014 22:57 |
|
Ah yeah, I had gone back and forth on that a couple times when I was first writing the code, because I was having trouble with the Arduino recognizing my mode switch pins. Turned out I was dumb and had floating pins, switching to the pull-up input mode really helped. It isn't getting stuck in either mode, but I'm wondering if IF statements will allow variables to get out to the global loop for updates...
|
# ? Jun 27, 2014 01:40 |
|
You're asking if something likecode:
|
# ? Jun 27, 2014 01:49 |
|
No, not exactly. My variables "ear1brightness" and "ear2brightness" are globally declared ints. When I do this, the led's change brightness fine, and their brightness is mapped to a bargraph on the LCD fine as well. if I make those two variables bytes (they are only ever 0-255 anyways) then the bar graph drawing routine acts like the variable isn't updating, although the LEDs still change brightness. I'm wondering why changing the type of variable matters, since all the math should still be fine. It's like, what I'm seeing is that the math functions of RunLights() still run, but for some reason, the Animation routine doesn't register that the variable changes.
|
# ? Jun 27, 2014 03:12 |
|
Just glancing at it the problem is probably in your map or analogWrite call with the ear brightness variables. If you stick a serial print in you can see if the math is working and the value is changing correctly. If the math is working and your value is progressing but not being written I'd try casting it as an int when you call map and analogWrite and just see if that works.
|
# ? Jun 27, 2014 03:28 |
|
Fanged Lawn Wormy posted:Anyways, in trying to strip down my code and make it more efficient. Also, you shouldn't be using pin 13 as an input; it's attached to the onboard led and won't read correctly without an external resistor. edit: You might also want to switch the layout to the below: That way you aren't checking an extra if statement every loop and it gets rid of 2 variables. It also doesn't waste a bunch of time constantly printing. code:
TheLastManStanding fucked around with this message at 04:17 on Jun 27, 2014 |
# ? Jun 27, 2014 03:59 |
|
thanks for the insights. I just had thought: perhaps the problem with the screen mapping is that the lcd's library expects ints for variables... I'll do some debugging later, take a closer look. TheLastManStanding posted:If you're looking for efficiency, you can start by getting rid of those 3 extra digital reads at the start of your loop and switch all the other ones to PINB. Digital read is hilariously slow and is typically the line that is slowing people's code down the most. Also, I didn't know about PINB. I understand the 'setup' part, but I'm not sure if I understand what you mean about "switching all the other ones". And it comes down to something I've never really looked too far in to... do I need to tell the Arduino digitalread() to check the pin status, or can I just write if(input == high) etc? oh yeah, and thanks for noting that about the LED pin... I as planning on moving it, it found it's way over there when I was doing some loving around with pins and never went back to its home. Fanged Lawn Wormy fucked around with this message at 04:23 on Jun 27, 2014 |
# ? Jun 27, 2014 04:21 |
|
Where you define your constants you would instead write them as:code:
Then instead of digital write you use: code:
edit: Remembered that you're running the loop when the pin is low, so you need finagle the bit math to work out that way. TheLastManStanding fucked around with this message at 06:19 on Jun 27, 2014 |
# ? Jun 27, 2014 05:13 |
|
What does digitalRead() do, exactly, that makes it so slow?
|
# ? Jun 27, 2014 05:20 |
|
Sagebrush posted:What does digitalRead() do, exactly, that makes it so slow? Yeah, this. I've never experienced slow code or processing using digitalRead() (or even analogRead())
|
# ? Jun 27, 2014 05:48 |
|
The command is multiple lines of code since it has to map a variable to 3 different ports. If you aren't sending a variable to the command then you can just access the port directly instead and you cut out a bunch of lines of code. It doesn't come up much, but if you're doing something that requires writing/reading extremely quickly (such as for an encoder or led display) it starts to matter. There's quite a few pages which talk about it (Such as this one) and libraries (digitalWriteFast) which offer a quicker read/write functions. As an example of when it's useful, one of his lines of code is: code:
code:
TheLastManStanding fucked around with this message at 06:45 on Jun 27, 2014 |
# ? Jun 27, 2014 06:00 |
|
I've got a problem to tackle and I'm not sure if an Arduino is the answer, but I'm hoping for some help. My neighbor has a dog that barks a lot. They leave it outside pretty much all the time and it barks at any sound in the neighborhood at all times of day. I bought this dog bark deterrent and it has done nothing to stop the barking. I suspect because it can't get loud enough but that isn't what I'm trying to do. I'd like to modify the bark detector to count barks and record the time and date. The detector does trigger when the dog barks, so I think it should be easy to hook in to the LED that goes red or the speaker circuit that emits the deterrent sound. I've never messed with an Arduino and have limited electronics experience, but I think I can make this work with this thread's advice. I do have a Raspberry Pi, which I think I will need as well, to actually record the bark times. I don't really know where I should start though. How would you go about accomplishing this?
|
# ? Jun 30, 2014 19:10 |
|
You'd be better off using just the pi since your taking about needing to do some FFTs to compare a real bark to a false positive (like a car backfire or horn). Alternatively file noise complaints every other day until the owners bring the dog in at night or are forced to give it away. (Or you know. Speak to the neighbors first)
|
# ? Jun 30, 2014 21:52 |
|
Thanks. The deterrent device already filters for dog barks to trigger on, so that's why I want to use it as the switch to count against. Not knowing anything about how to do it, what I imagine doing is tapping into the LED that turns red when the deterrent triggers, then somehow noting the time and date when it happens. I want to rig this up at least partially so I can see just how much barking is going on and decide if I'm just being overly sensitive or if it really is barking too much. If it really is barking too much, I'd like to be able to go over there and tell them "Your dog barked 568 times yesterday, 230 times after 9pm". Then I could send it to the county or whatever if the don't do anything about it (they won't). Edit: Or, if it barked like 30 times, then I would know I just need to relax a little. Economic Sinkhole fucked around with this message at 22:31 on Jun 30, 2014 |
# ? Jun 30, 2014 22:25 |
|
Tape a light sensor to the LED with black tape so that only light from the LED can hit the light sensor.
|
# ? Jun 30, 2014 22:49 |
|
I'd go with the arduino since it's smaller, cheaper, and much easier to program. You can get a real time clock module, microSD card board, and an optoisolator from sparkfun for around $25 total. They give you example arduino code so it shouldn't be hard to rework it to fit your need.
|
# ? Jun 30, 2014 23:02 |
|
I would put a multimeter positive lead on one leg of the LED and the ground lead on the ground of the device's battery. When the bark LED lights up check what voltage is being output by the LED. If it's anything in the range of 2.5-5 volts it should be fine for reading with an Arduino. You could use a Pi too, but be careful that the voltage doesn't go above 3.3 volts when the LED is lit (the Pi can't read a 5 volt signal directly). If the voltage does go to 5 volts you can put a couple resistors in as a voltage divider to knock it down from 5 to 3.3 volts (use large resistors like 10kohm+ so the current draw is small). Once you have a signal you can read with your board, just run a wire from the LED leg to a digital input on your Arduino/Pi. Read that input state using the digitalRead function to check if it's high (LED is lit) or low (LED is not lit). Make sure to also run a wire from the battery ground to the Arduino/Pi ground so they're both at the same potential. If you're using an Arduino you could actually power it from the 9V battery of the dog bark detector, but without adding some logic to sleep the Arduino you'll go through the battery in a couple hours. Better to just plug the Arduino into a power outlet if you can. One thing to be careful of in general though, don't go poking around and measuring voltages if the device has an AC power cord going straight into it. From the Amazon description it sounds like it's powered by a 9 volt battery so you should be fine. However if it's something like a kitchen appliance, etc. that is powered off AC you could probe a line at 120 volts and hurt yourself. I've wanted to tap into my rice cooker by checking when its cook light isn't lit, but that light is actually a small neon bulb that runs at the full 120 volts so it's way too high to mess with directly (using a light sensor taped to the bulb is what I ended up doing).
|
# ? Jun 30, 2014 23:04 |
|
If you just want to record the number of times the dog barked and grab the data once a day or something, so you can say "your dog barked 800 times yesterday" or whatever, all you need is the Arduino. Just increment the EEPROM every time the LED goes on, which you could measure directly if its voltage supply is between maybe 3.5 and 5.5 volts, or if not you could easily do it with an analog read of the pin voltage or a properly calibrated LDR stuck on the LED and wrapped in black electrical tape. You would plug in through USB and download the EEPROM value and reset it at whatever interval you like. If you wanted to record the exact date and time to make a cool graph to show to the cops, you would need to hook up a clock module. The Arduino's crystal isn't accurate enough to keep time over more than a few hours. Then, since you're storing much more data than just an incrementing counter, you would also need an SD card shield/module of some kind. A little more complex for sure but not out of the question. If you wanted to be a super cool hacker, I'd say get an ATTiny, wire it into the dog bark detector's 9v power supply with an appropriate divider, patch an ADC pin into the LED's positive leg to read it directly and store in EEPROM, and then wire in a button that you can press to have the ATTiny blink out a count of the last 24 hours' worth of dog barks in binary or morse code or something by hijacking the same LED you're reading. Hold the button down to reset for a new day. Total cost about $1.50 for the Tiny85 and some resistors and solder.
|
# ? Jul 1, 2014 01:54 |
Can you connect the arduino via USB while it's running close to the dog bark detector? Being able to just stream serial data to your PC in real time makes it stupid easy to record timestamps for barks.
|
|
# ? Jul 1, 2014 08:49 |
|
Delta-Wye posted:Can you connect the arduino via USB while it's running close to the dog bark detector? Being able to just stream serial data to your PC in real time makes it stupid easy to record timestamps for barks. WiFi! You could even set it up to send a tweet every time the dog barks. #MyAnnoyoingNeighborsDogBarksALot is probably available... That would time/date stamp it too.
|
# ? Jul 1, 2014 12:03 |
|
sharkytm posted:WiFi! I was about to suggest to fire up an UDP packet using an ethernet or wifi shield, and setting up a listener in one of your home computers, but this tweet idea obviously overrides mine
|
# ? Jul 1, 2014 15:39 |
|
1QyZckj6w6gDCLj9H6z3 JZnnjXk8cqKZUt2Dz0WE dccolIhfcWV42sTxVpOq LqsEo3y6gyfq6JFlTfrc nSLaal6DbF574QpkT1z3 BokI1oAkneqoJCYgo8nM BLF2qeMr6D9U8aNYjPhc BEgh1iGlE7T4GqnVqC1p zz4e7RQtcZvUCCUJ9LIR wCcx4cDqcESJdmCIKSbm Plasmafountain fucked around with this message at 21:24 on Feb 28, 2023 |
# ? Jul 1, 2014 16:25 |
|
Delta-Wye posted:Can you connect the arduino via USB while it's running close to the dog bark detector? Being able to just stream serial data to your PC in real time makes it stupid easy to record timestamps for barks. I could put the Pi out there. The detector hangs in a tree about 20 feet from the house. Zero Gravitas posted:Delta's idea is the simplest and easiest. You would only need an arduino, a usb cable, a couple of soldered connections and a serial monitor recording program like Coolterm to record when the LED on your monitor goes high. I think this is the way for me to go. Hopefully I can get the Pi to monitor the arduino and record the barks that way. Then I can tweet, record, fire flare gun or whatever with the Pi.
|
# ? Jul 1, 2014 16:53 |
|
How are you collecting the IMU data? Seems like you could get away with using the USB as OTG and have the phone take the accel data instead of the other way around.
|
# ? Jul 1, 2014 16:54 |
|
I just got my first Arduino and I'm already completely stumped. I have an Arduino Yun and I want to hit a web resource and pull down a JSON feed to parse and then have some lights blink based on the data in the feed. I see that when I run a Process like "curl", the response is a stream of data. I know I can stream that data into the console via one of the IDE's built in examples. But I can't figure out how to get that stream into an object like a string or a dictionary that I can manipulate. If I try to save the stream to a string by appending each character, the output is truncated, which makes me think I might be hitting a memory limit. The file I'm grabbing is only about 3k. Here's the code from the "Process" example which shows how to run processes on the Linux side and stream the result back into your Sketch. This example only streams the output to the console: code:
I'm assuming because the stream is asynchronous and the call to print returns instantly: code:
code:
|
# ? Jul 2, 2014 03:46 |
|
The code in your Arduino sketch is going to run on the ATmega32u4 processor which is the tiny 8 bit microcontroller. Unfortunately there's only 2k of memory, so trying to save a 3k stream of data won't work and is likely why you see it getting cut off. What you probably want to do is run stuff like python scripts on the Linux processor. Have you connected to the Yun using SSH and played around in its Linux environment yet? If not ssh into it and start poking around Linux. You can write a python script that does all the heavy lifting of talking to web services, interpreting results, etc. Your Arduino sketch can use the process class to call python and pass the path to your script as the first argument so the script will be run. Anything your script prints out can be read by the sketch just like you're reading the output of curl. There is some learning curve and not as many tutorials/guides for the Yun unfortunately. A Pi isn't a bad place to start, although you'll still probably want to program the Pi with Python or a similar higher level language. The nice thing with the Pi is that there's no weird split between two processors, however there are also some downsides like no analog inputs or realtime control capabilities on the Pi.
|
# ? Jul 2, 2014 03:55 |
|
mod sassinator posted:The code in your Arduino sketch is going to run on the ATmega32u4 processor which is the tiny 8 bit microcontroller. Unfortunately there's only 2k of memory, so trying to save a 3k stream of data won't work and is likely why you see it getting cut off. Thanks for the help. I didn't realize how little memory was available on the non-linux side. I have definitely been poking around. I ssh'd in and have installed a bunch of Ruby packages. The Yun can execute basic Ruby scripts and I've figured out how to pass stuff between Sketches and my Ruby scripts. But anything not in the Ruby core library throws an error. So things like parsing JSON or doing fancy stuff with URIs in Ruby is not going to happen. I was attempting to pick up that slack with Ruby, but my hands are definitely tied without use of the Ruby standard library and Ruby gems. I know Ruby really well, but no Python. Looks like I have to learn some Python! No time like the present. :/
|
# ? Jul 2, 2014 04:11 |
|
I would check the Arduino Yun forums here to see what folks say about Ruby: http://forum.arduino.cc/index.php?board=93.0 You might be able to find a package that's been compiled and adds the libraries you need. I would also look at expanding the Yun's filesystem to use the full SD card so you can install a lot of stuff in the root filesystem: http://arduino.cc/en/Tutorial/ExpandingYunDiskSpace
|
# ? Jul 2, 2014 05:53 |
|
mod sassinator posted:I would check the Arduino Yun forums here to see what folks say about Ruby: http://forum.arduino.cc/index.php?board=93.0 You might be able to find a package that's been compiled and adds the libraries you need. I'll definitely do that. I need to get a micro sd card this week. Thanks for the link and all the help! After banging my head for hours and having the Arduino refuse to load any of Ruby's standard libraries, I decided a sanity check was in order. I factory resetted my Arduino Yun and methodically reinstalled all the Ruby packages on the OpenWRT side that were available using the package manager. After that, I was finally able to get a few things working properly - most importantly Ruby's net/http library. So I can finally make http requests on the Ruby side! I guess I'm putting off learning Python for at least another day. I'll check in with a progress update later this week. Thanks again! EDIT: Holy poo poo, Ruby gems seems to be working now too. This thing is going to be a lot of fun. plasticbugs fucked around with this message at 08:25 on Jul 2, 2014 |
# ? Jul 2, 2014 08:23 |
|
DRQM4YzwLA2hfjXwM4sS nWNmVgmYHIGOIFwr5AuU eDoJt7mYVyaNjAY8pXIo LlyF1BUsQLRqtxRdoKs2 q7rGYththE7WrHimkbyW s7hBDNGJmCq4HvPMgInI LYJv7f8aXudQxVJXFmPH XbfdBa4EUjLkxaSZgXzH jyEEkTs0gFsdxRRjXtyu ZBCCg3d1XSn1ot41nkvq Plasmafountain fucked around with this message at 21:24 on Feb 28, 2023 |
# ? Jul 2, 2014 17:43 |
|
|
# ? May 29, 2024 18:51 |
|
Zero Gravitas posted:IMU? OTG? Sorry. IMU = Inertial Measurement Unit, a 6dof accel/gyro sensor is the foundation for a real IMU. OTG = On The Go, an extension to the USB spec that allows peripheral devices to act as a host to a limited set of other peripherals. So my question was, how are you currently collecting the acceleration & gyroscope data? I'm imagining it's onto a PC over a serial connection. You were asking "how do I get GPS off of the phone?" and I'm supposing it's a bit of XYing with that line of thinking. You don't need the GPS data off the phone so much as you need the GPS and accel/gyro data together. With OTG, you could use the Arduino as a peripheral to your phone, get the accel/gyro data into the phone and do your correction/drift measurement there. That might be a bit of a stretch depending on your experience in other areas, but I wired up an Android handset to an Arduino as a proof of concept for a client. I think this is the guide I used. e: mixed up android/arduino, i didn't wire two androids together JawnV6 fucked around with this message at 22:02 on Jul 2, 2014 |
# ? Jul 2, 2014 17:56 |