domenica 23 dicembre 2012

Two years of blogging: special post about paper nativity scene + bare paint + arduino

Hi, yesterday  was my second blogging anniversary and I'm writing a special post: a nativity scene made of paper and lighted up using LEDs, bare paint and arduino.
Here are some file that I found useful to make it.
I won't explain anything about this project because I think that using tools like Arduino and Bare Paint the only limit you have is your imagination, so I just suggest to make the scene being alive using LEDs, servo motors and whatever you want.
Here are some photos of the project:


LEDs connected to power using Bare Paint

LEDs connected to power using Bare Paint
 

The paper house

Arduino connected with Bare Paint to LEDs


 

The result




 And here is a video:

I hope you like the post, Merry Christmas and thanks for your support during these two years.
If you have any question comment or send me an e-mail to damianoandre@gmail.com

Bye, Dami

martedì 11 dicembre 2012

Conductive Paint, write circuits on paper

Hi today I'm posting about Bare Conductive Paint (http://bareconductive.com/), a conductive ink that you can use on paper and textiles to write circuits.
Here are the  Bare Pens (5 pens --> about 25£):




Here are some photo of a simple project to test this paint:


I think this paint it's great for everyone who like electronics, I will post soon about a project made using Bare Paint.
If you have any question comment, send me an email to damainoandre@gmail.com or check http://bareconductive.com/

Bye, Dami


sabato 1 dicembre 2012

2 thousands views in November!

I write this post to say that November was highscore month: more than two thousands views.
Since I've started posting this blog reached about 28000 views, for me it's a great goal and I'll try to get always more views, this doesn't mean I'll post everyday because for me blogging it's just an hobby.

Bye, Dami

venerdì 30 novembre 2012

Volumetric lighting in Blender

Hi, this psot is about how to create a volumetric light in blender.
Here is an example of volumetric light:



There is only a lamp type that support volumetric lighting in blender: the spot.
First of all add the spot(Optional: in the lamp properties check Show cone to see how light influence your scene). Then go in lamp properties and in Spot Shape submenu check Halo and edit Step to 12.
Now you have created a volumetric light but if you wanna get a better result (not always, but sometimes  using this it looks more realistic) activate Ambient Occlusion and Indirect Lighting int the World Properties.
I hope you found this post useful, if you have any question comment or send me an e-mail to damianoandre@gmail.com

Bye, Dami

lunedì 12 novembre 2012

Use Arduino to program AVR

Hi, today I'm posting about programming an AVR (such as an attiny85) using Arduino.
You'll need:
- one LED
-10 microfarad capacitor
-an AVR (in my case an attiny85)
-an Arduino board (in my case Arduino UNO)
-some wires

First of all open the Arduino IDE and upload the ArduinoISP sketch (you can find it in File>Examples)
If you are using arduino 1.0 software check that in the void heartbeat() there is a line that says delay(20) if not change it.
When you have uploaded it to Arduino disconnect the board from pc and connect your avr like this:
-Arudino GND to AVR GND
-Arduino 5v to AVR VCC
-Arduino pin 10 to RST pin on AVR
-Arduino pin 11 to MOSI pin on AVR
-Arduino pin 12 to MISO pin on AVR
-Arduino pin 13 to SCK pin on AVR
-10 microfarad capacitor  between GND and Reset on Arduino

If you are using an Attiny85/45/13 it should look like this:



Now hardware side everything it's done.
To compile and upload the code for the AVR we need a software like WinAVR.
Download and install it, then create a C source file with your code in my case this:
 
#include <avr/io.h>
#define F_CPU 1000000UL
#include <util/delay.h>

int main(void) {
    int n;
    DDRB |= ( 1 << 4 );
    while (1) {
        PORTB &= ~(1 << 4 );
        _delay_ms(1000);
        PORTB |= ( 1 << 4 );
        _delay_ms(1000);
    }
    return 0;
}

Now you're ready to compile and upload your code:
-connect arduino to USB
-navigate to code folder using cd command
-compile your code using these commands:
for attiny13:
avr-gcc -g -Os -c -mmcu=attiny13 test.c
avr-gcc -mmcu=attiny13 test.o -o test.elf
avr-objcopy -O ihex -R .eeprom test.elf test.hex
 
for attiny85/45:
avr-gcc -g -Os -c -mmcu=attiny85 test.c
avr-gcc -mmcu=attiny85 test.o -o test.elf
avr-objcopy -O ihex -R .eeprom test.elf test.hex 

check this for more commands.

-upload your code with this command:

avrdude -P COM4 -p t13 -c avrisp -b 19200 -U test.hex
 
If you're using a different port change COM4.
 
Now everything it's done and the AVR should be programmed.


Here are some photos of the project:



I hope you like this post, if you have any question comment or send me an e-mail to
damianoandre@gmail.com 

Bye, Dami

lunedì 29 ottobre 2012

Horror corridor made using blender

Hi today I'm posting about creating an horror corridor using blender, I think that it's simple to make it but the result it's cool, here is the final render:


And here is the download of the blender project(.blend).

I hope you like this post, if you have any question please comment or send me an e-mail to damianoandre@gmail.com

Bye, Dami

martedì 9 ottobre 2012

Minecraft zeppelin mod use tutorial

Hi, today i'm posting about the zeppelin minecraft mod.
This mod makes you able to make your bluiding fly.
To use this mod download and install it(premoodded minecraft folder download).
When it's installed try creating a 3x3 square of wooden planks and place in the center an airship controller


then right-click on the airship controller and start flying, to fly use there commands(in the numeric keypad):
8 to go ahead
2 to go back
4 to rotate to left
6 to rotate to right
5 to stop
+ to ascend
- to descend

This works with everything based on wooden planks and iron blocks and if you stay near the airship controller, but if you want to control you airship remotely you need a zeppelin remote, to use that just right click on the airship controller and use the same commands.
Here is a video demostration about the mod:



I hope you like this post, if you have any question comment or send me an e-mail to damianoandre@gmail.com

Bye, Dami


sabato 29 settembre 2012

Best free screen recording softwares

If you wanna record your screen there are lots of software but it's difficult to say wich one is the best, I think that the best three are:
-The MajorSilence screen recorder : it is good to record desktop, it create very small output files but it isn't very good with 3d software like games.
-The ezvid built-in screen recorder : it records in high quality but creates big output files and it doesn't record fullscreen mode games
-The ffmpeg based screen recorder : it record about everything and in a good quality but it creates big output files

I don't know which one is the best but I personally prefer the ffmpeg based.
I hope this post will be useful, if you have any question comment or send me an e-mail to damianoandre@gmail.com

Bye, Dami

mercoledì 5 settembre 2012

Too much accounts D:

This post isn't a guide or a tutorial it's just about all the account's that we have to manage everyday:
-Google(Gmail, Blogger, and all the other google services)
-Facebook
-Twitter
-Minus
-Scribd
-Openprocessing
-All the other forums accounts(arduino forum, processing forum)
-Online games acccounts
-Other

If we continue creating online services we'll need another online service that remember us to check each account!
This post is quite useless but I think to this everyday!

Bye, Dami

Scribd: online documents sharing

Today I'm posting about an online text documents sharing service: scribd.
I used that service sometimes (here is my account) I think it's cool, it makes people able to read documents online or to download them.ù
You can easily login using your facebook account and start uploading files or reading online documents.
Probably I'll upload the battlefield 3 guide this weekend or next week.
I know it's a short post but I think scribd it's really user friendly.

Bye, Dami

martedì 28 agosto 2012

Creating a Qt application in c++ in Windows

Today i'm posting about the famous GUI library created by nokia: Qt.
This  library provide a cross-platform application and UI framework.
To start programming with this library in windows we need to install first minGW (gcc ported to windows), you can download it here.
At the end of the installation add the minGW/bin folder to your PATH variable, to do this go to
control panel>system>advanced system settings>advanced>environment variables

then select the PATH variable in  the system variables and click edit and add at the end

;C:\MinGW\bin

now to check if everything it's working open the command line and try writing

make

If it's recognized as a command you've done everything right else try checking this tutorial for the installation.
Now we need to install the Qt library that you can download here.
When you finished downloading, install the library and add the    C:\Qt\4.8.2\bin
to the environment variables just like we have done with the minGW binaries.
When you've done check if everything is working writing in the command line

qmake

To start programming create file main.cpp and write this code:

#include <Qt/QApplication.h>
#include <Qt/QWidget.h>

int main(int argc, char *argv[]){
    QApplication app(argc, argv);

    QWidget window;

    window.resize(250, 150);
    window.setWindowTitle("Example");
    window.show();

    return app.exec();
}

Now open a command line and move to the folder that contains the file using cd command and then write this in the command line to compile the file:

qmake -project
qmake
make

If there's no error in your code or in the environment variables you will find the compiled file in the debug folder.

I hope you like this post, if you have any question please comment or send me an e-mail to damianoandre@gmail.com

Bye, Dami

giovedì 9 agosto 2012

Simple game/physics engine in Processing

Today i'm posting about a simple physics engine that I made in processing, I think there are some bugs but it's good to start a 2D game engine.
Here is the code:
Block b1;
Rectc c;
Boolean collision = false;
Boolean jumping = false;

void setup(){
  size(600, 400);
  c = new Rectc(40.0, float(height)-100);
  b1 = new Block(20.0, float(height)-50);

  }

void draw(){
  background(255);
  c.update();
  b1.update();
  println(jumping);
  }

class Block{
  float xpos, ypos;
  Block(float x, float y){
    xpos = x;
    ypos = y;
    }
  void update(){
    fill(255, 0, 0);
    rect(xpos, ypos, 50, 50);
    if(c.ypos >= ypos-20 && (c.xpos+10 >= xpos && c.xpos+10 <= xpos+50)){
      collision = true;
      jumping = false;
      }
    else{
      collision = false;
      }
    }
  }

class Rectc{
  float xpos, ypos;
  float vx = 0;
  float vy = 0;
  float elasticy = 0.4;
  Rectc(float x, float y){
    xpos = x;
    ypos = y;
    }
  void update(){
    if(keyPressed){
      if(jumping != true && key =='w'){
        vy += -15;
        jumping = true;
      }
      if(key =='a'){
        vx += -1;
        }
      if(key == 'd'){
        vx += 1;
        }
      if(key == 's'){
        vy += 0.25;       
        }
    }
    xpos += vx;
    ypos += vy;
    vx *= 0.4;
    vy *= 0.99;
    vy += 0.25;
    if(collision){
      vy = -Math.abs(vy);
      vy *= elasticy;
      ypos += vy;
      }
    fill(0, 255, 0);
    rect(xpos, ypos, 20, 20);
    }
  }

The code is available for download here(.zip).
If you have any questions about the code please comment or send me an e-mail to damianoandre@gmail.com

I hope you enjoy this post!
Bye, Dami

giovedì 28 giugno 2012

Processing Particle System

Today I'm posting about a really simple particle system made using processing, here is the code:

Particle particle;

void setup(){
  size(400, 400);
  particle = new Particle(70000, width/2, height/2, color(0, 0, 255));
  particle.generate();
  }

void draw(){
  background(255);
  particle.setDir(mouseX, mouseY);
  particle.update();
  }

//here is the particle system
class Particle{
  int qnt; //Particles count
  float dirx, diry;
  float[] xpos;
  float[] ypos;
  color c;
  Particle(int q, int dx, int dy, color col){ 
    qnt = q;
    dirx = dx;
    diry = dy;
    xpos = new float[q+1];
    ypos = new float[q+1];
    c = col;
    }
  void generate(){                            
    for(int i = 0; i<= qnt; i++){
      xpos[i] = random(0, width);
      ypos[i] = random(0, height);
      stroke(c);
      point(xpos[i], ypos[i]);
      }
    }
  void update(){                            
    for(int i = 0; i<= qnt; i++){
      float spd = random(0, 20);
      float rnd = random(0, 20);            
      if(xpos[i] < dirx-rnd){
        xpos[i] += spd;
        }
      if(xpos[i] > dirx+rnd){
        xpos[i] -= spd;
        }
      if(ypos[i] < diry-rnd){
        ypos[i] += spd;
        }
      if(ypos[i] > diry+rnd){
        ypos[i] -= spd;
        }
      stroke(c);
      point(xpos[i], ypos[i]);
      }
    }
  void setDir(float xd, float yd){
    dirx = xd;
    diry = yd;
    }
  }


As you can see it's really simple (no physics)  but it's also simple to edit it so I think it should be useful.
Here is the link for downloading the code(.zip)  and here is the link for the webdemo(processing.js).

I hope you like this post!

Bye, Dami

venerdì 15 giugno 2012

Processing speedart + ezvid


Today I made my first speedart video:



