Thursday, February 13, 2014

Ba Ba Dum review

A new language learning website has come out, called Ba Ba Dum (build 128, version 1.1.1).  This is my review.

tl dr; don't use it for learning languages where the gender of the words matter - like in German.

I first heard about the website through some UI/UX/js/css/web people (thanks Leigh and Paul!).  Not only is this interesting to me from a web app perspective (that's what I do for my day job), but I'm also very interested in making games, as well as learning languages.  So, naturally I checked it out.

It's a great start, and very well made!  Not only did they draw all the illustrations, but made the fonts!  It's also, I think, a great example of content marketing, ie making something useful for people showing off your skills.  This project shows that these people can produce a quality product (see making of, and the credits).  Reviewing a project fairly without knowing the brief is always impossible.  So I'm reviewing it based on what I see of the product.  I'm not taking into account the timeline, the amount of resources available, demands from clients, or reviewing it based on if this is just a marketing device.

What's it like for learning?

The major problem with it, for learning German(also French...) is that it doesn't have the gender or articles for the words (der, die, das).  Whilst it should be easy for them to add the articles as text, it would not be so easy to do for the voices.  Also, it only has a man's voice.  Women's voices are different compared to men's voices, and the way you say words can matter.  More so in some languages than others (eg, Japanese!).  I have a male friend who learnt Japanese mainly from women, and then had some funny reactions from the people who he talked with.  Not to mention a lack of accents or dialects.  Scottish people sound quite a lot different to someone from the south of England, or compared to a Texan, or someone from the outback of northern Australia.  Most German language teachers recommend learning the words with articles included.  So, at the moment it would be damaging to use this for learning some languages, rather than helpful.

Not including articles may have been a conscious design decision, a lack of resources, or a failing to get the language experts in at the early design stages, or listening to them in the QA stages.  I'm not sure.  It will be interesting to see if they justify this design decision, or act on the feedback.

This app does cover nine languages, and for some of them, this doesn't matter so much.

What about the UI?  How is it?

It does responsive!  Ya!  Well, sort of.  It is responsive to screen size.  Their graphics scale very nicely, and their design changes to best make use of available space.  However, it's not responsive to a lack of internet (offline first!).  Note, that the games will keep working if you load the game whilst you have internet.  So I commend them for that.  It's just you can't load the game if you don't have it already open.  I didn't try it on a 3G/2G connection, so I can't say for certain if it works well there or not.  It's quite media rich, with all the gaphics, sounds, and fonts.  So it may be a bit big for slow mobile connections.  Using it on a train, with a spotty connection, would probably make you cry.

As a single page app, they have URLs that work.  Well done.  I can switch to game three in German language, and then share that URL with people, or bookmark it.  It's not the prettiest of URL designs, with just query strings, rather than human readable words... but they are short, and they exist!  Which can't be said for every single page web app.

The two main UI problems are a lack of keyboard support, and hiding content.  As can be seen on the stats page: http://babadum.com/stats/ most people don't discover the other games.  Hiding content seems to be the latest design trend failing.  Sure, keep your interface less cluttered, but your design flows still need to let people discover other parts of your app.  Why bother making those other games if you're not going to show them to 80% of your viewers?

The games themselves?

For learning most languages there are four games. Plus one app just for Japanese.  They try to teach you different aspects of learning words.  They are
  • selecting the correct picture for a written word, and a spoken word.
  • multiple choice selecting of the written word, after being shown the picture.
  • spelling the word, after being shown the picture and hearing the word.
  • listening to the audio, and a multiple choice selection of the correct picture.
The first of the five games shows you a word, and four illustrations, whilst a human speaks it out loud.  Some apps use a robot voice, which might be nice if you are talking to robots. So the human voices are appreciated, since most people want to talk to humans.  You have to select the right picture, and you get a point for selecting correctly.  There are nice animations, sounds and transitions between the selections.  You get a thumbs down, and lose a point if you make a mistake.

The second game shows you one picture, and presents you with four words to guess from.  Once you select the word, the voice speaks it out aloud.  Again, you get a point if correct, lose a point if wrong.

In the next one you have to spell out the words.  You're given all the letters, and you have to place them.  Like the other two games, if you get it wrong you lose a point.  By this stage, I was getting a bit bored with the scoring mechanic.  But the third game does help you spell.  But you have to spell with the mouse... which is a bit weird.

The fourth game tests your hearing and comprehension by playing the sound for the word, and asking you to chose the correct picture.  You get scored in the same way, as in the other four games.

With the fifth game we have something a little bit different. The fifth game is about learning the katakana for Japanese.  Not so useful if you're learning one of the other languages.  You can probably guess how scoring happens.

I love internet points as much as the next person... but I don't find the scoring in these games interesting.  What can I do with these internet points?  Nothing it seems.  Even if my points drop to zero, nothing happens.  Maybe other people will like these internet points, but I have no use for them.

From a social game perspective... unfortunately there's no online high scores, or other social interaction I could see.  It would be great to be able to brag if I level up, or achieve a great score.  I'd urge the game designers to read some game design literature on rewarding players.

Speaking of levels, the game design does not give the player a sense of progression through the games.  Whilst playing, a person will be asking themselves: "Am I near the end of the level, or mid way through?  Are there even levels?"  For educational games, it's good to ask yourself "If this wasn't for learning language, would I play it for very long?".  Is this game fun without the motivation to learn a language?  The presentation is pretty good, but I'm not sure how many people would play these games without a motivation to learn.

What other apps do it better?

The learn like kids apps ( http://www.learnlikekids.com/ ) are probably the best apps available for this style of learning(not using the native language with pictures).  They are not free, but costing 1.89 for approximately 3 months of lessons isn't bad.  They have male and female speakers, and also say not only words, but sentences at different speeds.  Also, they are separated into lessons, because learning a basic set of words can be used to then construct more complex sentences later on.  As well, it uses other proven teaching techniques like spaced repetition, choosing topics which are relevant to many people, and selecting phrases to learn based on frequency of usage.

Although a very similar app, the Ba Ba Dum designers could learn some more from the learn like kids apps.  People wanting to learn a language from a similar, but better app, should check it out too.

In conclusion.

It's a good start, and they do many parts of it well.  However, until they fix up the lack of articles, language learners should avoid it (but not for all languages!).  Even though it's free, until they fix that one problem, I'd still say don't use this app.  From an accessibility perspective, the lack of keyboard support is most annoying.  It's not really usable for people who are mobile, as opposed to people sitting in an office or at home using a mobile device.  The games don't really stand by themselves as fun games outside of a learning context, but with improvements would be useful for learning.  Obviously, you couldn't learn a language with just this website.  There are too many things it doesn't teach.  I look forward to following their developments though, as it has potential to be a useful learning tool when used with other learning methods.




I'm blogging various techniques I have used to learn German under the German and Deutsch labels.

Tuesday, February 11, 2014

Learning German faster

(NOTE: this article is a work in progress, as I try and gather references and evidence for all the claims made in the video.  Please feel free to comment if you have any relevant links)

In this video Chris Lonsdale does a talk about principles and actions that can speed up language learning.  I think it's very interesting, and useful... but I'm always sceptical.  Learning how to learn is important, and this video attempts to share some effective techniques for learning, and the principles behind them.



The arguments used in the video are not referenced to academic standards since it is a very short talk - and not an essay.  However the presentation is convincing, and it does cover a number of pieces of advice I've read in other places.  I'm going to try and provide links to further reading on each of the techniques and pieces of advice listed.


What doesn't work?

He mentions some things that don't work.
  • Talent.
  • Immersion.

Talent is needed.

Citations needed.

He addresses an apparently common myth, that some people don't have a talent for learning languages.  He gives some anecdotal evidence of a woman who tried to learn Dutch in Holland, and was told she had no talent learning the language after failing to learn it after much study.  Then she changed her approach to learning in Brazil learning Portuguese and was able to learn it to a fluent level quite quickly.  If natural talent exists is a widely debated area of discussion... however if you think of talent as a skill, then obviously people can learn skills.  Not everyone can learn every skill they try to, but many can.  He gives another example of learning to draw in 5 days.  He chose this skill, as drawing is another skill that many people struggle with.

There is a good discussion on the topic of talent and language learning here: http://www.lingq.com/forum/4/14429/

In conclusion, I agree that most people can learn another language.  I still need to find references for this claim.

Immersion is needed.

Citations needed.

He argues that being immersed in a country where they speak the language won't necessarily mean you'll learn the language just from this.  He provides anecdotal evidence of people living in Hong Kong for 10 years, but not being able to speak Chinese.  I've seen this myself with a number of people living in expat circles, living in cities with a large percentage of English speakers.  It definitely does help that you can go outside, and strike up a conversation with someone in the language you are going to learn.  However, you can do that with online tools these days too (skype, hangouts etc). However, people can always get by without knowing a language very well.  If you can make enough English speaking friends, and do most things in your life with English, then that doesn't provide you with as much motivation to learn.  But not everyone is content with just getting by, and not being able to talk to people.

The people I know who moved to small villages and learnt a language there, where minimal others knew their language seemed to do better.  One man went to a small Chinese village, and the other went to a small village in Japan.  However, they both put in a lot of effort learning.  Perhaps it was the necessity, or need to learn which helped with their motivation.  I know countless people who live in a larger city but didn't learn the language however.

In conclusion, I agree that immersion can't guarantee good results, but it can be useful.  Just don't rely on it.

Principle #1.  Focus on language content that is relevant to you.

Citations needed.

Any information that is related to your own personal goals and survival has relevance, and you will pay attention to it.

We learn tools the fastest when they are relevant to us.  You have a project due to be complete in a language, then you will try to learn harder in order to complete the project.

He says there is a strong link between these things, and that each of them is related to each other:
  • Meaning
  • Relevance
  • Attention
  • Memory
From learning other topics and skills, I know this helps me.  But does it work with learning languages? Also, is there evidence to support the claim?

In the Duolingo Effectiveness report (pdf), the authors say
"their motivation;  with people who studied Spanish to travel having the biggest improvement.  People who studied mainly for personal interest and school had more modest improvement."
Which goes some way to backing up this principle with evidence.  However, in their report they say this only applies to learning Spanish.

Principle #2. Use your New Language as a Tool to Communicate... From Day 1.

Citations needed.

As a child does.

Principle #3. When you first understand the message, you will unconsciously Acquire the Language.

Citations needed.

It is called "Comprehensible input".

Here are two links for further reading on this subject.

Principle #4. Physiological training.

Citations needed.

Language learning is not about collecting lots of knowledge.

Hearing the sounds takes training.  Like learning how to hear pitch, and music.

Practising speaking helps with the mouth muscles.

The topic of perceptual learning is an area with a lot of research that relates to this.  Being able to perceive the different sounds is a skill that can be learned.

http://en.wikipedia.org/wiki/Perceptual_learning

Principle #5.  Psycho-physiological state matters!

Citations needed.

Happy, relaxed, curious and tolerant of ambiguity.


Action #1. Listen a lot!

More Citations needed.

In order to get the rhythms, to recognise the patterns extensive listening helps.

In the essay Extensive or Repeated Listening? A comparison of their effects on the use of listening strategies the authors claim that listening to things repeatedly was more effective than extensive listening.

Language Learning Tips: Extensive and Repeated Listening suggests methods for doing repeated listening and extensive listening.

In an article called Passing learning, the author shares his experiments with passive listening and how he went in his listening exam.  He did poorly after listening for thousands of hours of radio programs.  He also asks a number of other people about their results with passive listening.

In my own experiences, listening to how people say words is very useful, especially if you need to do something with what they are saying.  Like if you don't understand the announcements of a train delay, you might stand around for an extra hour... so you better try harder to comprehend it!

From these references, I'm fairly convinced that passive listening of extensive amounts of audio will not help you that much.  However, listening(and watching) actual people, and repeated listening will help.  I'm also fairly convinced that actively listening, and doing something with what you hear will help.

Action #2. Focus on getting the meaning first (before the words).

Citations needed.

By using body language you can understand a lot of communication, and then by seeing the words used with the body language you are learning by comprehensible input.

You can use words you already know.  Many languages borrow words from each other.  German and English share a great many words.

So between the body language, the context of the situation, and words you already know, you have a good chance of knowing the meaning.

Action #3. Start Mixing.

Citation needed.

Start creatively mixing the words you know, without worrying too much about correctness.

He says, if you know 10 Verbs X 10 Nouns X 10 Adjectives == you can say 1000 possible phrases.


Action #4. Focus on the core.

Citation needed.

Some words are used more than others.  In English 3000 words gives you 98% of the words used in daily communication.  So if you direct your study to the words used most frequently in areas that you are interested in you will have more coverage.

How do you say?
What is this?
I don't understand.

Simple pronouns, nouns, verbs, adjectives.

Glue words.


Action #5.  Get a language parent.

Citation needed.

A supportive person who you can learn things with in a safe space.

Comprehensible input environment that is safe.

Spouses not very good.

Works hard to know what you mean.
Does not correct mistakes.
Confirms understanding by using correct language.
Uses words the learner knows.


Action #6.  Copy the face.

Citations needed.

Copy people.  Copy the shapes and sounds people make, so you can mimic them.

Say it out loud and hear how it feels, and feel how it sounds.

He gives the advice of watching people speak.  However, I can have trouble seeing what people are doing inside their mouths whilst making sounds.  So, just watching people talk seems limited to me.  Asking how people make the sounds can be more useful.

Action #7. "Direct connect" to mental images.

Citations needed.

Link up sounds and words to the images your already have in your mind.

So far, I'm having trouble finding references or evidence for this.  So, at this moment I'm highly sceptical of this claim.



I'm blogging various techniques I have used to learn German under the German and Deutsch labels.

Monday, February 03, 2014

Welcome to your new NSA partner network. Tech art in Berlin.


Whilst walking around the Afterglow art hack day opening in Berlin, my phone buzzed as I had received a text message.  Opening up my phone I saw this:

"Welcome to your new NSA partner network."

I immediately had a scary thought.  "Had someone hacked into my phone?"

My next thought was "oh, someone is hacking the mobile networks".  "Damn, I forgot to turn my phone off like I usually do before coming to hacker events".

My phone didn't have service to either of the networks it usually connects to, so someone was definitely jamming the phone systems.

This message was a very impressive piece of tech art indeed.  It made me think, and feel something.




We are starting an EU/UK tech online magazine. Want to know when it is released?
Email



Rest your head against the speaker.
Part of the art hack day.

"The revolution is over. Welcome to the afterglow." reads the opening line to the transmedial festival in Berlin.

The transmedial festival brought back Cyber punk type thoughts from the last 15-20 years or so.  Now that the digital revolution is over, and "The future is now", and that 2020 is just around the corner... what next?

The afterglow.

"What is next" is a question lots of people in tech are always pontificating about, but perhaps not in the context of the time known historically as the information revolution.

Despite all that lofty talk, and a long speech on this topic, the event was a lot of fun.  Especially the art hack day parts.  Lots of people were there interacting with various art works people had made.


Some sort of eletronic alchemy going on here
"Art Hack Day as a grassroots event/exhibit format/community for artists whose medium is tech and hackers whose medium is art."


Over 80 artist hackers were invited to create the exhibit from scratch in 48 hours.  What they came up with was quite often fun and impressive.

Stamps combine to make prints.


Knowing the design brief for these pieces can give you a better appreciation of what went into the thought process.  Here is the brief the creators were given:
As coders we fear the ‘legacy’ system, a piece of old junk we haven’t yet figured out how to throw away. As artists, we’re tempted by prolific outbursts of freshness and novelty; more art of less value. Businesses and government crave more data, more connections, more context. By embracing these impulses without contemplation we perpetuate the technological hype cycle and unintentionally shorten the half-life of our artefacts. Technology has become akin to a natural resource, generating physical and immaterial waste that is appropriated in such diverse contexts as e-garbage dumps, big data businesses and mass surveillance schemes. As such, trash is no longer what is just left behind but is central to our post-digital lives. When digital detritus piles up it decomposes, giving rise to a post-digital afterglow with the potential for new expression and new enterprise. Can we make peace with our excessive data flows and their inevitable obsolescence? Can we find nourishment in waste, overflow and excess? Can the afterglow of perpetual decay illuminate us?

This honey pot exhibit was one of my favourites.  If you look closely you can see a phone in there tempting passers by...

Honey pot.  With actual honey. With phones in the honey.

Below are a selection of short video clips showing some of the other exhibits in motion.






The tower of beer was one of my favourites.  Not just because it had beer cans in it, but because of the great video effect it had when filmed.




The augmented reality of this tablet swinging from a rope was popular.  Point it at the picture of a rubbish bin painted on the wall, and the video will show rubbish flowing out of the wall.






Not only is the Afterglow happening for the digital revolution, but also for the revolution in Berlin.  After the Berlin wall fell, many artists entered the city from around the world.  It is currently undergoing another revolution of sorts, with many tech companies growing from within Berlin, and also moving to Berlin.  However, tech in Berlin has been around for a long time.  From groups like the Chaos Computer Club (europe's largest association of hackers), to the Z3 (world's first working programmable, fully automatic digital computer), Berlin has a very old historical involvement with technology.  The other revolution in tech that is going on is citizens fighting back against surveillance of the state and corporations.  So maybe we are not finished with the digital revolution, and perhaps it will cycle, one more time, towards a future.  But which future?



We are starting an EU/UK tech online magazine. Want to know when it is released?
Email

Thursday, January 30, 2014

redmine, Bad Gateway error, file upload max size

Redmine and other ruby on rails apps can have issues with large file uploads or file uploads with a slow internet connection.

In redmine you may get the dreaded 502 Bad Gateway error showing up in the user interface.

Here are the pieces: Apache, unicorn, rails, and redmine.

Short version is you need to set the timeout config variable to something higher... like perhaps 120 seconds.  It's not the best solution, but it will let you upload files.

Here is a blog post which describes unicorn.rb configuration.

There's a setting in the redmine administration section of the tool to increase the maximum file size if you need to do that.

You may find apache error log entries like this:
[Thu Jan 30 11:11:08 2014] [error] (103)Software caused connection abort: proxy: pass request body failed to 127.0.0.1:7000 (localhost)
[Thu Jan 30 11:11:08 2014] [error] proxy: pass request body failed to 127.0.0.1:7000 (localhost) from 1x.1x.1x.1x ()

Also, you may also need to change your web server configuration to allow larger post sizes.  For example, to set the limit at 100MB might be something like this for Apache httpd 2:
LimitRequestBody 104857600



Wednesday, October 02, 2013

Techniques for learning German - podcasts.

Podcast - "A multimedia digital file made available on the Internet for downloading to a portable media player, computer, etc."

If you have a modern phone, ipod, or mp3 player you can play podcasts on the move.  Or you can listen to them on your computer when you're not mobile.  It may seem a bit weird explaining what a podcast is... but there are many people who do not know what they are, or haven't tried them.  Skip to the bottom for lists of German podcasts.

Situations where you may be able to learn with a podcast:
  • sitting at the computer doing an office job (if you don't need to talk lots!)
  • on a bus/train, or walking/running (be careful!)
Other methods of learning may not be possible in these situations.  For example, you probably can't have a teacher follow you around the park as you go jogging.  Also, they probably can't sit next to you at your office whilst you work.

It's always better if you can talk out loud along with the podcasts.  Even if the people on the train start to consider you a little strange, or annoying.  But not everyone is happy with sounding like a freak... so if that's you, speak the words to yourself in your head.  Listening to yourself on a recording later can be a great way of comparing what you said to how it sounds when said on the recording.  Often people notice their mistakes much more easily this way.

Not only lesson podcasts are useful for learning German!  Any podcast in the language you are learning can be a useful one to listen to.  Just so you can get used to hearing how people speak.  Choosing a topic you are interested in can help your motivation as well.  For example, if you like photography and are learning German, find a photography podcast where the speakers speak German.  This gives you a little bit more motivation to try and listen to how people speak.

Going over what you have already learned is a great way to retain that knowledge.  Podcasts are a low effort way of refreshing knowledge you learnt through another technique.  For example, if you are going to language lessons, then listening to the words you have learnt that day can keep them fresh in your mind.

The Audio Trainer - is a podcast for learning German.  It contains 100 German lessons of vocabulary, grammar and pronunciation training.  It goes over (CEFR) A1 and A2 level content.  By going over the standardised A1 and A2 level topics, this podcast useful for directing your learning towards the tests.  Whilst learning lots of other esoteric words may be useful for your general knowledge, directed learning towards the syllabus allows you to use other learning materials within your level.

"Deutsche, Warum Nicht" is available in iTunes and as a podcast at http://www.dw.de/learn-german/deutsch-warum-nicht/s-2548
"The course Deutsch – warum nicht?, divided into four parts, tells the story of the journalism student Andreas and his invisible ex. Join the two of them on an adventure and learn German along the way! Each of the four series contains 26 lessons with dialogues, exercises and audios to download. The course covers levels A1 to B1 of the European Framework of Reference for Languages and is geared toward beginners and advanced learners. Deutsch – warum nicht? was produced by Deutsche Welle and the Goethe Institute."
The Goethe institut has made some pod casts available here:http://www.goethe.de/frm/pod/enindex.htm.  From the seven podcasts they provide,  Radio D is sort of fun.  Since it contains fifty two short stories, each 15 minutes long, suitable for A1 and A2 level students.  Listen to short stories, and learn at the same time!  It can be a nice change from more boring learning methods.

One other good example of a non-lesson podcast that many learners will be interested in, is a podcast of the Deutsche Welle News read using simplified language, and spoken slowly.  This way you can get some of your daily news, but at the same time be learning something!  Brilliant.  See: German news spoken slowly podcast

http://german-podcast.blogspot.com/ is a podcast by Stephen Wiesner with many lessons (111 items listed in the podcast at time of writing).  Stephen has also made PDF files available to print out so you can read along whilst you listen(Unfortunately a lot of the links to the PDFs are broken).  The lessons include a lot of call and response with Stephen asking you to respond to his questions, or repeat phrases.  Stephen has also made an Android app available.

Germanpod101.com beware! this one is sort of free (for 7 days), but there are some lessons made available for free if you search on itunes for their podcasts.  Otherwise you have to sign up via email, and they try and get you to pay a monthly fee.  I found the accent improvement lessons particularly useful.  You can see many of their video lessons for free on youtube here: http://www.youtube.com/user/germanpod101/videos?flow=grid&view=1 They're not podcasts, but video podcasts or vodcasts.  Learn German Vocab with pictures is a youtube playlist from them where you can listen to some nice piano playing whilst a man reads out words for different topics, and you are shown pictures of the word.

"Slow German" is a podcast where Annik Rubens from Munich reads various stories slowly in German.  The text is available in the mp3 id3 tag or on the website ( http://www.slowgerman.com/ ).  This lets you follow along with the story if you want.  This is at approximately simple B1 level, and is sort of good for improving your listening comprehension skills.  There is a related iphone/ipad app too.

"German GrammarPod" podcast and the blog that goes along with it covers German grammar lessons.  There's about 30 lessons, with some being 11 minutes long, and others being as long as 51 minutes!  Some people hate learning grammar, but I don't think it can really be avoided.

"Pukka German!" is a podcast of German slang, idioms, funny sayings, common German words and phrases.  This one has real authentic soul - and teaches you funny things to say.  Want to know what to say at parties, or to talk about your hangover the next day?  Then Pukka German! has you covered.

Forming learning habits can greatly help your progress in learning German.  By including a podcast into your daily routine, you make sure you are learning regularly.  A little bit of learning every day slowly adds up, and many people can fit some podcasts into their routine easily without having to sacrifice other things.

Podcasts are one of many techniques, and tools available to learn languages.  They should not be used alone for learning, but can be a great when used with other methods of learning.  I'm blogging various techniques I have used to learn German under the German and Deutsch labels.

Friday, April 12, 2013

All you need is love, Berlin... and a dog.




All you need is love, Berlin... and a dog.



Thursday, April 11, 2013

Serial and pixels for breakfast. Arduino + pygame.

Taking a byte of bits of Serial, along with Green screen with Sam, pygame, and an Arduino hooked up to a light sensor and a motor thing.

Coffee too?  Naturally.

Where do we begin?  At the end of course.  A video of the result...



The arduino code

#include <Servo.h>  
Servo myservo;
int potpin = 0;
int val;

void setup() { 
  Serial.begin(9600);
  myservo.attach(9);
} 
 
void loop() { 
  val = analogRead(potpin);
  Serial.println(val);
  val = map(val, 62, 540, 0, 179);  
  myservo.write(val);
  delay(15);
}

python pygame code

Extended the "green eggs and ham" code I made recently to read serial data from the Arduino, and paint the screen different shades of green, whilst also making some silly sounds depending on the value read from the light sensor.



import os
import pygame
import serial

# guessing serial ports names. Linux or macosx.
#'/dev/tty.usbserial'
ser = serial.Serial('/dev/tty.usbmodem1411',
                    9600,
                    timeout = 0)
serial_buffer = ""

# an event number for the SERIAL
SERIAL = pygame.USEREVENT + 1


from pygame.locals import *
Event = pygame.Event
split = os.path.split


pygame.mixer.pre_init(44100, 8, 2, 1024)
pygame.init()
screen = pygame.display.set_mode((640, 480))
message = "Press q to quit, b for blue, r for red."
pygame.display.set_caption(message)

import pygame.examples
example_path = split(pygame.examples.__file__)[0]
example_data = os.path.join(example_path, "data")
sounds = [pygame.mixer.Sound("wiff.wav"), 
          pygame.mixer.Sound("punch.wav"), 
         ]

going = True
while going:
    serial_data = ser.read()
    #print (repr(serial_data))
    while serial_data:
        serial_buffer += serial_data
        # if there is a new line in it, then 
        if "\r\n" in serial_buffer:
            #print (repr(serial_buffer))

            evt = Event(SERIAL, 
                        {'line': serial_buffer})
            pygame.event.post(evt)
            serial_buffer = ""
        serial_data = ser.read()

    events = pygame.event.get()

    for event in events:
        print (event)
        if event.type == KEYDOWN and event.key == K_q:
            going = False
        if event.type == KEYDOWN and event.key == K_b:
            screen.fill(Color("blue"))
        if event.type == KEYDOWN and event.key == K_r:
            screen.fill(Color("red"))
        if event.type == SERIAL:
            # read the line from the serial event.
            print (repr(event.line))

            # clean up, and do sanity checking.
            # It could be corrupt or garbage.
            line = event.line.replace("\r\n", "")
            line = line.replace("\n", "")
            line = line.replace("\r", "")
            # it could be empty.
            if line:
                val = int(line)
                if val < 1024 and val > 0:
                    print (repr(val))
                    # map 0 and 1023 of analog read to
                    #  0-255 colour colour range.
                    green = int((val/float(1023))*255 )
                    screen.fill((0, green, 0))
                    if val < 100:
                        sounds[0].play()
                    if val > 300:
                        sounds[1].play()
                    
    pygame.display.flip()

ser.close()

Tuesday, April 09, 2013

Touchless UI with a Light Dependent Resistor, and the Arduino.

Touchless UI?  This is the next step in my little adventure into the world of Arduino...

It can sense light, from which the Ardunio reads an analog signal and then drives a Servo Mototor.




Arduino Servo motor, and a Potentiometer

Moving a servo motor(vrmmm vrommm) based on the analog input Linearly interpolated (LERP'd) from the Potentiometer (turny thing).

Arduino, Analogout fading LED.

So the Arduino adventure continues... This time, playing around with fading a light via an Analog output.

Vietnamese style coffee.

Coffee good.  Different styles of coffee good.  Viet coffee good.

Try and get the viet bean, and get it ground the way they do it too.  It's usually a mild flavour... but with the sweetened condensed milk it can be very sweet.  Plus you can make it on your desk!  Mostly I don't drink it sweetened, but that's the way they mostly do it, so for this video I did that too :)


Here is a much better video on how to make Vietnamese style coffee... great song too!


Monday, April 08, 2013

LED, lumens and a multimeter

Picked up a small 360 lumen LED light with built in heatsink. As well as a multimeter.  Going to use them in a projector project with the Arduino.
LED lights with built in heatsink, and a multimeter.

Saturday, April 06, 2013

Reducing the number of concepts. To make teaching easier.

I am Sam.  Sam I am*.  Well at least my middle name is Sam.  So of course, one fun book I've always been drawn to is Green Eggs and Ham. The famous beginners book by "Dr. Seuss".
 
It contains just 50 different words: a, am, and, anywhere, are, be, boat, box, car, could, dark, do, eat, eggs, fox, goat, good, green, ham, here, house, I, if, in, let, like, may, me, mouse, not, on, or, rain, Sam, say, see, so, thank, that, the, them, there, they, train, tree, try, will, with, would, you.

A great beginners book, because it's a full story teaching a number of other concepts using a limited amount of words.  It's a clever bootstrapping hack to language learning.  Apart from all its cleverness, it's a fun & entertaining read too! :)

So you want to teach some newbies how to be l33t python pygame pr0grAmm3rs?  Maybe Sam I am, and Green Eggs and Ham have something to teach us, the teachers?

Let's reduce the number of concepts!

Classes, packages, and even functions are hard to get right away.  As in the first 10 minutes of teaching something to someone it's hard anyway.  Some people may get your car metaphors, and your nonsense about Ducks quacking like ducks... but others will look at you blankly.  Then that snotty nosed brat at the back of the class will start texting rude words about how you are a poo poo head, and it's GAME OVER.

However, there are two parts to these concepts.  Creating them, and just using them.

Here is an example pygame program using functions, packages, and classes... but not creating them.  This requires less knowledge to start doing something.

Press r for red.

import pygame
from pygame.locals import *

pygame.init()
screen = pygame.display.set_mode((640, 480))
message = "Press q to quit, b for blue, r for red."
pygame.display.set_caption(message)

going = True
while going:
    events = pygame.event.get()
    for event in events:
        print (event)
        if event.type == KEYDOWN and event.key == K_q:
            going = False
        if event.type == KEYDOWN and event.key == K_b:
            screen.fill(Color("blue"))
        if event.type == KEYDOWN and event.key == K_r:
            screen.fill(Color("red"))
      
    pygame.display.flip()


This displays quite a number of perhaps confusing concepts, but removes a few of the complex concepts.

Watch ALL the events printed out!

Notice how there are no functions declared, no classes created, and no packages declared.  There's also no "Reactor", or callbacks required for the events.  It's just importing (which is boiler plate).

Ask yourself, "How would I see all of the events coming into a browser with JavaScript?".  This example prints out all of the events happening to the program.  Including Keyboard events, and Mouse events.  You don't need to know in advance what type of events will be appearing.  You can discover that there is a key up event, that there are mouse motion events.

By reducing the set of concepts needed to understand the code you will have an easier job teaching it.

Press b for blue!


(* I don't like Green Eggs and Ham. I don't like them here or there. I don't like them anywhere.)

q for quit.