Programming with open source hardware educational board eduArdu and Scratch 3

Screenshot from 2019-07-29 14-52-10

New demo code which transforms eduArdu in Makey Makey and tutorial how to use with Scratch 3 is uploaded to GitHub.

Here is the result from above code:

C awesomeness (not)

The_C_Programming_Language_logo.svg

Few days ago I was asked question what would be the output of this code:

#include <stdio.h>
int main()
{
      int a = 5;

      printf("%d %d %d %d\n",a++,a++,++a,a++);

      return 0;
}

Nothing special, right? But C standard do not specify how printf evaluates it’s parameters, so it’s left up to the C compiler and here the fun part starts.

Old C compilers would be a bit more predictable as they would start evaluating from the top of the stack to the bottom i.e. right to left, but the new ones heavy optimize and try to execute some instructions in parallel, so the only certain thing is that at the printf “;” point of synchronization “a” would be incremented 4 time, but nobody knows in what order.

Compiled with GCC/Code Blocks the output is:

Screenshot from 2019-02-20 11-46-45

Again nobody guarantee that if you re-compile on different computer /CPU the result will be same!

Even changing the code with one more line like enter the value of a with scanf leads to different result:

Screenshot from 2019-02-20 11-47-47

So good practice will be to avoid any calculations inside printf and to search logic there. Do these separately where compiler has to stick to C standard and rules.

 

Nice tutorial for writing and debugging plain C on ARM Cortex-M3 STM32F103

OLIMEX-STM32-H103

Jacob Mossberg wrote nice tutorial how to program in C ARM Cortex-M3 with GCC and how to debug it with GDB and OpenOCD.

We like very much the hardware he is using 🙂 STM32-H103 and ARM-USB-OCD-H.

 

Bulgaria has the highest average reputation among top users in the Stack Overflow

Europe

VB News posted interesting article. They analyzed data from StackOverflow where coders exchange Questions and Answers. Users of the platform vote up or down answers to questions this way ranking the coders who answer the questions and problems posted.

Their analyze shows that London has the highest number of top Stack Overflow members, with 394 that have a reputation over 5,000.

cities

Another ranking based on the average country ranking of Stack Overflow users above the 5,000 threshold shows that Bulgaria has the highest average reputation among top users in the
world.

average-reputation-by-country

 

I have no idea how correct is this analyze, but I’m glad to see finally something IT related, where Bulgaria is #1 in the world 🙂

Programming ESP8266-EVB with Arduino IDE

arduino

 

We made Arduino style library to easy the stand alone ESP8266 programming, but we were not using any IDE but mostly command line compile and programming. Two of our developers decided to use Eclipse and set it up for ESP8266 tools.

Yesterday we spotted on ESP8266_wiki GitHub account that someone already add support for ESP8266 in the latest Arduino 1.6.1 IDE release, how cool is this?

I decide to try it today. I downloaded the pre-build binaries arduino-1.6.1-linux64.tar.xz and decompress it in /home folder then ran terminal and “sudo ./arduino” in the Arduino-1.6.1 folder, the Arduino IDE was launched.

Then I connected USB-SERIAL-Cable-F to ESP8266-EVB Open Source Hardware board UEXT connector connecting blue wire to PIN2, the green wire to PIN.3 and red wire to PIN.4 on the UEXT connector as on this picture:

esp8266

Then in Arduino IDE I Selected Tools->Board-> Generic ESP8266 board

Then connected USB-SERIAL-CABLE-F to USB and selected Tools-> Port -> /dev/ttyUSB0

Then selected Tools-> Programmer->esptool

From examples loaded Blink LED then changed the port 13 to port 5 where the relay is connected.

I pressed the ESP8266-EVB button and connect 5V power supply to board to make it enter in bootloader mode, then click on Upload button.

The sketch was compiled and uploaded successfully then the relay start to switch on and off like expected.

Well done! I didn’t check all the libraries, but I see inside demos for web servers etc.

 

Free online e-book – Pragmatic D Language Tutorial

Image

For these who are currious about learning more for D Language this is link to free online book: http://qznc.github.io/d-tut/hello.html

quote from there:

D is greatly inspired by C++ and inherit parts of its philosophy. D provides powerful abstraction mechanisms without sacrificing performance. If you are looking for a better C++, you should feel at home with D. If you dislike C++, you might like D for being C++ done right.

Weekend Programming Challenge – Week #24 – combinatorics

Image

Problem:

Write code which calculate the number of ways you can express positive natural number N as sum of positive natural numbers.

Example:

for N=1 we have 1 way

for N=3 we have 3 ways

1+1+1
1+2
3

etc.

The rules:

You can code the solution in any programming language during the weekend and have to submit it to info@olimex.com latest on Sunday September 15th.

On Monday we will upload the solutions on GitHub https://github.com/OLIMEX/WPC

You can play with your real name or with nick if you want to be anonymous, we will not disclosure your personal info if you do not want to.

Weekend Programming Challenge – Week #23 – Evil code

Image

Problem:

Invent something small and evil which to be almost invisible and to cause lot of troubles to catch like:

#define struct union

#define double float

#define floor ceil

#define true (__LINE__&42) !=42

#define private public

The rules:

You can code the solution in any programming language during the weekend and have to submit it to info@olimex.com latest on Sunday September 8st.

On Monday we will upload the solutions on GitHub https://github.com/OLIMEX/WPC

You can play with your real name or with nick if you want to be anonymous, we will not disclosure your personal info if you do not want to.

Weekend Programming Challenge – Week #22 Plagiarism detector

Image

Problem:

Make code which compare two texts and output the % of similarities between the two texts i.e. if they have same words even if the words are in different order.

More advanced version may take care for synonyms ,

The rules:

You can code the solution in any programming language during the weekend and have to submit it to info@olimex.com latest on Sunday September 1st.

On Monday we will upload the solutions on GitHub https://github.com/OLIMEX/WPC

You can play with your real name or with nick if you want to be anonymous, we will not disclosure your personal info if you do not want to.

Weekend Programming Challenge – Issue #21 Words Puzzle

Image

Problem:

Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn’t mttaer in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is taht the frist and lsat ltteer be at the rghit pclae. The rset can be a toatl mses and you can sitll raed it wouthit porbelm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe.

You can see original text here: http://www.mrc-cbu.cam.ac.uk/people/matt.davis/Cmabrigde/

Write code which takes as input normal text and shuffles the letters inside the words to make text like this one above.

The rules:

You can code the solution in any programming language during the weekend and have to submit it to info@olimex.com latest on Sunday August 25th.

On Monday we will upload the solutions on GitHub and review https://github.com/OLIMEX/WPC .

You can play with your real name or with nick if you want to be anonymous, we will not disclosure your personal info if you do not want to.

Good Luck and Have fun!

Previous Older Entries