I hope you like it!
You can see the final result here(I used processing.js).
For mounting the video  I used a free software called Ezvid that it's useful for creating video and slideshow; it also has functions for audio recording from mic, screen capturing, uploading direct to youtube....
Unfortunately I discovered the screen capture function after that I recorded my video so I used another screen recorder.I think that Ezvid it's a really useful software, it's user-friendly, and it has a lot of cool functions.

Bye, Dami

mercoledì 13 giugno 2012

Minus, a cool file sharing service

Today I discovered a service called Minus and in my opinion it is the best file sharing service available for free.
I tried a lot of file sharing services for uploading file for my blog:
-Box
-Google docs
-Megaupload
-Drop Box
and others, but i can say that minus is the best, you have 10 GB of space for free and you can increase it inviting friends.
To get started with Minus you only have to select an username and a password.
To sign up in Minus click this link.
I hope you will try this service and please to sign up use the link above so I'll increase my online storage.

Bye, Dami

Battlefield 3 guida strategica multigocatore [ita]

In questo post vi propongo una guida strategica per il mutligiocatore di battlefield 3 che ho scritto:



Guida strategica multiplayer Battlefield 3

by Damiano Andreghetti (www.ilblogdidami.blogspot.com)


Modalità di gioco:
Nel multiplayer di battlefield 3 possiamo trovare alcune modalità di gioco, questi sono i consigli che vi do per quanto riguarda la scelta della modalità di gioco:

-Deathmatch a squadre/fazioni: lo consiglio solo quando si ha la necessità di fare qualche uccisione per sbloccare armi o piastrine.

-Corsa: modalità basata essenzialmente sul gioco di squadra, va bene se si devono fare punti o se ci si vuole divertire giocando con alcuni amici.

-Conquista: personalmente penso sia la modalità migliore, è caratterizzata dalla necessità di gioco di squadra per vincere; solitamente si fanno un sacco di punti e non troppe uccisioni. La consiglio se si deve giocare con amici o se si ha bisogno di fare punti in fretta.

Classi:
In Battlefield 3 in generale si ha un buon bilanciamento tra le varie classi. Infatti uno scout ha le stesse possibilità di un geniere o di qualcuno che utilizza Supporto. Inoltre il fatto che ogni classe abbia la sua funzionalità in una squadra aumenta le possibilità di fare gioco di squadra con i compagni. Qui c'è una semplice descrizione delle classi:

-Assalto/Medico : questa classe va bene se si vogliono fare tante uccisioni o se vogliamo aiutare i nostri compagni per esempio rianimandoli o offrendogli cure mediche. Questa classe permette l'utilizzo di fucili d'assalto come l'M16A3. In generale con questa classe si fanno tanti punti nelle mappe dove si ha la possibilità di muoversi sempre con i compagni (es.: Operazione Metrò).

-Geniere: adatto per coloro che amano i mezzi di qualunque genere, permette infatti di riparare i veicoli e di distruggere quelli nemici con una serie di diversi lanciarazzi. Inoltre è anche ben equipaggiato per quanto riguarda le armi primarie.

-Supporto: adatto se ci si muove in ambienti stretti o dove comunque si sa che il nemico può arrivare solo da una parte. Questa classe è utile per liberare la strada per l'avanzata dei compagni.
A suo favore ci sono le armi primarie, ovvero delle mitragliatrici leggere con 200 colpi in caricatore. Inoltre è equipaggiato di una cassa per il rifornimento di munizioni e di un equipaggiamento a scelta tra claymore, c4 e un mortaio.

-Scout: se ne scopre l'utilità quando si impara a usarlo bene, infatti permette di uccidere nemici a grandi distanze e se ci si apposta nel modo corretto ci si può mettere a fare fuoco su uno stretto corridoio da cui arrivano i nemici (per esempio in Operazione Metro).

Tattiche migliori:
Se si ha bisogno di fare uccisioni per sbloccare armi, medaglie o piastrine consiglio di giocare a deathmatch a squadre usando l'Assalto, infatti ci sono molti nemici e si gioca in ambienti solitamente ristretti.
Se invece si ha bisogno di punti per salire di livello o per altri motivi un'ottima modalità è conquista, in cui ci sono mezzi da usare (e distruggere) e dove secondo me è più facile fare gioco di squadra, guadagnando punti con rianimazioni, rifornimenti, cure mediche ecc...
Se il vostro scopo è invece diventare un asso degli sniper, vi consiglio di non cercare di fare trick come quickscope o simili, infatti in battlefield lo scout trova grande utilità nei tiri a lunga distanza.

