#2 Data representation in computers

The basic number value stored in computer’s memory has 8 bit – 1 byte. This allows us to store number from 0 to 255 (00000000 – 11111111) because there are no combinations of 1 and 0 left in those 8 bits. But all systems works with largers numbers with different size. 1 byte, 2 byte, 4 byte or even 8 byte numbers. This get us an opportunity to use larger or smaller variabels due to what they will be used.

BytesRangePossible usage
10 – 255Store states 0 or 1
20 – 65535Simple stopwatch
40 – 4294967295Youtube views count
80 – 18446744073709551615Something big

The reason why we cannot use the largest variables all the time is that we don’t have memory with infinity size. For example PC or smartphone has 4GB or RAM memory but small microcontroller chip can only have 1kB what is 4 milion times smaller! Programming these devices with small RAM needs to think about size of data we want to store and then use appropriate variable size.

#1 Data representation in computers

Let’s say the computer’s memory is built out of transistors. This electronic part can store electric charge or not, so state 1 or 0. That is the reason why it’s easier to store only 1 or 0 rather than all digits we use in our decimal system (0 1 2 3 4 5 6 7 8 9). Everything in computer is stored as number is specific way.

How is number like 142 represented in binary system consisting only of bits 1 and 0?

Computers use a group of 8 bits called byte. For example 10001110 in binary is 142 in decimal.

In dec system each position in number has different weight. Weights are powers of 10. 10^0 = 1, 10^1 = 10, 10^2 = 100, 10^3 = 1000,… So number 142 is shown here:


Sum it: 1*100 + 10*4 + 1*2 and get 142. Something similar is done also in binary.
This time the weights are powers of 2 because binary. 2^0 = 1, 2^1 = 2, 2^2 = 4, 2^3 = 8


Sum this: 1*128 + 1*8 + 1*4 + 1*2 and you get 142.

The save process can be done vice versa. Let’s convert number 180 from dec to bin.
We start with the largest power of 2 which is smaller than our number.

180 has 128 1 times, 180 – 128 = 52
52 has 64 0 times, 52 stays
52 has 32 1 times, 52 – 32 = 20
20 has 16 1 times, 20 – 16 = 4
4 has 8 0 times, 4 stays
4 has 4 1 times, 4 – 4 = 0
0 has 2 0 times, 0 stays
0 has 1 0 times, 0 stays

Then write down 1 and 0 and we get 10110100 which is 180 in bin.

#2 SQL

Where Clause

We often select only a portion of out huge database. For example, we will use table from last article and we would like to select only students with bikes. Let’s do it.

SELECT id FROM students WHERE has_bicycle = true;

The result:


Examples of another where clause uses:

SELECT * FROM students WHERE surname = 'Smith';
SELECT * FROM students WHERE id = 1;
SELECT * FROM students WHERE date_of_birth < '2005/01/01';

#1 SQL

SQL (Structured Query Language ) is language created for querying from database.

Assume you have a database. You want to insert new stuff, update it, select some stuff or maybe delete it overtime.

Easy explained, the database consists of several tables, for example table of students:

2Alex Hunnybun2004/01/19false
3Carol Gladden2005/10/13true

The first column is unique id of record in the table (it is not number of the row as we can delete second row and row with id 3 will be second then).

Let’s start with selection. The basic syntax is:

/* comment in sql */
/* basic syntax ended with ; */ SELECT columns FROM table;
/* examples */
/* 1 */ SELECT id FROM students;
/* 2 */ SELECT name, surname FROM students;
/* 3 */ SELECT id, name, surname, date_of_birth, has_bicycle FROM students;
/* 4 */ SELECT * FROM students;

The first query SELECT id FROM students will return whole column with ids. The last 2 queries are the same, * character means everything (every column). The result of query number 2 will be:


#1 Eskate – to build or not to build

I asked myself a question: Would you like to build electric skateboard? And so my answer was divided to pros and cons. But first, let me tell you some keywords which run across my mind when I wanted answer my qeustion: Freedom, Expensive, Swag


  1. Enjoying the ride
  2. Get something cool for transportation
  3. Develop an app for it
  4. Add custom sensors to monitor conditions


  1. Waste of money
  2. I cannot ride everywhere, only on good roads
  3. It is not stable as electric scooter

Big motivation to build it was the fact that my friend wanted to build an eskate too but He was lazy and did not get enought money for realisation, cuz the price of basic eskate is around 250$. I wanted to beat him and show the eskate to him so he will be shocked. I did not tell anything about my eskate until the revelation.

My top 10 IT jokes

Algorithm: Word used by programmers when they don’t want to explain what they did.

Life is too short to remove USB safely

Q: Why do Java programmers have to wear glasses?
A: Because they don’t C#.

Where’s the best place to hide a body? Page two of Google.

3 Database SQL walked into a NoSQL bar. A little while later they walked out because they couldn’t find a table.

A programmer’s wife asks him to pick up some groceries on his way home from work. He asks what she needs, and she says to pick up a gallon of milk, and if they have eggs, get a dozen. When he returns home, his wife asks why he brought home 12 gallons of milk, and he responded that they did indeed have eggs.

