Archive

Posts Tagged ‘programming’

How to use the TCN75 temperature sensor with Arduino

January 13th, 2012 No comments

In this short tutorial I'm going to show to you how to implement , in the Arduino UNO environment, the basic functionalities to work with the TCN75.


Materials needed for this tutorial.

  • 1 Arduino UNO board (naturally)
  • Arduino IDE (naturally)
  • 1 TCN75 (naturally I'll use my own board, see related posts)
  • 4 jumper cables


Our tcn75 board is described here:


Ok let's start

The new ISO C11 standard for the C language

January 3rd, 2012 No comments

 

On 8th December 2011, ISO has ratified and published as ISO/IEC 9899:2011 the new C11 (C1x) standard for the C programming language. The major changes from the previous standard (C99), as written in the wikipedia, are the following:

 

The standard includes several changes to the C99 language and library specifications, such as:[6]

Alignment specification (_Alignas specifier, alignof operator, aligned_alloc function, <stdalign.h> header file)

The _Noreturn function specifier

Type-generic expressions using the _Generic keyword. For example, the following macro cbrt(x) translates to cbrtl(x), cbrt(x) or cbrtf(x) depending on the type of x:

#define cbrt(X) _Generic((X), long double: cbrtl, \

                              default: cbrt, \

                              float: cbrtf)(X)

Avoid the use of multiplies to optimize your code for speed (C/C++).

November 25th, 2011 1 comment

If it is possible you should use constant increments instead of multiplies.

#include <stdio.h>

#include <stdlib.h>

int main(void)
{
    int i, j;
    for(i=0; i<10; i++)
    {
        j=i*10;
    }
}

int main1(void)
{
    int i, j;
    for(i=0; i<100; i+=10)
    {
        j=i;
    }
}

Dennis Ritchie: 1941-2011

October 19th, 2011 No comments

 

#include <stdio.h>

int main()
{
    printf("goodbye, dad\n");
    return 0;
}


source: http://www.muppetlabs.com/~breadbox/rip-dmr.html

Ten GCC optimization flags that must be known

October 15th, 2011 1 comment

The GCC provides the capability to generate optimized compiled code. When you are running gcc to compile your code you can choose between a large number of optimization levels using the following switches:

Brainfuck For Arduino

October 2nd, 2011 1 comment

This Saturday I've seen the light. For the first time since three months I've had the freedom to do what I want. So I have implemented this simple brainfuck interpreter for Arduino.

I tried it on my Arduino UNO dev board, let me know if you try on other boards.

nglogc a flexible C logging API

September 22nd, 2011 No comments

nglogc is a flexible C logging API, it is released under the LGPL license. The author, Dennis Krzyzaniak, has released a full detailed manual.

In the following lines, the first two paragraphs from the manual, just to understand something about this library.

Introduction

An alternative way to parse command line arguments

September 12th, 2011 1 comment

In C, if you are developing a complex application that requires a large number of command line option you should use the getopt function to handle them, if your application needs a small number of command line arguments you can think to manage them with your own code.

Function pointers in C

July 11th, 2011 No comments

 

In C A function pointer is a type of pointer. When dereferenced, a function pointer can be used to invoke a function and pass it arguments just like a normal function. Function pointers can be used to simplify code by providing a simple way to select a function to execute based on run-time values.

How to trap the CTRL-C on MAC OS X and Linux

June 26th, 2011 No comments

 

 

During the developing phase of programs for my customers, I have to think that they can use the CTRL-C combo to interrupt the execution of my code. 

In some cases, for example in a program that makes only some computations, I can avoid catching this event.

Statistical data collected by Statpress SEOlution (blogcraft).