Mezzi:
In battlefield 3 i mezzi hanno sicuramente una grande utilità, ma ci vuole tempo e pratica per imparare ad usarli.
Soprattutto all'inizio è possibile demoralizzarsi e decidere di usarli il meno possibile, infatti come nelle armi nel tempo si sbloccano varie abilità per i mezzi.
Se si ha intenzione di imparare a usare il jet avverto che soprattutto all'inizio si avrà a che fare con altri giocatori probabilmente già esperti e con molti potenziamenti sbloccati.
Probabilmente il mezzo migliore per facilità di utilizzo e versatilità è l'elicottero, infatti se lo si impara a pilotare bene può diventare un ottimo mezzo che può supportare i compagni a terra.

Conclusioni:
concludo questa breve guida dicendo che è inutile fissarsi con l'idea di raggiungere un buon rateo, rischierete solo di innervosirvi quindi è meglio cercare di giocare per divertirsi(anche perchè altrimenti non sarebbe più giocare).

Guida scritta da Damiano Andreghetti
Grazie dell'attenzione, sul sito sono presenti altre guide su black ops e bad company 2


La guida è scaricabile in pdf qui.
Oppure la si può leggere su scribd qui.
Ciao, Dami

lunedì 7 maggio 2012

Processing music frequency visualizer super mario version

Today I'm posting about a new project in processing that uses minim audio library to visualize frequency using super mario tubes.
I think it's cool, here is the code

import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.ugens.*;

Minim minim;
AudioPlayer song;
FFT fft;

String song_file = "song.mp3";
PImage tube_up;
PImage tube_sec;
PImage bg_mario;
int m = 3;

void setup(){
  size(1200, 622);
  tube_up = loadImage("tube_up.png");
  tube_sec = loadImage("tube_sec.png");
  bg_mario = loadImage("bg_mario.png");
  frameRate(60);
  minim = new Minim(this);
  song = minim.loadFile(song_file, 512);
  song.play();
  fft = new FFT(song.bufferSize(), song.sampleRate());
}

void draw(){
  background(bg_mario);
  fft.forward(song.mix);
  stroke(127, 255, 0, 200);
  for(int i = 0; i <= fft.getFreq(80)*m; i++){
    image(tube_sec, 10, height-(10+i));
    }
  image(tube_up, 10, height-(74+fft.getFreq(80)*m));
  for(int i = 0; i <= fft.getFreq(150)*m; i++){
    image(tube_sec, 180, height-(10+i));
    }
  image(tube_up, 180, height-(74+fft.getFreq(150)*m));
  for(int i = 0; i <= fft.getFreq(200)*m; i++){
    image(tube_sec, 350, height-(10+i));
    }
  image(tube_up, 350, height-(74+fft.getFreq(200)*m));
  for(int i = 0; i <= fft.getFreq(300)*m; i++){
    image(tube_sec, 520, height-(10+i));
    }
  image(tube_up, 520, height-(74+fft.getFreq(300)*m));
  for(int i = 0; i <= fft.getFreq(400)*m; i++){
    image(tube_sec, 690, height-(10+i));
    }
  image(tube_up, 690, height-(74+fft.getFreq(400)*m));
  for(int i = 0; i <= fft.getFreq(500)*m; i++){
    image(tube_sec, 860, height-(10+i));
    }
  image(tube_up, 860, height-(74+fft.getFreq(500)*m));
  stroke(255);
}


I think it's a simple sketch so I won't explain how does it function.
You can download the sketch and the file you need to run it here.
You can also try a web version here(java required).
The demo song that I put in the zip folder and that I used in the web version is
Drive Hard - PrototypeRaptor

I hope you like my post, if you have any question please comment or send me an e-mail to damianoandre@gmail.com

Bye, Dami

P.S.:probably next week I'm gonna post about a TV B gone made using arduino and an Attiny85

venerdì 17 febbraio 2012

CODEMOTION THE EVENT OPEN TO ALL LANGUAGES AND TECHNOLOGIES

