fredag 23 september 2016

A slice of pi

I baked a pi with ruby:

()()()()()()
|\3.1415926|
|:\53589793|
\::\2384626|
 \::\433832|
  \::\79502|
   \::\8841|
    \::\971|
     \::\69|
      \::\3|
       \__\|

I did a codegolf the other day where the objective was to print out the above ASCII-art in the shortest amount of code possible. The code I came up with looks like this:
It is quite hard to read so here is a "ungolfed" version:
What I did was to create an array with the sub-sections of the pie and then traverse through that array and print out \\::\\n| where n is the current section of pi. For the bottom part I just printed out \\__\\|. I used rjust to get the pie to be right alligned.

Anyway, that's it for today. I've gotta go bake some raspberry pi, thanks for reading my post!

onsdag 21 september 2016

Introduction

My name is Linus Styrén and I am an upper secondary school student with an interest in electronics and computers. I like to share what I have learnt with others and try to challenge myself in order to become better. I think of myself as an enthusiast. I've built a few cool projects with electronics and programming. My favourite platforms are the Arduino and Raspberry Pi.

I have some experience with the Arduino UNO, I own one of them and I've built a few pretty neat projects using them. Here is a youtube video showing a basic RTTL player using an Arduino UNO:
I also own several RPis which I use for various projects, I've turned one into a basic home theater system. Also I've used three RPis for a more advanced bird feeder application (which has a website). This project was started in the autumn of 2014 and has been on continous development ever since on and off (I have not been working on it for a while however). I had a basic idea to create an autonomous bird feeder capable of recording videos of birds. It has expanded into a relatively complex proejct with time as it has been equipped with more and more peripherals and more functions has been implemented. Here is a photo of what it looks like:
My most recent project using a Raspberry Pi (and an ATtiny85 microcontroller) was a timelapse device running from a battery. It uses a RTC module so it can keep track of the time. It also has a builtin temperature sensor apparently so I use that to log the temperature for every picture which is captured. It runs on a 12V 4.5Ah battery and uses the microcontroller to toggle the battery on and off periodically every 5 minutes. I regulate the voltage down to 5V which powers RPi zero. The RPi captures a picture and writes that to the sdcard along with the current time and temperature. I've got it to draw extremely little power so the battery lasts for approximently 2 months straight.

I'm planning on writing an instructables for this project which hopefully will be released in the start of October. But as a sneak peek, here is what my timelapse project looks like as of right now (more pictures will be released in a later blogpost when I have made the instructables for the project):

Looks really aesthetically pleasing with the pink micro USB cable, doesn't it? :)

I also regularily participate in the Ludum Dare game jam competition. If you don't know what that is, you can read about it here. I use Unity3D for my games because that gives me a lot more time focusing on the actual game itself, and not so much on the game engine. Take a look at some of my games here. Or you can try my latest game for LD36 which I published on gamejolt.

Until next blogpost, have a good day!

tisdag 20 september 2016

Hello, World!

This is my first blogpost ever, so exciting! As a start here is how to print "Hello, World!" in various languages that I frequently code in :D


C says hello:

Python says hello:

Ruby says hello: