Thursday, December 5, 2013

Microcontroller Play Kit

This board is to help you familiarize yourself with basic of embedded electronics. It consist of a micro-controller and other input/output devices which you can play with.

Features

- It has a Attiny44 micro-controller. The board is designed to use internal RC oscillator which runs at 1MHz frequency.
- It can be powered from the USB or FTDI cable. Before powering from FTDI cable, remove the 0ohm jumper resistor.
- It has inbuilt USB over current protection (if you use PTC fuse) to provide extra layer of protection for your USB port.
- In-board ISP connector to programming micro-controller.
- It has a RGB LED connected to pins (R-PA5, G-PA4 and B-PA1)
- It has a Switch connected to PA1 (Note that since switch and Blue led in RGB led shares a common pin, they can not be used simultaneously)
- It has Thermistor connected to pin PA7 for temperature measurement.
- Push-button switch connected to pin PA1
- Photo-transistor connected to pin PA0
- TX/RX pin for serial port interface or I2C
- 4 extra pin available for interfacing other devices.


Making HellouC Board

Mill your board using the files below



Notes about Stuffing the Board (see the image of stuffed board for reference)
- All the standard components are marked in above board (resistors and capacitors)
- THR is thermistor (has no polarity)
- AVRISP is six pin avrisp connector
- PT is photo-transistor (it has polarity, the collector (marked with two green mark in component) should be connected PA0 (pin13 of uC)
- RGB is rgb led (it has polarity, see the image of stuffed board)
- PTC is PTC fuse used to provide extra protection. If you don't have simply put 0ohm resistor.



Sample Programs

Blink Led

 /*
* Author: Prashant Patil
* Date: 12/05/2013
* This code is to blink LED connected to PA5
*/

#define F_CPU 1000000UL
#include
#include
#include

/*Macros definition*/
#define BIT(x)    (1 << (x))            //Set a particular bit mask
#define CHECKBIT(x,b) x&b            //Checks bit status
#define SETBIT(x,b) x|=b;            //Sets the particular bit
#define CLEARBIT(x,b) x&=~b;        //Clears the particular bit
#define TOGGLEBIT(x,b) x^=b;        //Toggles the particular bit

int main(void)
{
    SETBIT(DDRA,BIT(5))            //Sets Direction of 5th pin of port A as output for driving LED

    while(1)
    {
        SETBIT(PORTA,BIT(5))    //Sets PORTA5 as high i.e. turn on led
        _delay_ms(100); //delay
        CLEARBIT(PORTA,BIT(5))    //Clears PORTA5(PA5 pin goes low) i.e turn off led
        _delay_ms(100); //delay
    }
}

  Rainbow

Switch

 /*
 * Author: Prashant Patil
 * Date: 12/05/2013
 * This code is to turn on red LED when switch is pressed.
 */

 #define F_CPU 1000000UL
 #include
 #include
 #include

 /*Macros definition*/
 #define BIT(x)    (1 << (x))            //Set a particular bit mask
 #define CHECKBIT(x,b) x&b            //Checks bit status
 #define SETBIT(x,b) x|=b;            //Sets the particular bit
 #define CLEARBIT(x,b) x&=~b;        //Clears the particular bit
 #define TOGGLEBIT(x,b) x^=b;        //Toggles the particular bit

 int main(void)
 {
     SETBIT(DDRA,BIT(5))            //Sets Direction of 5th pin of port A as output for driving LED
     CLEARBIT(DDRA,BIT(1))          //Sets Direction of 1st pin of port A as input for sensing Switch
   
     while(1)
     {
       
        if(CHECKBIT(PINA,BIT(3))) //Check 3rd bit in PINA register
        {
            SETBIT(PORTA,BIT(5))    //Sets PORTA5 as high i.e. turn on led
        }
        else
        {
             CLEARBIT(PORTA,BIT(5))    //Clears PORTA5(PA5 pin goes low) i.e turn off led
        }
       
       
     }
 }

Measure Temperature

Ambient Light Sensor

  #define F_CPU 1000000UL
 #include
 #include
 #include

 /*Macros definition*/
 #define BIT(x)    (1 << (x))            //Set a particular bit mask
 #define CHECKBIT(x,b) x&b            //Checks bit status
 #define SETBIT(x,b) x|=b;            //Sets the particular bit
 #define CLEARBIT(x,b) x&=~b;        //Clears the particular bit
 #define TOGGLEBIT(x,b) x^=b;        //Toggles the particular bit

 int main(void)
 {
     SETBIT(DDRA,BIT(4))            //Sets Direction of 5th pin of port A as output for driving LED
     CLEARBIT(DDRA,BIT(0))          //Sets Direction of 1st pin of port A as input for sensing Photo-transistor
    
     while(1)
     {
      
        if(CHECKBIT(PINA,BIT(0))) //Check first bit in PINA register
        {
           
            SETBIT(PORTA,BIT(4))    //Sets PORTA4 as high i.e. turn on led
        }
        else
        {
             CLEARBIT(PORTA,BIT(4))    //Clears PORTA4(PA4 pin goes low) i.e turn off led
        }
        
        
     }
 }

 Remote-Control Through PC  

 

To do for Next Version

- Change USB connector type
- Add an SMD buzzer
- Add a potentiometer
- Add port pins for external interface.


No comments:

Post a Comment