Adventures in C – A betting generator (take two)

Adventures in C – A betting generator (take two)

My Raspberry Pi powered betting generator hit a bit of a roadblock today. I found a batch of LCD1202 screens and wired one up to the Pi. I found a whole load of tutorials and set up guides for using this screen with a Raspi and python, but no matter how many I tried, I could not get the screen to display anything. The contrast was fine, sometimes it would display a random collection of characters but never what was being generated by the script.

On the second day of piscreen adventures, I learned how to SSH into the Raspi from my laptop because I was finding it difficult to type in code on the Raspi while reading the code on my laptop, the monitor I was using was small and blurry, it wasn’t a fun experience. Still accessing the pi remotely made me feel like some kind of hacker which kept me amused for longer than it should have. Needless to say though, eventually the persistent failure of the screen to play with the Raspi was making me particularly frustrated.

During my travels around the web I found a whole load of tutorials for Arduino too, so I dismantled the Pi and wired up the Arduino instead. Once I got the Arduino IDE installed I found the LiquidCrystal example and sent it to the board… guess what? it worked first time. The LCD screen mocked me with its Hello World and a number displaying how many seconds since the code ran.

Ok so at least we know the screen works.

But my bet generator is written in Python and I do not know C at all. In fact, I was so reluctant to try recreating it in C that I RETURNED TO THE PI.

My head is in my hands even now, wondering why on earth I wasted a further few hours trying to make the pi work.

Eventually, I gave up and decided it was time to at least investigate C. Starting with the standard Hello World and jumping right on up to creating a betting generator. I found a script for creating a random sentence generator and, I suppose, I hacked it 🙂 There was a lot of false starts and errors but eventually it compiled and ran.

The results of the bets are here:

And I’ve already assembled the Arduino, so now I just need to work out how to push the results to the LCD screen instead of the console.

Adventures in Python: A betting generator

Adventures in Python: A betting generator

This week, I was having a discussion with my other half about football and money and the subject came round to betting. Whenever he goes to the match his mates all chip in a few quid and they put a bet on. The bet is usually the final score AND either the first or last goal scorer. Needless to say they never win any money.

We realised that while it is possible to have small windfalls through betting, it is so random, and obviously so stacked against you, otherwise how would bookmakers earn a living, that the amount you have to spend cumulatively far outweighs the amount you might win.

We decided to make that money work for us instead – we will enjoy the excitement of a bet while saving money.

Uh-oh! I feel a maker project coming on… Introducing Ralph & Edna’s Fixed Odds Betting Shop (named after Edna Cross and Ralph Hardwick from Brookside – they loved having a cheeky little bet)!

Both of us will place a £10 bet on a randomly generated final score AND first or last goalscorer. If either of us win, we win £20. If we lose the money goes into a savings box. At the end of the football season we’ll use whatever we have to go on holiday or something. There’s still a small chance one of us will win some money each week, but the house definitely wins most of the time – just in our case the house is ours so we win either way!

The make

Ultimately I want to make a money box that represents the house/betting shop. But I want to include a button that, when pressed, will display the random bet each of us is making.

I’m imagining this will use a Raspberry Pi or Arduino (depending on what we have lying around the makerspace that I can test on) and a 16 character, 2 line LCD screen.

For now though I’ve created a python script that will generate the bet for me.

I initially followed a tutorial for a magic 8 ball (be careful though if you’re trying it – this code is for python 2 but my laptop uses python 3 so there are a few discrepancies in the tutorial namely raw_input has been replaced by input and print now requires parentheses)

I noticed the random module was appearing a lot in the various forums and comments so I had a read about that here

It took a few attempts but eventually I came up with a bit of code (see featured image) which, miraculously worked for me.

Here’s the bets it generated…

Now I just need to learn how to run it from a button press and output it to the LCD screen and I’ll have my bet generator gadget!

Adventures in coding

Adventures in coding

I’ve been learning to code, on and off, for several years. In the 13 years I spent as a web designer, I picked up a thing or two with regards fixing and tweaking code, but mainly just HTML and CSS and if the Instagram memes are anything to go by, they’re not considered coding by any real coders.

Still, I learned how to find bits of code and tweak them, but I couldn’t have built a website from scratch (I am a genius with WordPress though).

I signed up for all manner of online lessons. I tried Javascript, Python, Ruby… but in every course I would get to the same point and give up. I find it hard to follow courses, I tend to learn by doing. Having something I want to make and learning how to make it.