Codemotion is the event open to all languages and technologies. It is the evolution of Javaday Roma, which after four editions has become the event of the art of programming.
The first edition of Codemotion has been in March 2011 and over 2000 people, 25 communities and 22 sponsor firms have become members.
During Codemotion 2011 there have been 65 talks on: gaming, mobile, hacking,  os, tools, what’s hot, language and innovation.
The second edition of Codemotion will be held on 23rd and 24th March and there will be two main innovations: the lengthening of activities from one to two days and the fact that two events will be held simultaneously in Rome and Madrid.
Codemotion’s program will be defined through Call for Paper which is open to everyone. The proposals’ selection will be done by representatives of the official communities which are connected to both the analysis of language and software development.
During Codemotion, all participants will have the chance to have new professional opportunities by leaving  their CV to the sponsor firms.
We are working on a project to promote the relationship between developers and startups and their synergic work for innovation.
Codemotion will be hosted by the Engineering department of the Third University of Rome.
Entry is free, as always.
For any further information contact us on: http://www.codemotion.it

sabato 11 febbraio 2012

FGES v1.0 released

I released the version 1.0 of FGES(First Grade Equation Solver).
You can download it from here.

I hope you like.
Bye, Dami

venerdì 10 febbraio 2012

Easy Arduino POV

This is a simple project about making a simple POV project using arduino.

What is POV?
 POV stands for Persistence Of Vision and here is a simple definition from wikipedia:
Persistence of vision is the phenomenon of the eye by which an afterimage is thought to persist for approximately one twenty-fifth of a second on the retina.
The POV can be used to write letters simply blinking LEDs.

About the project --> hardware
In the hardware side we only need to connect 7 LEDs to the pins from 2 to 8.

About the project  ---> software
First of all we need an array that contains the matrix of the font that we will write using POV.
This is a simple matrix that we're going to use for the project:

