Perhaps someone has already heard about the hackathon wth.by , held in Minsk. Below I will tell you how he went for me and what brought our team first place. If interested, welcome under cat.
Training
I learned about the hackathon in 2 weeks. Immediately I registered, put together a “team” and we began to think what to do. We decided that it would be something based on arduino.
After a couple of days of thinking, I accidentally stumbled upon a quite popular recently plot clock and I had the idea to make a chat with an “output” in this form. ')
We discussed the idea with the team and collectively decided what it would look like: chat for 2 users, each with its own “device” for displaying information, choosing a check tape that the motor would wind up with a field for output.
A couple of hours before the hackathon, they assembled an “alpha version” of the device (in order to focus on writing code on the spot).
Source materials:
Arduino UNO, 2 x MicroServo SG90, 1 x Servo MG946R, 1 stepper motor, wooden block, receipt paper, fan with letters (yes, such as it was in kindergarten / elementary school), super glue and, of course, blue electrical tape .
The format of the event: a non-profit hackathon, 44 hours is not the realization of an idea, an overnight stay: optional, subject: free, but linked to the web.
Hackathon day
Friday, 18:00 We collected all that is, and went to the venue. We listened to the presenter, patted the judges, told us what we were going to do, went to take a seat and get to work, which, by the way, had a lot to do.
We sat down and realized that no one has any idea how to write something using 2 servo and a marker. We decided to look for clues on the network, stumbled upon a bunch of “guides” for the plot clock like “print these models here, connect everything like this, fill this code with arduino and you will be happy”. Having rummaged in the source code of the plot clock, I realized that even with comments to the code, nothing is clear. As a result, after a couple of hours, we didn’t have anything, it only remained to do everything on our own.
After a couple more hours, we were able to formulate the task normally, it was quite simple right after we made the drawing:
Did not find a suitable drawing tool at hand
We derived the formulas for obtaining the angles of rotation of the servos to hit an arbitrary point (x, y):
Decision
(similar for 2 servo)
By the time of the decision, the server and client code was already ready, it remained to consider the communication of the client application with arduino and the communication protocol. The clock, meanwhile, was 4 am and we went to bed.
Both the client and server were written in node.js, client communication -> server via web socket; client -> “device” through serial port, on the client using node-serialport library , on “device” using standard arduino c.
Day 2
9-00: Waking up about either from the cold, or from the noise around, we started thinking about how to write letters. First idea: put each letter of the alphabet on the coordinate grid, find out the extreme points and draw straight lines on the points. We tried and realized that, due to the nature of the mechanism, the path from the point (x1, y1) to (x2, y2) is an arc, and not a straight line. We decided to beat the line on a set of points and then the small arcs between these points will not be so noticeable.
From here, we can roughly formulate the client application's communication protocol with arduino: the client receives a message, breaks it into letters, a set of points is known for each letter, the client builds a set of commands like: raise the marker, drop the marker, squander the tape and set angles for two servoes.
At first glance, everything is fine, but it turned out that the speed of communication that the serial port allows is not enough and the letters are written unacceptably slow (about a minute for 1 letter).
in fact
Maybe I just do not know how to cook it.
21-00: after several hours of attempts with the serial port, we were in despair. There was an idea how to fix everything, which perfectly embodied the popular joke about the hackathon code:
Typical hackaton code
Here is what we did: we wrote a “code generator”, which for each letter built a set of function calls on C and stuffed this code directly into Arduino. Those. we got a “firmware” with hardcoded letters. The communication protocol has changed a bit: the client accepts the message, breaks it into letters, sends each letter to Arduino, arduino accepts a letter, writes it and rewinds the tape (the entire code for Arduino took about 30kb from the available 32).
(Meanwhile, many participants went to the bar to rest, but we didn’t care for it. Rest for those who wrote the code).
With the words "for such I would be fired for sure" at 4 o'clock in the morning of the second day we learned to write words and went to sleep.
Day 3
After a few hours of sleep, we began to customize the letters for the 2nd device, fix the bugs and prepare the presentation. Presentation of projects was scheduled for 16:00.
At 15-50 we finished customizing the letters for the 2nd device.
So that nothing broke at the last moment, we decided to put everything in advance on the table and bring it in when it would be our turn. But this did not save us: during the presentation in the second device, the rewind broke, but, fortunately, it was not noticeable.
Video submission:
Award
After all the participants showed their projects, the judges retired to take a decision for a long 40 minutes. After the announcement of each prize place (several nominations and Top 3), I mentally said: “here, now we, come on!”. Then came the second place award, and I began to despair: "Well, we could not win." But suddenly I heard: “plot chat” is further like a fog .
Prizes: 1 year silver repository on github, 1 million Belarusian rubles (~ $ 70) for hosting tut.by and magnificent Lego Mindstorms .
But the main thing is that we received a lot of positive emotions and invaluable experience. And also a cold, a broken voice and a huge lack of sleep. But it was worth it.
UPD: added some technical details and information about the hackathon format.