pomeroyb / PortalGun

Code to control a Portal Gun (From Rick and Morty)
32 stars 19 forks source link

Code problem #4

Open carter1055 opened 7 years ago

carter1055 commented 7 years ago

I need help! I bought all the proper hardware and I am having issues with the switch. I am using all the right pin definitions, but the button side of the switch is not working. The rotary side is working just fine, but when I push in the encoder, nothing happens. I just bought brand new hardware and would like to resolve this issue before I start to solder anything. I would appreciate any feedback. Thanks!

pomeroyb commented 7 years ago

For some reason I didn't get a notification that this issue was here, sorry about the slow response time!

First thing to check would be if your button actually works -- you may have gotten a bad encoder. Check that the Button and GND pin are connected when the button is pressed by using a multimeter.

If the button works, double check your solder joints -- a bad joint can lead to no connection.

If neither of those options work, try switch the button pin in the code to a different pin and connect to that. You may have a bad trinket that has a bum pin.

Good luck!

carter1055 commented 7 years ago

Thanks for getting back to me! I think I have found the problem. I am almost positive that all my electronics are in working order. So I thought that maybe the code was the problem. So I went through the entire code and it seemed good( I made some additions to it to fit my liking, but nothing big) Then I thought that I was having trouble uploading the code from my computer to the trinket pro. ( I tried the trinket pro and an arduino with the rest of my hardware but they both had the same issue) So I thought it was maybe the USB port. My computer has 6 USB ports, two on the front and 4 on the back. I tried all of them, but the results were strange. The back 4 resulted in the same switch issue, but the front two resulted in the display displaying a group of random numbers with the switch being completely unresponsive. So maybe it's my computer. Can I ask what type of computer you used to upload the code to your trinket pro? Yesterday, I attempted to download arduino IDE on my laptop. Maybe I'll have better luck on that. Thanks for helping!

pomeroyb commented 7 years ago

I just used a windows 7 laptop. I'd suggest double checking the Adafruit guide to setting up the IDE for the trinket, and making sure that you've selected the correct trinket pro board (3v vs 5v) and bootloader. If it works on your laptop, you may also have to reinstall the drivers on your desktop PC!

carter1055 commented 7 years ago

Ok, I was successful in downloading all the proper drivers and libraries. But when I try to upload to my trinket pro, I get this error message: Arduino: 1.8.1 (Windows 10), Board: "Pro Trinket 5V/16MHz (USB)"

C:\Users\Owner\Documents\Arduino\portal_gun\portal_gun.ino:32:22: fatal error: TimerOne.h: No such file or directory

include

                  ^

compilation terminated.

Multiple libraries were found for "Wire.h" Used: C:\Users\Owner\AppData\Local\Arduino15\packages\adafruit\hardware\avr\1.4.9\libraries\Wire Not used: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire exit status 1 Error compiling for board Pro Trinket 5V/16MHz (USB).

This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

I got this error message before on my desktop computer when I was trying to set this up. I'm probably missing something obvious. Like something to do with the bootloader. But I'm afraid to proceed any further in fear that I might mess something else up.

pomeroyb commented 7 years ago

Try downloading Arduino 1.6.4 from adafruit:

https://learn.adafruit.com/adafruit-arduino-ide-setup/arduino-1-dot-6-x-ide

I'd just use the pre configured installer to eliminate any variables. It's hard to tell from your log files, but it looks like you are using Arduino 1.81, but 1.5 libraries. I not super familiar with the inner workings of the Arduino ide, so hopefully this helps!

carter1055 commented 7 years ago

I downloaded an earlier version of arduino IDE (1.6.8) and verified the code. It still has the same switch issue when I upload it. I'm at a lost. I don't know what I'm doing wrong. Have any more tips?

pomeroyb commented 7 years ago

For some reason I keep missing these notifications, sorry about that!

Are you still getting any errors when you compile? If it compiles without error and uploads then your issue must be either on the microcontroller pin or the button itself. Try changing the pin number for the button in the code to an unused pin, and adjust the wiring accordingly.

If you are still getting errors but can upload, please enable verbose output in File -> Preferences, and paste the entire error output here. Hopefully we can see something we missed before!

carter1055 commented 7 years ago

I got arduino 1.6.4 on my desktop computer, and it seems to work better than my laptop. The sketch verifies right away, but when I upload it, another error comes up. As for the switch, I have two different rotary switches I have used. One is the one from adafruit, and the other is one I bought off of amazon. It's blue instead of green but the layout is exsactly the same. They both have the same effect when I plug them in. And I have tried to change the button pin before. A2 to A3. Same effect. I'm kind of getting sick of this project and would like to resolve it soon. Hopefully we can fugue this out!

pomeroyb commented 7 years ago

I'm pretty stumped, to be honest... could you copy and paste the error you get when uploading?

carter1055 commented 7 years ago

Sketch uses 7,194 bytes (25%) of program storage space. Maximum is 28,672 bytes. Global variables use 277 bytes of dynamic memory. <This is the verification) _avrdude: usbdevopen(): did not find any USB device "usb" <Its for some reason not finding the USB now. This should be an easy fix but I have a feeling I will run into the same issue even if I do upload it. But we'll see.

pomeroyb commented 7 years ago

Alright after re reading your comments and looking over my code and wiring again, I've got something that might help. Try adding the following code to the start of the setup() loop

''' pinMode(encoderButtonPin, INPUT_PULLUP); // sets the digital pin as an input with the internal pull-up resistor '''

I realized that the circuit is in a floating state, and that, while it may work for my device, it may be the issue on your end.

If this still doesn't work, then I am unfortunately at a loss... so fingers crossed!

carter1055 commented 7 years ago

It didn't work. Sorry it took so long to get back to you! I don't know what I'm doing wrong. A detailed set of instructions on how you downloaded everything would be nice. But I wouldn't want to inconvenience you. I guess I'll put this project on hold for now. If you find anything else out make sure to keep me posted. Well, I guess that's it. Thanks for all your help!

Chromewrecker commented 7 years ago

Did you ever figure out the error in haveing the same issue can't seem to get past it I have tried it in the 1.6.4 and the 1.6.9

meridoch commented 6 years ago

I'm having the same TimerOne issue too. Any ideas?