const byte font[][5] = {                     
        {0x00,0x00,0x00,0x00,0x00},   //   0x20 32 0
        {0x00,0x00,0x6f,0x00,0x00},   // ! 0x21 33 1
        {0x00,0x07,0x00,0x07,0x00},   // " 0x22 34 2
        {0x14,0x7f,0x14,0x7f,0x14},   // # 0x23 35 3
        {0x00,0x07,0x04,0x1e,0x00},   // $ 0x24 36 4
        {0x23,0x13,0x08,0x64,0x62},   // % 0x25 37 5
        {0x36,0x49,0x56,0x20,0x50},   // & 0x26 38 6
        {0x00,0x00,0x07,0x00,0x00},   // ' 0x27 39 7
        {0x00,0x1c,0x22,0x41,0x00},   // ( 0x28 40 8
        {0x00,0x41,0x22,0x1c,0x00},   // ) 0x29 41 9
        {0x14,0x08,0x3e,0x08,0x14},   // * 0x2a 42 10
        {0x08,0x08,0x3e,0x08,0x08},   // + 0x2b 43 11
        {0x00,0x50,0x30,0x00,0x00},   // , 0x2c 44 12
        {0x08,0x08,0x08,0x08,0x08},   // - 0x2d 45 13
        {0x00,0x60,0x60,0x00,0x00},   // . 0x2e 46 14
        {0x20,0x10,0x08,0x04,0x02},   // / 0x2f 47 15
        {0x3e,0x51,0x49,0x45,0x3e},   // 0 0x30 48 16
        {0x00,0x42,0x7f,0x40,0x00},   // 1 0x31 49 17
        {0x42,0x61,0x51,0x49,0x46},   // 2 0x32 50 18
        {0x21,0x41,0x45,0x4b,0x31},   // 3 0x33 51 19
        {0x18,0x14,0x12,0x7f,0x10},   // 4 0x34 52 20
        {0x27,0x45,0x45,0x45,0x39},   // 5 0x35 53 21
        {0x3c,0x4a,0x49,0x49,0x30},   // 6 0x36 54 22
        {0x01,0x71,0x09,0x05,0x03},   // 7 0x37 55 23 
        {0x36,0x49,0x49,0x49,0x36},   // 8 0x38 56 24
        {0x06,0x49,0x49,0x29,0x1e},   // 9 0x39 57 25
        {0x00,0x36,0x36,0x00,0x00},   // : 0x3a 58 26
        {0x00,0x56,0x36,0x00,0x00},   // ; 0x3b 59 27
        {0x08,0x14,0x22,0x41,0x00},   // < 0x3c 60 28
        {0x14,0x14,0x14,0x14,0x14},   // = 0x3d 61 29
        {0x00,0x41,0x22,0x14,0x08},   // > 0x3e 62 30
        {0x02,0x01,0x51,0x09,0x06},   // ? 0x3f 63 31
        {0x3e,0x41,0x5d,0x49,0x4e},   // @ 0x40 64 32
        {0x7e,0x09,0x09,0x09,0x7e},   // A 0x41 65 33
        {0x7f,0x49,0x49,0x49,0x36},   // B 0x42 66 34
        {0x3e,0x41,0x41,0x41,0x22},   // C 0x43 67 35
        {0x7f,0x41,0x41,0x41,0x3e},   // D 0x44 68 36
        {0x7f,0x49,0x49,0x49,0x41},   // E 0x45 69 37
        {0x7f,0x09,0x09,0x09,0x01},   // F 0x46 70 38
        {0x3e,0x41,0x49,0x49,0x7a},   // G 0x47 71 39
        {0x7f,0x08,0x08,0x08,0x7f},   // H 0x48 72 40
        {0x00,0x41,0x7f,0x41,0x00},   // I 0x49 73 41
        {0x20,0x40,0x41,0x3f,0x01},   // J 0x4a 74 42
        {0x7f,0x08,0x14,0x22,0x41},   // K 0x4b 75 43
        {0x7f,0x40,0x40,0x40,0x40},   // L 0x4c 76 44
        {0x7f,0x02,0x0c,0x02,0x7f},   // M 0x4d 77 45
        {0x7f,0x04,0x08,0x10,0x7f},   // N 0x4e 78 46
        {0x3e,0x41,0x41,0x41,0x3e},   // O 0x4f 79 47
        {0x7f,0x09,0x09,0x09,0x06},   // P 0x50 80 48
        {0x3e,0x41,0x51,0x21,0x5e},   // Q 0x51 81 49
        {0x7f,0x09,0x19,0x29,0x46},   // R 0x52 82 50
        {0x46,0x49,0x49,0x49,0x31},   // S 0x53 83 51
        {0x01,0x01,0x7f,0x01,0x01},   // T 0x54 84 52
        {0x3f,0x40,0x40,0x40,0x3f},   // U 0x55 85 53
        {0x0f,0x30,0x40,0x30,0x0f},   // V 0x56 86 54
        {0x3f,0x40,0x30,0x40,0x3f},   // W 0x57 87 55
        {0x63,0x14,0x08,0x14,0x63},   // X 0x58 88 56
        {0x07,0x08,0x70,0x08,0x07},   // Y 0x59 89 57
        {0x61,0x51,0x49,0x45,0x43},   // Z 0x5a 90 58
        {0x3c,0x4a,0x49,0x29,0x1e},   // [ 0x5b 91 59
        {0x02,0x04,0x08,0x10,0x20},   // \ 0x5c 92 60
        {0x00,0x41,0x7f,0x00,0x00},   // ] 0x5d 93 61
        {0x04,0x02,0x01,0x02,0x04},   // ^ 0x5e 94 62
        {0x40,0x40,0x40,0x40,0x40},   // _ 0x5f 95 63
        {0x00,0x00,0x03,0x04,0x00},   // ` 0x60 96 64
        {0x20,0x54,0x54,0x54,0x78},   // a 0x61 97 65
        {0x7f,0x48,0x44,0x44,0x38},   // b 0x62 98 66
        {0x38,0x44,0x44,0x44,0x20},   // c 0x63 99 67
        {0x38,0x44,0x44,0x48,0x7f},   // d 0x64 100 68
        {0x38,0x54,0x54,0x54,0x18},   // e 0x65 101 69
        {0x08,0x7e,0x09,0x01,0x02},   // f 0x66 102 70
        {0x0c,0x52,0x52,0x52,0x3e},   // g 0x67 103 71
        {0x7f,0x08,0x04,0x04,0x78},   // h 0x68 104 72
        {0x00,0x44,0x7d,0x40,0x00},   // i 0x69 105 73
        {0x20,0x40,0x44,0x3d,0x00},   // j 0x6a 106 74
        {0x00,0x7f,0x10,0x28,0x44},   // k 0x6b 107 75
        {0x00,0x41,0x7f,0x40,0x00},   // l 0x6c 108 76
        {0x7c,0x04,0x18,0x04,0x78},   // m 0x6d 109 77
        {0x7c,0x08,0x04,0x04,0x78},   // n 0x6e 110 78
        {0x38,0x44,0x44,0x44,0x38},   // o 0x6f 111 79
        {0x7c,0x14,0x14,0x14,0x08},   // p 0x70 112 80
        {0x08,0x14,0x14,0x18,0x7c},   // q 0x71 113 81
        {0x7c,0x08,0x04,0x04,0x08},   // r 0x72 114 82
        {0x48,0x54,0x54,0x54,0x20},   // s 0x73 115 83
        {0x04,0x3f,0x44,0x40,0x20},   // t 0x74 116 84
        {0x3c,0x40,0x40,0x20,0x7c},   // u 0x75 117 85
        {0x1c,0x20,0x40,0x20,0x1c},   // v 0x76 118 86
        {0x3c,0x40,0x30,0x40,0x3c},   // w 0x77 119 87
        {0x44,0x28,0x10,0x28,0x44},   // x 0x78 120 88
        {0x0c,0x50,0x50,0x50,0x3c},   // y 0x79 121 89
        {0x44,0x64,0x54,0x4c,0x44},   // z 0x7a 122 90
        {0x00,0x08,0x36,0x41,0x41},   // { 0x7b 123 91
        {0x00,0x00,0x7f,0x00,0x00},   // | 0x7c 124 92
        {0x41,0x41,0x36,0x08,0x00},   // } 0x7d 125 93
        {0x04,0x02,0x04,0x08,0x04},   // ~ 0x7e 126 94
    };