Two of the kids from the kids tech club I run entered the Big Bang NW competition and won a place in the final. Their project, The Kerbinator, aims to make the streets more accessible for wheel chair users by using crowdsourced data to locate drop kerbs/ramps, and adding them to a map so that wheelchair users can plan their routes to include the drop kerbs. It’s a fabulous idea. The plan was to build a gadget that would include a button, which when pressed would write the gps coordinates and upload them to a database which would then be added to the map.
Feedback from the judges at the Big Bang suggested that a mobile app would make it more easily distributed in terms of crowdsourcing and so we decided to work on that for the final.

So now I have a purpose for learning to code. Although we have roped in a volunteer expert programmer who is mentoring the kids, I at least now have a direction for my learning… as well as an expert to help me when I get stuck!

So you can follow my journey as I learn NodeJS and MongoDB… whatever they are!

A New Year, A New Me.

A New Year, A New Me.

We’re already 8 days into the new year but I finally know what I want to do differently this year:

I want to be visible.

I want to stop worrying about what other people think of me, to the point where I don’t raise my head above the parapet.

I want to share my knowledge and experiences with people without feeling self conscious.

I want to get rid of my imposter syndrome. I want to like myself. I want to enjoy the achievement and successes of my work and creativity. I want to not care if no one else likes me or my work.

I want to learn a new hobby to give me something to do other than wasting time on social media.

I want to widen my tech skills. I know I can learn and understand pretty much any software or hardware that I’m presented with, but I want to learn to code things from scratch. Coding could be a fall back option should I ever find myself seeking employment.

I want to talk more. Do assemblies, talks, presentations etc so that I get more comfortable speaking in public and improve my confidence generally in myself, my skills and my business.

I want to use my voice, my writing and any other skills I have to speak up for those who can’t speak up for themselves.

I want to talk about the things that rile me, I want to do something to make the bit of the world I live in better for those of us that live in it. I want to make a stand.

I want to get more politically active. I’ve been a member or the Labour Party for a few years now but I’ve never been actively involved. I live and work in the same CLP and if I want to start trying to make things better this seems like a good place to start.

I can’t make a difference in my community if I can’t be heard or if no one knows I exist.
So this year, I’m going to change my ways. No more hiding behind my computer and hoping for the best.

And if I remember, I’ll even try to document my progress!

Patience is a virtue

Patience is a virtue

I seem to recall hearing that when I was younger and rolling my eyes dramatically.

But today, in a world where everything happens at the touch of a button, maybe we could all do with strengthening our patience.

Gone are the days when you would wait 14 days for delivery, Amazon even has same day delivery on some items. Technology – and don’t get me wrong, I LOVE technology – has evolved so that all our gadgets are small and fast. We click a link and if it doesn’t open immediately we click it again, and again and then several times to demonstrate our annoyance that our computer isn’t fast enough today. Actually all we’re doing is giving the computer several duplicated commands to process, making it even slower and if we’d just exercised a little patience we’d be browsing the desired page already.

Most of us are pretty decent people, but we’re all guilty of being a little self centred. I mean I’m rather fond of saying I hate people. People ruin everything. But I’m a person, my family are people, my boyfriend, my business partner and my best friends are people and they’re all pretty awesome.

But sometimes, like when you’re driving to work and you’re late and you’re trying to get through that amber light before it turns red but the driver in front of you is slowing down you’ll no doubt fume and call them names. All they’re doing is being a good, safe, responsible driver and if you weren’t running late for work, you’d no doubt have done the same.

Sometimes we take risks and then get angry when the strangers around us don’t do their part to minimise the risk. Like stopping in a box junction and then causing an obstruction coz the queue of cars before us didn’t move before the lights changed. That’s on us, and shouting at people and getting angry with them is really unfair.

And don’t you find it just a bit exhausting? All that anger and aggression. Maybe we should all stop for a second to notice what’s happening around us, to see what others are doing, to take some time to just be in the moment while we’re waiting for something beyond our control to catch up.

Drink some coffee, eat a biscuit, read a book – one of those paper ones – Maybe start your journey earlier to account for those annoying slow drivers. And when you feel yourself getting angry and impatient, just stop and ask yourself why.

We can’t control everything. And trying to isn’t going to make us any happier. Is your life improved because you angrily overtook a learner driver and beat them to the red light? No it’s ridiculous and all the other road users thought you were a dick*.

We’ve all been that person. And we’ve all seen that person and raised an eyebrow and though “jeez, calm down.”

So let’s all just calm down. Next time you get impatient, or want to shout abuse at someone for unknowingly not behaving the way you wanted them to behave, just stop. Stop, and ask yourself, ‘does it really matter?’

And then enjoy those couple of moments of calm.

*OK I’ll admit it. This post was inspired by yet another impatient driver incident on my way to work.