Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Sunday, March 6, 2016

Small magnetic single throw double pole circuit

Back when I was a wee lass I saw Jurassic Park and knew then I wanted to get into computers so that I could create special effects. When I was a bit older we were visiting San Francisco and I went on an Aliens themed "3D" ride around Fisherman's Wharf (or maybe it was in Seattle?) Anyway, I remember being blown away by the experience of the seats moving and air hissing and decided I wanted to do computer stuff that would effect the real world. Fast forward a couple more years and I was at UW, majoring in Computer Engineering with a focus on embedded systems. Fast forward a few more after that and I'm a web dev tinkering with JavaScript... whoops. Might have miss-stepped somewhere along the way... but my love of computers is sound.

I have an inkling of knowledge on how to do things In The Real World but it's pretty weak. Turns out EE is hard and intimidating. But my interest remains strong. This, combined with my experiences doing several Escape Room games and the delight I had playing in a friend's Harry Potter puzzle LARP has lead me to the obvious conclusion that I should organize my own escape game.

Settling in to craft

Happily we got a lot of rain this weekend here in San Francisco. Not only does it help the drought problem, it allowed me to stay inside most of the weekend coding and crafting. And boy howdy is there a lot of coding and crafting to be done for this project.

A majority of the project is computer systems/pure code which I've been chipping away at, but some elements are hardware related and I've certainly been avoiding working on them. I enjoy it! But... it's hard. Thankfully I made actual progress on one portion but also wound up scrapping a different portion after repeated failure. Lets focus on the positive though!

If there's a chance you'll be playing in the game (you know who you might be, my so few Readers), I'd recommend not reading the rest of this post.

Not even half of what I needed Failed ideas

The goal: Have a surface that players can place an object on. The object has several magnets embedded in it, which activate switches below the surface when aligned correctly. The switches are attached to an Arduino which informs the computer, which informs the game server, which then has an effect on the game.

Turns out the end portion of it- the Arduino talking to the server is suuuuuper easy given the pySerial library. So the question here is about the circuit. Magnetic switches in a small space. Not difficult, right?

First attempt: run a wire to a bent paperclip, tape the wire to the hidden "floor" below, and use the wire as a hinge. Have the "surface" above be wrapped in tin foil and ground that. Now the wire runs to an Arduino pin in `INPUT_PULLUP` mode. Boom! Done! Success! When the magnet moves above the paperclip, the paperclip jumps up and grounds itself against the "surface" above and you've got a closed circuit!

Problem: There's only a couple pins on the Arduino and I'd like there be be a number of sensors so that different configurations can be recorded. That means each sensor circuit needs to ground 2 pins so I can have more unique combinations (That's multiplexing... right? Maybe?)

Next attempt: ... somehow close 2 circuits with a single paperclip's movement rather than just 1 circuit.

Problem(s): The paperclips I bent all had a single point of contact where the magnet was. The wire hinge was a bit too ridged/constricting to allow smaller pieces to rise and fall. I tried many different shapes and sizes and padding/fringe along the top of the paperclip that contacted the surface above. The signal was finicky, rarely closing both circuits.

Not really "success," but acceptable

eventually... "success!" (the signal is still a bit finicky, but good enough to go forward for now)

The solution? Have lots and lots of craft items laying around your house... No, really. The solution? conductive thread & copper tape

Conductive Thread : something needs to hold the paperclip to the "floor", allow it to pivot, and make sure it's connected to the circuit. Wire hinges were proving to be too ridged along with folded tape or aluminum foil. Enter the ever magical conductive thread. Taking two strands and tying them to the paper clip solved this problem. The clip was bent to be flat along the bottom, one strand tied to each corner, then the strands taped down with masking tape. It was a smooth hinge and a reliable connection. I wrapped the floor with aluminum foil and grounded it so that each paper clip is grounded via it's conductive thread tie downs.

Copper Tape : originally acquired for stained glass purposes, it's great. One side sticky, one side copper & conductive. Note that the sticky side is not conductive (sadly). I used this to mark out the traces on the bottom of the surface, where the paperclip would connect to. The tape is already pretty thin but I was able to cut it in half and place very close to each other- like laying out a sticker circuit board. I cut the paperclip to be U shaped, anchoring it to the floor at the bottom of the U. Now when the clip jumps up towards the magnet and closes the circuit, it has 2 little points contacting the 2 different traces (rather than one broad one).

Thursday, April 14, 2011

The Tichu Project

I'm a Java head. Love it. Love Java. It wasn't even the first language that I learned, but I still love it. I think it fits particularly well with my learning and thinking style... general concepts, without getting into the nitty-gritty of things (like C). There's some order to it though, variable typing is a must for me to feel comfortable.

The best part of Java is the JavaDoc though and the libraries... as someone who can't hold more then 2 digits in her head at a time, I adore the way I need not actually cache knowledge about Java in my memory. So while I consider myself "good" at Java, I could not recite near anything to you on demand...

But, anyway.... Java. Yeah. Awesome.

However, in the real world of life where one strives to impress others, knowing more then just one trick is good. So I decided I should learn Python. I'm using Flex at work so I've already started dipping my toe into the waters of insanity- AS3 is a bit too loosey-goosey scripting like for me. But I hear so many good things about Python. All the cool kids are doing it. As is Google App Engine.

App Engine apparently comes in two lovely flavors- Java and Python... and rather then go for the known tasty option, I'm taking the opportunity to broaden my pallet. Python it is.

It's not going that well so far though.

Fucking lack of typing... I forget what I pass around! If I'm picking up code tomorrow that I wrote yesterday, how am I supposed to remember what everything is?? Also, blah, the documentation on line.... maybe I have to learn to read it first... but right now? I think it's ugly.

App Engine on the other hand is looking pretty awesome so far. Yay.

Hence the Tichu Project... it always helps to have a *reason* to learn something new. So I'm trying to code up an online multi-player Tichu game. Never heard of it? Neither had I really... my artist friend Mel is making a themed deck of cards for the game and I thought it would help us both if they were put to use in a public place.

So... yeah... it's my first personal coding project in quite some time... wish me luck.