• 検索結果がありません。

gattai led hotaru 最近の更新履歴 kaimunantai gattai led hotaru

N/A
N/A
Protected

Academic year: 2018

シェア "gattai led hotaru 最近の更新履歴 kaimunantai gattai led hotaru"

Copied!
4
0
0

読み込み中.... (全文を見る)

全文

(1)

Bread board Challenge 2012

[BC12-02] Gattai LED Hotaru

#1 3-LED Module

(1) Parts

(2) Layout

(3) Schematic

1

( ) 3-

a

LED Module

( )

b Assembled Modules

(2)

(4) Firmware Source Code

// Gattai LED Hotaru

// INT0 : Falling Edge Int. by Optical transistor 0:Blight 1:Dark // INT1 : Falling Edge Int. by Aux Input

// PD0 : Buzzer

// PD1 : Aux.Signal Output

// PB0, PB1, PB2 : LED1,2,3 1:OFF 0:ON

#include <avr/io.h> #include <avr/interrupt.h>

// Light Pattern ID

#define P_STANDBY 0x00 #define P_SHIFT 0x01 #define P_BLINK 0x02

// Buzzer Control ID #define ON 0x01 #define OFF 0x00

// Initial Light Pattern

volatile int PATTERN = P_STANDBY;

void wait(volatile long i) {

while (i-- > 0); }

void buz(char c) // buzzer control {

switch (c) { case ON:

PORTD |= (1<<PD0); break;

case OFF:

PORTD &= ~(1<<PD0); break;

} }

void beep(int length, int height) // beep !

{

volatile long i, j;

for ( i = 0; i <length; i++) { buz(ON);

for ( j = 0; j < height; j++); buz(OFF);

for ( j = 0; j < height; j++); }

(3)

}

void led(int led1, int led2, int led3) // led light on / off

// led1,2,3 : 0...OFF, 1...ON {

PORTB |= (1<<PB0) | (1<<PB1) | (1<<PB2) ;

PORTB &= ~( (led1<<PB0) | (led2<<PB1) | (led3<<PB2) ); }

void auxout(void)

// Output Auxiliary Signal {

PORTD |= (1<<PD1); wait(100); PORTD &= ~(1<<PD1); wait(10000); }

void pattern(int no) // Light Pattern Control {

int i; switch (no) {

case P_SHIFT:

led(1, 0, 0); wait(10000); led(1, 1, 0); wait(10000); led(1, 1, 1); wait(10000); led(1, 1, 0); wait(10000); led(1, 0, 0); wait(10000); led(0, 0, 0); wait(10000); break;

case P_BLINK:

for ( i = 0; i < 3; i++) {

led(0, 0, 0); wait(20000); led(1, 1, 1); wait(20000); }

break; default:

led(0, 0, 0); wait(200000); }

}

ISR(INT0_vect)

// Interrupt 0 : Optical Transistor input {

beep(100, 10); switch (PATTERN) {

case P_STANDBY:

PATTERN = P_SHIFT; auxout();

break; default :

PATTERN = P_STANDBY; }

pattern(PATTERN);

(4)

}

ISR(INT1_vect)

// Interrupt 1 : Arrival Auxiliary Signal from Another Module {

beep(50, 5); switch (PATTERN) {

case P_STANDBY:

PATTERN = P_SHIFT; break;

case P_SHIFT:

PATTERN = P_BLINK; break;

case P_BLINK:

PATTERN = P_SHIFT; break;

}

pattern(PATTERN); auxout();

}

int main(void) {

// Initialize I/O Port PORTD = 0xff;

DDRD = (1<<PD0) | (1<<PD1) | (0<<PD2) | (0<<PD3); DDRB = (1<<PB0) | (1<<PB1) | (1<<PB2) | (1<<PB4);

// Intialize Interrupt MCUCR |= (1<<ISC01); MCUCR &= ~(1<<ISC00); GIMSK |= (1<<INT0);

MCUCR |= (1<<ISC11); MCUCR &= ~(1<<ISC10); GIMSK |= (1<<INT1);

// STANDBY

led(1, 1, 1); wait(10000);

// Interrupt Enable sei();

// Start Sequence beep(400, 2); while (1); return 0; }

参照

関連したドキュメント

The lower two bits are used to assign the NCV7430 to one of four groups for the color setting, while the upper two bits are used to assign the device to one of four groups for

The compensation pin (COMP) of all boosters is connected together to the same compensation network, to equalize the power distribution of each booster (booster phases work with

• Primary Side Constant Current Control: thanks to a proprietary circuit, the controller is able to take into account the effect of the leakage inductance of the transformer and

Figure 28 to Figure 31 shows current harmonics measured using actual rated LED loads.

Figure 30 to Figure 33 shows current harmonics measured using actual rated LED loads.

タッチON/OFF判定 CinX Data Registerの更新 Result Data 1/2 Registerの更新 Error Status Registerの更新 Error Status Channel 1/2 Registerの更新 (X=0,1,…,15).

SCILLC makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does SCILLC assume any liability arising out of

Should Buyer purchase or use ON Semiconductor products for any such unintended or unauthorized application, Buyer shall indemnify and hold ON Semiconductor and its officers,