Arduino

Arduino (주차장 프로젝트)

ElectricShock 2013. 1. 10. 10:16

 

 

Practical Arduino Cool Projects For Open Source Hardware (Technology In Action).pdf

Arduino는 오픈소스를 기반으로한 Physical Computing Platform으로,

AVR을 기반으로한 보드와 소프트웨어를 기반으로한 통합환경 IDE를 제공한다.

 http://arduino.cc/en/Main/Software        (☜ Program Download ....FreeWare)

 

 

 


Arduino Parking Lot (주차장 시스템)

 

(▽원리 = Principle) 

 

 

Each line means... ▽

Negative

Positive

Control

 

Refer to YouTube below...

 

 

 

Arduino-Diecimila-schematic.pdf

 

 

 

 

Coding...

/*ParkingL02.pde
Arduining.com 08 JUL 2012
Code used in the production of the Youtube material.
*/

#include <Servo.h>
Servo myservo;              // create servo object to control a servo

#define ServoM    12        //Connected to the servo motor.
#define Bright    11        //servo library disable PWM on pins 9 and 10.
#define Exit      9         //Pin connected to the EXIT button.
#define In        8         //Pin connected to the IN button.

#define BarLow    177       //Low position of the barrier.
#define BarUp     95        //Up position of the barrier.
#define CAPACITY  8         //Capacity of the parking lot.
#define INTEN     80        //Display intensity %

//Pins conections to segments (cathodes). ........핀들은 연결된다.☞ 7세그먼트 Cathode에.
#define  segA  0
#define  segB  1
#define  segC  2
#define  segD  3
#define  segE  4
#define  segF  5
#define  segG  6

//Array with the segments to represent the decimal numbers (0-9).
byte segments[10] = {
// pgfedcba  <--- segments

//p = 0 <-- 사용하지 않으므로(Unused)


  B00111111, // number 0
  B00000110, // number 1
  B01011011, // number 2
  B01001111, // number 3
  B01100110, // number 4
  B01101101, // number 5
  B01111101, // number 6
  B00000111, // number 7
  B01111111, // number 8
  B01101111  // number 9
};

void setup(){
  myservo.attach(ServoM);          // attaches the servo.

  pinMode(Exit, INPUT);           // set "EXIT" button pin to input
  pinMode(In, INPUT);             // set "IN" button pin to input
  digitalWrite(Exit, HIGH);       // Connect Pull-Up resistor.
  digitalWrite(In, HIGH);         // Connect Pull-Up resistor.
  pinMode(segA,OUTPUT);
  pinMode(segB,OUTPUT);
  pinMode(segC,OUTPUT);
  pinMode(segD,OUTPUT);
  pinMode(segE,OUTPUT);
  pinMode(segF,OUTPUT);
  pinMode(segG,OUTPUT);
  pinMode(Bright,OUTPUT);
  analogWrite(Bright,255*INTEN/100);
  myservo.write(BarLow);          //Barrier in the low position
//  delay(1000);
}

int  Available= 9;                    // Number of places available.

//================================================================ ▽ 이하 메인코드
void loop(){
Display(Available);
if(digitalRead(In)==0)

{
  if(Available != 0){
    Available--;
    myservo.write(BarUp);
    delay(3000);
    myservo.write(BarLow);
    }
  }
if(digitalRead(Exit)==0)
{
  if(Available != CAPACITY){
    Available++;
    myservo.write(BarUp);
    delay(3000);
    myservo.write(BarLow);
    }
  }
}

/*-------------------------------------------------------------------
Put the segments according to the number.
--------------------------------------------------------------------*/
void Display(int number){
byte segs =  ~segments[number];        //"~" is used for commom anode.

digitalWrite(segA, bitRead(segs, 0) );
digitalWrite(segB, bitRead(segs, 1) );
digitalWrite(segC, bitRead(segs, 2) );
digitalWrite(segD, bitRead(segs, 3) );
digitalWrite(segE, bitRead(segs, 4) );
digitalWrite(segF, bitRead(segs, 5) );
digitalWrite(segG, bitRead(segs, 6) );
}

 


 

sketch_jan10a.cpp.hex(△위 coding을 통해 생성된 파일)

 

How to generate Hex File.

http://arduino.cc/forum/index.php/topic,46866.0.html

Hold "Shift"key,

then click the Upload button.

You can find the .hex file in the follwing path.

경로 ▽

C\Documentss and Settings\Administrator\Local Settings\Temp\buildXXXXX.tmp\XXXXX.ccp.hex.

(검색이 안되므로 직접 경로를 찾아갈것)

(이 hex파일을 Proteus의 MCU에 upload한다.)

The windows tempory file is hidden.

 

 


Proteus (Set >> Sheet Size...)

 

작업공간 조절가능 !!!

(You can make your workspace bigger enough.!!!)

 


사용하는 푸품들 (=Using parts)

  • IC1 Atmel ATmega328 MCU
  • C1 0.1 uF ceramic capacitor
  • C2,C3 22 pF ceramic capacitor
  • Q1 16 MHz crystal
  • R1 10k 5% 1/4W resistor
  • R2 330 5% 1/4W resistor
  • LED1 5mm red LED
  • S1 Momentary pushbutton switch
  • SV1 10 pin shielded header or dual row header
  • X1 6 pin Molex KK100 or single row header
  • Not shown
    • Perfboard
    • 28-pin socket
    • Power supply.

     

    .

    .

     


    Bus Wire Usage (How to use Bus Wire in Proteus)

     

    Q: How to use Bus_Wire in Proteus ?

    A: Draw the bus >> Connect the bus and a pin >>Give it a label >> Give another one same lable.

     


    Arduino Simulation with Proteus

    http://www.youspice.com/ys/gettingstartedwithproteus.3sp?pageNum=4

     

    Here is spilt in 6 pages.

    You can find complete guide here.

    1. ATMEGA328P를 찾는다.

    2. Crystal과 Capacitor를 찾는다.

    3. 더블클릭한다. on the Crystal을 & Set the frequency to 16MHz.

    4. Then also set the values of Capacitors.

    5. 최종 완성 회로

    6. Download the software from the Arduino site. & Run it.

    7. After compiling your code, browse the hex file you made.

    8. Upload the hex file on the MCU

       and then select the following settings:

     

     

     

     

    9. 끝!

     


    Refer to both pictures below to figure out what the placement of the pinout.