Yo momma so FAT, she can’t save files bigger than 4 GB.

A SQL query goes into a bar, walks up to two tables and asks, „Can I join you?“

God is real, unless declared integer.

There are only 10 types of people in the world: those who understand binary, and those who don’t.

Acceleration limiter for ESC

The basic Electronic Speed Controller with only PWM input for speed control and 3 phase output connected to BLDC motor has no Hall effect sensor feedback input from the motor. The feedback tells which state the motor is in to the esc and esc is adjusting speed. This is called closed loop control. Some of BLDC motors has another 5 cables and these cables are for this sensor (VCC, GND, A, B, C). We don’t have any special cables so feedback for now.

When we send full throtle to the ESC, it starts to change phases very quickly as it should but this is not very effiecient if the motor is stopped. We should increate the speed in smaller steps so the ESC will be shooting phases slower and we will get higher torque so the motor will have more force to start rotating.

How to limit this acceleration while you are hitting full throtle on the controller?

  1. Use pulseIn(pin, HIGH, timeout = 5000) that returns microseconds.
  2. This value is in range 1000 to 2000 microseconds as a standard esc/servo pwm control.
  3. Let’s use servo.writeMicroseconds(value) for output
  4. Set constant variable CHANGE_IN_ONE_LOOP to 10 for example.
  5. Let have variable currentMicros initialized to 1000 as minimum of pwm.
  6. Assume a loop function with 100 milliseconds delay.
  7. At the begin of the loop, read pulseIn value.
  8. Get delta value as pulseIn – currentMicros which will be positive or negative if accelerating or deccelerating.
  9. Set currentMicros to currentMicros + delta * CHANGE….LOOP and write it via servo function

This is an example of implementation. It could be definitelly done better.

Android Things?

Android Things is platfrom for your IoT prototyping. The name Android Things comes from Android, because it runs on Android and you can run Android Apps there and Things because you make some IoT (Internet of Things) device. IoT stands for a lot of things that are connected to internet, for example alarms, sensors, smart screens, smart everything

It is like „Arduino running Android“. Protocols such as I2C, Serial, SPI and GPIO, PWM are supported.

Android Thins itself is only way how to do software on your development board. You can run it on Raspberry Pi 3B or Pico i.MX7D. I like the fruity way more. Small comparison:

RPi 3B 4x ARM Cortex-A53 1.2GHz Broadcom VideoCore IV 1GB LPDDR2 (900 MHz) uSD card 10/100 Ethernet, 2.4GHz 802.11n, BT, BLE 40-pin header
Pico i.MX7D 2x ARM Cortex-A7 1.2Ghz, ARM Cortex-M4 200Mhz 512MB LPDDR3 (1066 MHz) 4GB eMMC WiFi, Ethernet, Bluetooth 40-pin header + 12-pin + 2×8-pin

The Starter pack I got is borrowed from eMan.cz. This is not a commercial promo. The box contains several smaller boxes with these components:

  1. Pico i.MX7D Development Board
  2. Wi-Fi antenna + cable
  3. 5″ multi-touch display + cable
  4. Pimoroni Rainbow HAT + Camera module
  5. Camera ribbon cable + Standoffs ads screws + Double-ended screwdriver + USB-C cable

The box itself has cardboard-styled parts which can be connected together into one Development Stand as they say.

Photos on Google Drive

One of the dissadvantages you can get is support of libraries. There are not so many libraries for components like for Arduino or Python running on Raspberry. If you want to run a rare component which works with Arduino you can run it with Android Things as well, but with need to be lucky finding the right library otherwise you will need to write it yourself by datasheet and that could not be so easy.

My top sensors/components


VL53L0X is I2C infrared laser-like distance sensor which can measure distance with accuracy of 1 mm and maximum distance of 200 cm in long range mode, the basic mode provides 120 cm range which is good for many applications. One disadvantage is that you cannot change I2C address permanently. You have to shut down other sensors on the line and then set I2C address of the sensor. Address resets when the sensor losts power.


Nokia 5110 SPI display or OLED I2C. 5110 is low power, readable on direct sun, has optional backlight but the pixels are rectangular not squares, so circle looks like ellipse. The OLED one is no so power efficient but easy to connect and has variable colors (blue and white) and size (0.9 and 1.3 inch). I like the 1.3″ inch version.


Bosch BME280. It measures temperature, humidity, pressure (and above sea level from pressure). It uses I2C interface and supports low power modes. For the precise contactless temperature measurements I choose Melexis MLX90614. This I2C sensor has several versions (voltage, field of view, accuracy). I like the DCI version which is 3 volt with 3 degrees FOV and almost medical precision.


If I want to get just Yaw/Pitch/Roll in degrees then I use GY-25. The board itself has MCU and sensor. The MCU communicates via I2C with sensor and over Serial to you. But if I want more data I use MPU-9250. It is I2C sensor with accelerometer, gyro, compass, so 9 axis in total. It also provides temperature as bonus.

I will add other soon