Are you a coder or white-hat hacker looking to make some money on the side? Bug bounty hunting might be the perfect gig for you. Tabtight professional, free when you need it, VPN service.
Protoboards Protoboards are essential, in various sizes. After using cheap Ebay imports, medium-grade produce, and fancy Adafruit protoboards I have to say that unless you never make mistakes, the pricier Adafruit boards are worth it for their durability and resistance to resoldering. Cheaper boards tend to start lifting traces if you have to resolder a pad more than once. You can cut proto boards on a bandsaw to make smaller ones. Keep a stack of them around; you'll always be needing another one.
MINI DEMO of USBcycle, EuroBike Simulator version ( ). This project is more about software than hardware; I didn't do any original electronic circuit design. I just put together a pile of off-the-shelf parts and then wrote the Arduino code to turn them into a USB game controller driven by a bicycle. The only cleverness here is in the code and the physical modifications to the bike (and even those are pretty crude). In this write up I'm using the quote format (immediately below) for asides, disclaimers, and game-specific notes rather than for quoting other people. The Project Hub doesn't offer us much flexibility in formatting, so I'm making the best of what is available.
Disclaimer: After I was almost done with editing this writeup I thought (rather belatedly) I should have a look around and check if anyone else was using the same name for a similar project. To my dismay I did find a 'USB Cycle' project, and their logo was embarrassingly similar to mine -- I guess geek minds think alike, ouch -- but I couldn't figure out what it was all about because I can't read Dutch. It was based in the Netherlands and looked kind of academic, with Powerpoint presentations and so on -- and it seemed to have no activity since early 2014. So I hope that it is dormant or completed, and that the Dutch team will not feel I'm infringing on their public image or trying to steal their street cred. I just want to say for the record that I have no connection with this other project of similar name, had no prior knowledge of its existence when I was building my USBcycle, and only discovered it after I had completed and named my project. The Dutch project seems to be called USB Cycle with a space, whereas mine is called USBcycle without a space.
If the USB Cycle team objects to my use of this name, or to my logo, I invite them to contact me; for courtesy's sake I'm willing to use one of the fallback names I came up with, even though these are not as good (so I'm hoping they don't contact me!) USBcycle. The problem with coastal BC (where I live) is that the winters are really long, dark, wet. Not conducive to healthy outdoor exercise. I get out of shape in the winter.
I used to be a pretty avid cyclist, but the weather plus our locally bike-unfriendly terrain have reduced me to a winter couch potato. Microsoft Frontpage 2007 Torrent Download. Well, computer potato really, I spend more time playing games or coding than watching TV. No problem, right?
Get an exercise bike! Low-impact indoor exercise, no rain, no mud, no traffic, what could be easier? The problem with exercise bikes is that they are Boring. I mean, Really Boring. It's hard (for me anyway) to get motivated to do something so insanely boring for even 10 minutes, let alone an hour or more.
But I can play immersive computer games for hours without getting bored. The obvious solution: equip the exercise bike with a video screen and tie it to some kind of interesting game-like software. It's such an obvious solution that quite a few people are working on it at present. Their projects run the gamut from fairly slick licensed training or exercise packages to garage-based Maker efforts.
I categorise them roughly into three flavours: • Advanced bike training simulators & stands (the kind serious professional racers use) offer race course simulations (of real-world courses that the cyclist is preparing for) complete with app-controlled resistance scaled to grade. Some high-tech trainer stands offer a flexible mount so the bike can lean a bit and feel more natural. But the,, and the. • In the world of academia and prototyping, there are some clever folks tying bikes to Google Earth; a is in progress.
That's a very cool project but seems a bit daunting to replicate at home. And frankly, google street view (in my experience) is more like a slide show than animation. • At the lower end of the market, the 'USB game controller bike' is; various creative geeks have come up with free or commercial ( pedal your way through infinitely generated terrain!).
Also, there are a handful of iThing/computer based offering virtual tracks/courses of varying complexity.. But it's not generic (it's tied to architecture-specific h/w interfaces and/or to proprietary games from the vendor). And it costs beaucoup bux Meanwhile, I have a good old MTB that I don't use much any more (getting too old to think that riding around in the rain and cold of a BC winter is fun). And I have a moderately beastly gaming computer (an i7 Hackintosh with a GTX 970, quite adequate as long as I stay in the 1080p world) and I have already paid the license fees for a -- one so likeable and fun that I've spent over 300 hours driving it. Sitting on my increasingly padded bum all winter driving a virtual truck all over Europe is not helping me stay in shape. But surely these three resources could be combined into a virtual biking setup, at a reasonable cost? So, early in 2017, I decided to see if I could turn an ordinary off-the-shelf bike into a USB game controller that would enable me to cycle, rather than drive, through the over 45,000 (virtual) km of European roadways in my favourite open-world sim.
It took about 4 months because I was really starting from scratch (had never built any homegrown electronics before, other than assembling computers from components, had only the vaguest idea of what an Arduino is), but in the end I succeeded -- and hope that others may decide to do likewise based on my experience. The end result: a generic bike-to-joystick controller (USBcycle), with a user control panel mounted on the handlebars. The user control panel includes a generous array of buttons (36 at last count!); I have customised my controller by mapping the buttons to commands specific to ETS2, and the final result is a virtual bike touring experience that I really enjoy, which should motivate me to exercise more regularly during the long BC winter. And I call it. Two Wheels Good! Euro Bike Simulator: Ingredients and Recipe Complete Ingredients List An Open World to Ride Through: • 1 copy of SCS' driving simulator, Euro Truck Simulator 2 (or American Truck Simulator).
This sim is available for OSX, SteamOS and Linux as well as Windows. It is available through Steam. The core game only costs $22 CDN but you will want the DLCs; the 'whole enchilada' from SCS is more like $60, and you can expand your open world for free with various community map mods. • plus: a simple mod to make the player's POV more like a cyclist's view of the road. I can provide this mod for you. Hardware to Run the Open World and Ride Through It: • 1 gaming computer capable of running ETS2 or ATS at a graphic quality that makes you happy • 1 Bike or Exercise Gizmo: 1 standard road bike, MTB, recumbent or whatever you've got lying around that has at least one drive wheel, a steering device, and a brake actuator. If your bike gizmo is a real bike then you'll need a training stand (doesn't have to be fancy, I got a cheapie off Ebay).
You could use a, but I think you'd lose the ability to steer using the bike handlebars -- I think twisting the bars when on a roller stand results in falling over, though I haven't verified this personally. • 1 Controller to make the Bike into a USBcycle: The USBcycle Controller: • 2 Arduino Leos • some hacked-together hardware to mount the sensors appropriately on the bike; not having a 3d printer I like to build stuff out of foamcore, doorskin, 1/4' ply, scrap wood, hot glue, closed-cell packing foam, velcro, electrician's tape, etc. • various long USB cables, long HDMI cable, long audio cable etc, to carry signals between computer and bike. You can use powered devices to extend these lengths to over 100 feet if need be.
I just kept the bike near the computer:-) • a few specialised (and more expensive) electronic components: one ams 5601 Hall rotary encoder on an I2C breakout board, Adafruit Trellis keypads (I2C again), Adafruit 7 segment display I2C backpack, WiiChuck (this is also I2C) for WASD version. • a bin of small generic (cheap) electronic components -- resistors, LEDs, capacitors, 7 seg displays, a linear pot, a knob, slide switches, reed switches, a Hall linear encoder (proximity sensor), pushbuttons, solderless prototyping breadboards, small prototyping PCBs, jumper wires, RJ45 connectors and cable, etc. • a project box with a user control panel, to be mounted on the bike handlebars. Fab one up or repurpose a jewellery box or some other box -- about the size of 2 stacked hardback books was comfortable for me, but I'm sure you could make it more compact. • the usual basic hand tools of the electronics trade, antistat mat, etc. Mostly, they don't have to be super expensive; but I do recommend you buy or borrow a decent soldering iron for the final assembly (and for building kit components such as Adafruit backpacks). A good iron can make all the difference between frustration (and possibly component damage) and success.
• possibly the most important resource for your project: the terrific Arduino community. The forum, the free libraries for almost every breakout board and device under the sun, the zillions of documented projects, the official online doco and tutorials: all this enabled me to go from 'what's an Arduino' to a working, fairly complex, project in under 6 months. Admittedly I have a background in both coding and electronics, but I think even an absolute n00b can succeed with Arduino because of the very high quality of support (both official and community). I guesstimate the total electronics cost to be under $250. I didn't really keep track because I was gearing up for Arduino hacking generally and bought way more parts than ever went into the USBcycle project. Lastly, when putting it all together for actual use, you need a screen in front of the bike to watch the world go by (at first I just stole the TV from the living room), and it's nice to hear the ambient sound effects if there are any, so: The Video and Audio Output • 1 large screen 1080p display to put in front of the bike • (luxury item) stereo speakers to enjoy game SFX while riding; or you could wear headphones.
------------------------------------------------------------------ The objectives: First milestone: build a simple WASD controller in which pedalling action determines speed and fwd/reverse. Steer by using a real mouse or emulating mouse movement. Use a portable stepper device as the pedal unit. This was Phase One: a feasibility study and prototype. If this worked out well, I planned to proceed to. Second milestone: Use a real bike instead of a stepper.
Instead of simple WASD keystrokes, emulate the accelerator/brake/steering control axes by instrumenting the bike. Steer using the handlebars, brake with the R-hand brake lever, and accelerate with pedalling speed. Make it feel (sorta) like riding a bike. Note that as of this version of USBcycle, I have not yet succeeded in getting any telemetry out of the game, so this is a zero-feedback system.
The controller cannot know (any more than my Driving Force GT controller knows) the truck speed or position. So it is a fairly dumb system at present. If I were a faster/better C coder, or could find a collaborator, telemetry would open up all kinds of possibilities (like a fan speed controller that would blow air on your face proportionate to your speed, maybe app-controlled resistance so hills are more realistic, etc). That would all be very nifty and is on my list of future projects.
The Development Kit: Arduino I was starting from zero here, never having done any microcontroller hobby stuff. I decided to use Arduino technology because it seemed popular, well-supported and user-friendly. So I would be using Arduino to build a device that emulates 2 USB HIDs: a keyboard and mouse device, and a joystick with 3 axes. This actually requires 2 'duinos because each one can only emulate one HID. UPDATE Dec 2017: I don't know why I was so sure of this HID limitation when I started the project. It turns out that one Leonardo can in fact emulate an arbitrary number of HIDs. Probably my app would not have fit in the available memory on one Leo, so my 2-Leo system might have been a good choice anyway; but I am now quite sure that you could fit the whole shebang on one Due.
I knew I needed to provide lots of buttons on a control panel to send keystrokes to the game (which uses a lot of single-key commands); also I needed a mouse equivalent for mouse functions (look-around, navigating menus), or perhaps I would map some other controller to send mouse events. And I needed to accept some inputs from sensors on the bike. Already it was obvious that the Phase Two version would involve a lot of I/O. The two Leos, between them, have to monitor all the pushbuttons, knobs and other user-input devices and translate them into game commands; monitor the sensors on the bike and translate their values into joystick axis values; and provide diagnostic and functional feedback by way of LEDs, segment displays, etc. As it turned out, I used almost every I/O port on both Leos, and I could have used a few more. Distributing the work between the two Leos took a bit of thinking and several iterations. The two Leos also had to talk to one another, another challenge!
Fortunately for me, other Arduino users have written many useful libraries including one that permits Arduinos to talk to each other over the IIC (I2C) bus. This handy bus was a bacon-saver for me. It requires only two wires/pins for communication, and many modern components are able to use it. Not only could I make the two Leos communicate over I2C, but where possible I used sensors and display devices that also 'speak' I2C, thus economising on Arduino I/O ports. For example, the Adafruit Trellis keypad gives me 16 buttons using only 4 wires (vdc, gnd, and I2C clk and data) each going to a common bus.
I needed 2 of these keypads for a total of 32 buttons -- I could never have fitted the whole application into two Leos without I2C. I used the standard Arduino development environment for OSX; I tried some other variants (Platformio, etc) but in the end found that the Arduino IDE was adequate when combined with external editing using vi when revision got serious. Revision control has been pretty sketchy so far, mostly achieved by renaming source files at various checkpoints (oh dear, cowboy coding); after achieving the second milestone I'm getting more serious about revision control and using git (locally) for tracking day to day development, and github for publishing. Other Software Aside from the 'duino code to run on Leo 1 and Leo 2, I needed to make a simple little mod for ETS2 that would move one of its cameras forward, to centre and down (to approximately a cyclist's head height) so that the truck is not visible (unless you turn your virtual head too far). This is not too difficult (and ETS2 modding is too large a topic to cover here); all you need to know for now is that this mod is available for download on github along with the duino source code.
I wanted the first releasable version to offer the user the option to play the game as normal (apart from using the bike for 3 axis control); but also to let the user conveniently use the game as a virtual 'bike touring' experience. That's why I need so many buttons on the control panel: unless you want a stock USB keyboard strapped to your handlebars (which is a legitimate option, I guess), you need a lot of buttons to control your Eurotruck (brakes, lights, trailer hitch, gear shift, camera selection, horn, etc etc). I also wanted higher-level button-press options like 'teleport me to the beginning of a particular scenic ride that I enjoy', 'set the warp speed of the game to a comfortable subjective bicycle-like speed at my preferred pedalling speed', 'make it tomorrow morning because I don't like to ride in the dark', 'make the other traffic go away', 'make the rain go away.' All these commands are avilable via the game's developer console, using keyboard input; given a Leo already acting as a keyboard for single-keystroke commands, I could execute these more complex commands with single button presses. I wanted the bike touring mode of EBS1 to present fewer trucklike features and more cyclist-pleasing fantasy, which meant a little more game tweaking. Fortunately ETS2 offers lots of user-settable options.
In the profile I use for bike touring I have turned off other traffic and all road laws; this means I can ride on the wrong side of the street, break speed limits, run red lights, etc., and there is no one else on the road. A cyclist's dream world! Most of these tweaks can be enabled and disabled without leaving the bike, but not all; some (like road laws and fatigue simulation) are only accessible via layers of in-game menus. To run the truck normally, in a fully-populated and law-abiding world, and pursue a standard campaign of freight pickups and deliveries, I would set up a second profile. I'm including the 'touring bike' profile in the distro at GitHub. I have biked it both ways. It's kind of fun to be an ultra high speed bike courier hauling cargo (even if the rear view mirror does show you a semi and trailer).
And it's (imho) even more fun to tour freely just for exercise and sight seeing. The world of ETS2 is well worth being a tourist in.
Project History (Skip this if you are not interested in the evolution of the project, but only in the finished product.) I knew nothing about Arduino, so I bought a starter kit complete with tutorial book, and did most of the exercises in the book (lighting LEDs, reading photosensors, the usual n00b stuff). I needed to get comfortable with my new toys. This took a couple of weeks. I ordered cheap components (resistors, capacitors, transistors, LEDs, reed switches, etc) from China on Ebay. This was not such a great idea as it turned out, because most of my stuff took over 90 days to arrive and I needed it long before that.
Be warned:-) I ended up buying some things over again in N America because my project would have stalled for months waiting for the cheap Ebay components. Be warned; don't buy anything from China on Ebay unless you are in no hurry for it. The first step was to fabricate a rough-n-ready rotor (a CD glued to a dowel axis), attach a neodymium magnet to its outer edge, whack together a crude stand for it to sit on, affix three reed switches to the stand (close enough to the CD that the magnet would trigger them), and monitor the reed switches with a Leo. Spinning the CD by hand, I refined the core code that would determine speed and direction of a rotor and smooth out jitters in the measured rpm. (Originally I thought the rotor would be the rear bike wheel, but in the final version it's the pedal assembly.). Very Primitive Rotor w/magnet and reed switch The next step was to attach and monitor some kind of user input device, and map its output into USB keyboard/mouse events.
I chose a WiiChuck, which is how I was introduced to I2C. Quite quickly, thanks to the excellent libraries available for Arduino, I was able to steer the mouse using the chuck joystick, and map chuck buttons to mouse buttons or to keystrokes.
I was quite impressed by then with Arduino -- the community, the hardware, the documentation, the software. I then built a very simple game controller prototype to drive a basic WASD adventure/shooter game. I used a portable stepper (exercise machine) which is just a pedal unit with adjustable resistance. I instrumented the pedal assembly with magnets and reed switches; the prototype code then correctly determined speed and direction of pedalling. Portable Stepper, magnet passing by reed switch as crank rotates I mapped speed and direction into WASD keystrokes, such that at low speed one revolution was one 'step' in the game (a tap of the W or S key), a moderate speed was walking (holding down a motion key), and a high speed was running (shift+motion key). I was able to navigate a mini world that I had built in Unity, and I could also navigate in Portal, Dear Esther, Timescape and other WASD games.
Sitting in a chair, with the WiiChuck in one hand, I could run, walk and jump while pedalling. This was the first project milestone. I then fired up ETS2 and tried driving the game by keyboard input via my Arduino (it was just one Leo at this point). Driving the truck by keyboard input is no fun, but I was able to pedal my way through Euro Truck land, steering by tilting the WiiChuck, braking with a WiiChuck button, and mousing with the WiiChuck joystick. It was an encouraging moment; the illusion of recumbent cycling was at times convincing, it was fun, and I now knew it would be well worth the effort and expense of building a more sophisticated controller. For a while I tried to keep both modes (WASD and bike) available, with the idea of having one controller box that could function in either mode -- with pedals+chuck OR with a real bike -- selectable by a switch.
This quickly led to cumbersome messy code, and later in the project I pruned all the old WASD code out and split it off into a different branch altogether. I plan to make a one-Leo WASD controller later on in a very compact package. The next challenge was to mount the bike on the trainer stand and instrument it. I bought a cheapish stand off Ebay, which turned out to be fairly well made and solid. Then came some head scratching. I needed to instrument three moving parts of the bike: pedalling, steering, and braking. I pursued some dead ends which needn't be detailed here; the final versions are as follows: pedalling: fabricate supports for reed switches to be triggered by neodymium magnet attached to pedal crank arm; wire reed switches to controller box mounted on bike handlebars (I used hardware from a clip-on bike basket that was already installed on the bike).
K'NEX test jig for Rotary Hall Encoder: the diametrically polarised neo magnet is in the green cup I attached the magnet to a bracket secured to the bike frame and allowed the chip, on its breakout board, to rotate with the handlebars. A little attention had to be paid to aligning the two properly to get a good continous range of values.
So I left a generous window and supported the magnet on a disc of clear plastic for easy positioning, to get it lined up with the rotational axis of the chip below. The rotary encoder breakout is an I2C device (hooray!) so I only had to run four wires to the control box (power, ground, 2 signal lines). Short Video of Breakout Board Rotating with Handlebars To provide a reasonably realistic feel when steering, and to prevent the bike from trying to lean or fall over (thus trying to deform or rack the trainer stand) when actively steering, I had to do a bit of engineering. At first I thought I would just put the front wheel on a sitting flat on the floor; but it quickly became obvious (as it should have been all along, doh!) that the axis of rotation of the handlebar/fork assembly is, ummm, hardly perpendicular to the floor. So a turntable sitting flat on the floor does not rotate in the correct plane. I ended up building an angled stand to support my basic 'lazy susan' turntable.
Angled stand supporting turntable for steering action I try to keep this stand positioned and oriented so that the axis of the fork assembly, if extended downwards, would intersect the stand more or less at the centre of the turntable. This means that the bike tyre actually contacts the stand a little lower down than the centre, but it all seems to work OK; initial motion turns the turntable, giving a soft easy feel, and more extreme steering scrubs the tyre on the turntable surface (notice the scrub marks). The geometry is good enough that the bike does not try to lean during steering, so no torque stress is placed on the trainer stand. It doesn't feel quite natural to steer without leaning, but it will do for now (trainer stands that accommodate leaning are more expensive).
This front wheel support does, over time, try to 'walk away' from the bike (forward, that is); I've installed eye screws on it with the intention of chaining it to the front legs of the trainer stand. Braking: I am indebted to another bike hacker whose URL I have unfortunately lost, someone who was working on brake sensing for his road bike. I had been scratching my head trying to figure out how to attach encoders to the brake lever mechanism (flex sensor strips? Another hall rotary? Some kind of pantograph linkage turning a conventional pot?) but his solution was far more elegant. I found and purchased a handful of stainless slotted cross clamps (these are not easy to find; I bought mine ) and attached a neo magnet to one of them; this magnet is then clamped onto the brake cable where it passes along the underside of the top bar of the frame. Magnet and Hall Effect Proximity Sensor A Hall effect linear encoder (proximity detector) is mounted so that as the brake lever is pulled, the magnet approaches the sensor.
By adjusting the sensor & magnet mounting locations I could take advantage of the maximum range of values, i.e. Almost kiss the sensor at maximum brake pull. This sensor was a cheapie out of one of those Chinese 'Arduino inventor kits' (I name no names) and I am not too happy with it; it is unbelievably noisy, but good enough for now. This provides not just a simple 'brake on/off' but 'amount of brake pedal applied' -- I can brake lightly or hard, just as I would with my Driving Force GT setup. So now I have three sensors on the bike.
The 'duino code on the Leos translates these raw sensor values into a valid range for each of the three controller axes. Thanks to the nifty, feature-rich Joystick library by Matthew Hieronimus, it was a piece of cake to go from raw sensors to HID axes. I highly recommend the app (for OSX) which is very helpful in debugging and sanity-checking. Mouse: What about looking around while riding, and interacting with in-game menus? I was using a WiiChuck when I was sitting in a chair pedalling the portable stepper, but now that I'm on the bike it's harder to use a mouse-equivalent. The WiiChuck is right out, as are other hand-held mouse gizmos, because you need to keep both hands on the bars.
I'm using my right hand for braking so any mousing device has to be mounted where my left hand can reach it, and it has to be very small. There's a real shortage of micro trackball devices on the market today, as I was frustrated to discover. In the end I managed to mount a mini Ergo touch pad on a piece of doorskin velcro'd to the left-hand brake lever (only the right-hand brake lever is used in USBcycle for the brake axis). This is not the perfect solution (no middle button, for a start), but I can use it to look around in the game and to select options from in-game menus. Desperation Mouse: Ergo Touchpad on L-hand brake lever With joystick axes and mousing all implemented, another milestone was reached when one evening I could get on the bike and ride through Euro Truck land. On my own familiar MTB! It felt surprisingly realistic.
I was chuffed. I had to do a little tuning of the steering value map (degrees of rotation dectected: percentage of joystick axis range), but other than that it was immediately ride-able.
Meanwhile, the actual physical layout of the duinos and their associated wiring, LEDs, etc. Was getting beyond messy. Here's a quick evolutionary sequence from the very beginning to the out-of-control final bench prototype. And were fruitful and multiplied. I think this is getting out of hand.
I was using solderless proto boards, an old Electronics Educational Kit from the 80s, any old cables I could find lying around, and there was a sprawling snake's nest next to my computer. What I wanted was a smallish box that would have lights and switches and buttons and stuff on its top panel, with the Leos inside and nice neat modular cables going to the remote sensors; it should be small enough to mount on the bike handlebars, yet big enough to accommodate all the lights and buttons required. And it was time to face the problem of those pushbuttons -- I required so many, and I was out of I/O pins. I had a working system, it was ride-able and fun -- and now I had to rip it all apart and rebuild it in some kind of Package. And I had to design a front panel.
And make sure it all would fit within my I/O port budget. And would not take weeks to fab.
This was one of the most vexing and discouraging phases of the project. I went through a lot of front panel layouts, a long series of paper drawings and scribbles, and am still not really happy with the current version. As mentioned earlier, in order to economise on ports I used two of Adafruit's 'Trellis' switch matrix devices (I2C a.