Then we need to set the pin in the setup() function:


void setup(){
  for(int i = 2; i <= 8; i++){ //I set the digital pin from 2 to 8 as OUTPUT pins
    pinMode(i, OUTPUT);
    }
  for(int i = 2; i <= 8; i++){ //I turn off the pins
    digitalWrite(i, LOW);
    }
  }


Now we have to use 2 for(;;) cycles, one for write each column (in this case 5, it depends from the matrix) and the other one for each row (or each LED). Now we use the bitRead() function to read the bit of a row and to turn on the LED if the bit value is 1.

void loop(){
  for(int col = 0; col < 5; col++){ //for each column
    for(int row = 0; row <=6; row++){ //and for each row  in a column:
      int val = bitRead(font[33][col], row); //I read the bit of the "A" byte at the current column and in the current row
      if(val==1){
        digitalWrite(row+2,  HIGH); // if the bit value is 1 I turn on the LED that represents the row
        }
      else{
        digitalWrite(row+2, LOW); // if the bit value is  0 I turn off the LED
        }
      }
      delay(3); //before starting  with the next column I delay 5 milliseconds
    }
    delay(100);
  }


You can download the full code at this link.

Here are some photos of the project:






I hope you enjoy this project, for more info comment or send me an e-mail to damianoandre@gmail.com

Bye, Dami

martedì 31 gennaio 2012

Processing Text-image generator Processing

This is a simple post about a processing sketch that makes you able to generate from a normal image an image like this, formed by letter/numbers of differents colors.




This is the processing sketch:

PImage img;
String txt = "hello"; //here goes your text
float spacex = txt.length()*2.9;

//you should need to recalibrate this variable
float spacey = 5.0;

void setup(){
  img = loadImage("img2.jpg");
  size(img.width*2, img.height*2);
  noStroke();
  background(255);
  smooth();
  }

void draw(){
  for(int xpix = 0; xpix <= img.width; xpix += spacex){
    for(int ypix = 0; ypix <= img.height; ypix += spacey){
      color pixcol = img.get(xpix, ypix);
      fill(pixcol);
      text(txt, int(map(xpix, 10, img.width, 10, img.width*2)), int(map(ypix, 10, img.height, 10, img.height*2)));
      }
    }
    saveFrame("img-text.jpg");
  }


This sketch simply create the image getting the color of the processed pixel and save the final result (saveFrame) as an image.
This sketch can generate from this image:

this image:


I hope you like this post, if you have questions comment or send me an e-mail to damianoandre@gmail.com

Bye, Dami

P.S.:the sketch it's calibrated to wite "0" but if you want to write something else you have to recalibrate some things.