February 10, 2010

ゴム銃競技用ポケット・タイマー

久しぶりにゴム銃競技用ポケット・タイマーを作ってみました。
今回は受け狙いでALTOIDSの缶に入れ、単三電池1本で動くように設計してみました。



プログラムは以下に置いておきますので参考にしてください。
なお、回路の概略は、
・LEDはポートから電流制限抵抗を通してGNDに接続。
・スイッチは10kΩでプルアップし、アクティブ・ローで動作。
・圧電素子は、ポートとGND間に接続。
・1.5Vを5VにアップするDC-DCコンバータを使用。
です。そのうち、時間がとれたら回路図を書いてアップします。


このプログラムの商業目的での利用はお断りします。

/* R.B.G. Pocket Timer Ver.1.11(Arduino0018)
coded by kiyoshi sasano 2010.02.10 */

byte soundPin = 3; //buzzer
byte startPin = 1; //start switch
byte selectPin = 0; //mode select switch

byte LED01Pin = 10; //LED 1 - 10
byte LED02Pin = 11;
byte LED03Pin = 12;
byte LED04Pin = 13;
byte LED05Pin = 14;
byte LED06Pin = 15;
byte LED07Pin = 16;
byte LED08Pin = 17;
byte LED09Pin = 18;
byte LED10Pin = 19;

byte sw_new;
byte sw_old;
byte sw_status;

byte soundSW;

byte timeStep, tStep;
byte countDown;

const byte mask = 0x02;

void ledOnOff(byte j, byte k)
{
switch(j)
{
case 10: digitalWrite(LED10Pin, k);
break;
case 9: digitalWrite(LED09Pin, k);
break;
case 8: digitalWrite(LED08Pin, k);
break;
case 7: digitalWrite(LED07Pin, k);
break;
case 6: digitalWrite(LED06Pin, k);
break;
case 5: digitalWrite(LED05Pin, k);
break;
case 4: digitalWrite(LED04Pin, k);
break;
case 3: digitalWrite(LED03Pin, k);
break;
case 2: digitalWrite(LED02Pin, k);
break;
case 1: digitalWrite(LED01Pin, k);
break;
default: break;
}
}

void setup() //ポートの初期設定
{
pinMode(soundPin, OUTPUT);
pinMode(startPin, INPUT);
pinMode(selectPin, INPUT);

for(byte i = LED01Pin; i <= LED10Pin; i++)
{
pinMode(i, OUTPUT);
digitalWrite(i, LOW);
}

if(digitalRead(selectPin) == HIGH)
{
tone(soundPin, 4000, 200);
}
else
{
tone(soundPin, 2000, 200);
}
sw_old = PIND & mask;
}

void loop()
{
sw_new = PIND & mask;
sw_status = (sw_new ^ sw_old) & sw_new;
sw_old = sw_new;

if(sw_status)
{
soundSW = 0;

if(digitalRead(selectPin) == HIGH)
{
timeStep = 6;
}
else
{
timeStep = 3;
}

for(int i = 1; i <= 10; i++)
{
ledOnOff(i, HIGH);
}

tone(soundPin, 4000, 500);
delay(1000);

countDown = 10;

while(countDown != 0)
{
if(countDown == 10)
{
tStep = timeStep - 1;
}
else
{
tStep = timeStep;
}

for(byte i = 0; i < tStep ; i++)
{
if(countDown > 2)
{
ledOnOff(countDown, LOW);

if(soundSW == HIGH)
{
tone(soundPin, 2252, 50);
soundSW = LOW;
}
else
{
tone(soundPin, 2000, 50);
soundSW = HIGH;
}

delay(500);
ledOnOff(countDown, HIGH);
delay(500);
}
else
{
ledOnOff(countDown, LOW);
tone(soundPin, 2252, 50);
delay(250);
ledOnOff(countDown, HIGH);
delay(250);
ledOnOff(countDown, LOW);
tone(soundPin, 2000, 50);
delay(250);
ledOnOff(countDown, HIGH);
delay(250);
}
}

ledOnOff(countDown, LOW);
countDown--;
}

tone(soundPin, 4000, 2000);
}

delay(10);
}
Posted by onchanks at 22:25:13 | from category: Arduino | DISALLOWED (TrackBack) TrackBacks
Comments

onchanks:

某所で好評だったので調子に乗ってもう二つ作ってしまいました。
まあゴム銃関係者しか喜ばないでしょうから、ゴム銃関係の何かのお礼にでも使います。
(February 21, 2010 17:13:55)

フォレスト:

素晴らしい出来映えですよ!
プログラムも凝っていて楽しいですね。
ソースは読んでみたものの、さっぱり理解できませんでした。(^^;;;
おおよその見当は付くのですが、、、(笑)
1つだけ変更したいとしたら、計測中でも、スタートスイッチを押したら、再度計測が始まるといいのかなぁと言う点です。割り込み処理になるのかわかりませんが、私じゃどこをどう直すのか??
(March 05, 2010 12:32:33)

onchanks:

今までの公式タイマーには組み込んでいましたが、最近の競技でこの機能があることによっていろいろと問題を起こしている気がしてるのでこのタイマーには再計測の機能はわざと組み込んでいません。
本来だと割り込み処理で時間計数を行うべきなのですが、プログラムに慣れていない方には割り込む処理が理解しづらいので単なるディレイで時間を決めています。
(March 05, 2010 12:46:37)

sustanon:

well worth the read. I found blog.onchan.info very informative as I have been researching a lot lately on practical matters such as you talk about
(December 03, 2011 03:26:54)

electric glass insulators:

Its Pleasure to understand blog.onchan.info. The above articles is pretty extraordinary, and I really enjoyed reading your blog and points that you expressed. I really like to appear back over a typical basis,post a lot more within the topic. Thanks for sharing
(May 02, 2012 01:36:17)

escorts UAE:

I really wanted to send a small word to say thanks to you for the fantastic points you are writing on blog.onchan.info. My time-consuming internet lookup has at the end been honored with extremely good ideas to exchange with my pals. I
(July 05, 2012 18:42:57)

Appliance repair Santa Monica:

hello blog.onchan.info and thank you for your info
(July 13, 2012 23:48:34)

escort girl Oslo:

非常に有益なポスト。おかげで私たちとあなたの見解を共有するために時間を割いてblog.onchan.info 。よろしくお願いいたします!
(September 08, 2012 17:03:13)

escort girls France:

magnifiques soumettre, très instructif. Je me demandais pourquoi les experts opposé de ce secteur ne remarquent pas cela. Vous devez continuer votre écriture. Je suis sûr, blog.onchan.info ont une base de lecteurs énorme déjà!
(September 25, 2012 14:04:06)

escort girls dubai:

Hello, would you mind sharing which blog platform you’re using? I’m going to start my own blog soon but I’m having a tough time deciding between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design and style on blog.onchan.info seems different then most blogs and I’m looking for something completely unique. P.S Apologies for being off-topic but I had to ask!
(October 27, 2012 15:18:50)

seo tools:

Its Pleasure to understand blog.onchan.info. The above articles is pretty extraordinary, and I really enjoyed reading your blog and points that you expressed. I really like to appear back over a typical basis,post a lot more within the topic. Thanks for sharing…keep writing!!! and wish you all the best in the 2013!
(January 01, 2013 15:46:53)

Dubai escorts:

Je veux créer un blog wordpress à où je peux partager des photos, des gens télécharger des photos et tout le monde peut les évaluer. Quelqu'un peut-il recommander un bon thème ou quelques conseils? Libre est préférée ou similaire, moins de 100 $ .. . Merci!.
(January 09, 2013 11:45:07)

вибропогружатель на экскаватор:

Comment appliquer un thème wordpress téléchargés à partir d'autres sites?
(January 16, 2013 03:37:17)

moroccan escorts in dubai:

Salut , Vous avez effectué un travail incroyable . Je vais certainement digg it et individuellement recommander à mes amis . Je suis sûr qu'ils vont être bénéficié de ce site. meilleurs vœux
(April 04, 2013 08:06:23)

call girls Paris:

Bravo et merci pour cette descripition ! Une question : Peut-on faire des stats sur les clics ? A savoir peut-on savoir combien de fois les gens ont cliqué sur telle annonce ? Merci d’avance pour la réponse. Yvon .Yvon de Copywriting Pratique recently posted..6 astuces de copywriting pour booster votre blog
(April 20, 2013 08:05:03)

anabolic steroids:

Dès que j'ai remarqué ce site je suis allé sur reddit partager une partie de l'amour avec eux. ;) ;)
(April 21, 2013 08:14:42)

Paris escort service:

Hair Capsicum has hair development maximizing proficiency. .It cannot merely put a stop to hair fall .season but probably help and support within preserving coarse hair. .This kind of pills seems to have enticed a lot of storage devices care to the fact .it’s being utilized by the best stars. Except when typically the cases are usually valid it wouldn’t were agreed on from the celebs since virtually every 1 among us realise that the particular super stars have a lot of significantly .more desire to be slim and additionally lead in the same manner too much fat burning. .Spot for you to does capsiplex work is in the merchant retailer or perhaps .by the stores. You can also buy right from the nation’s brands.
(May 02, 2013 14:04:37)

Paris escort:

Et ben alors ce Blog? .Déjà découragé? .(Je sais, je te suit sur Facebook et tu es bien occupé). .J’avais juste envie de jeter un pavé dans la marre… :-p .Bonne continuation. .Ps: J’ai dévoré ce bouquin, Bravo.
(May 15, 2013 05:21:16)

anabolic creatine:

Enjeux énormes sur blog.onchan.info . Je suis très satisfait de scruter votre article. Merci beaucoup et je cherche avant de vous toucher . Allez- vous déposer gentiment moi un mail ?
(September 26, 2013 23:04:31)

anabolic steroids forum:

Un tel site Web instructif! Grands mercis! Merci pour un bon moment visiter blog.onchan.info . C'est vraiment un plaisir de compréhension d'un site web comme celui-ci rempli de belle information. Merci !
(October 02, 2013 19:57:42)
:

:

Trackbacks
DISALLOWED (TrackBack)