Brian2898 2 Posted June 21, 2011 Share Posted June 21, 2011 By popular demand //MSP430 Annoyatron //Brian Gorman 2011 #include int i=0; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT P1DIR |= 0x32; // P1.5 output CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = 32767; TACTL = TASSEL_1 + MC_1; // ACLK, upmode P1OUT = 0x00; int flow=0; int delays[]= {59,531,259,472,118,59,177,354,177}; while(1) { if (i>(delays[flow])) { P1OUT ^= 0x32; // Toggle P1.5 long z = 65000; // Delay do (z--); while (z != 0); P1OUT ^= 0x32; i=0; if (flow>9) flow=0; else flow++; } _BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/ interrupt } } // Timer A0 interrupt service routine #pragma vector=TIMERA0_VECTOR __interrupt void Timer_A (void) { i++; _BIC_SR_IRQ(LPM3_bits); } :evil: Quote Link to post Share on other sites
geoper2 0 Posted June 22, 2011 Share Posted June 22, 2011 lol i need to try this its evil :twisted: thanks for sharing Quote Link to post Share on other sites
bluehash 1,581 Posted June 22, 2011 Share Posted June 22, 2011 Hello Brian, If you make a few more posts, You can put this in the Project of the Month contest. Last day is tomorrow. A video of the Annoyatron would be awesome! Quote Link to post Share on other sites
lastaid 15 Posted June 25, 2011 Share Posted June 25, 2011 hey brian i just played with your source a little. i really like the annoyatron, wanted to plant one on a friend for quite some time. i made a little change which would make it completly impossible for someone to anticipate a beep. it uses a prng to generate the delays rrather then an array, this way its way less predictable. maximum delay is capped to 511 seconds using the bitshift [ from the 16bit unsigned to a more reasonable value ] have fun #include "msp430g2231.h" #define PIEZO BIT6 unsigned short lfsr = 0xACE1u; unsigned period = 0; unsigned int getRnd (void); int i=0; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT P1DIR |= PIEZO; // P1.5 output CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = 32767; TACTL = TASSEL_1 + MC_1; // ACLK, upmode P1OUT = 0x00; unsigned int delay = 10; while(1) { if (i>delay) { P1OUT ^= PIEZO; // Toggle P1.5 long z = 65000; // Delay do (z--); while (z != 0); P1OUT ^= PIEZO; i=0; delay = getRnd() >> 7; } _BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/ interrupt } } // Timer A0 interrupt service routine #pragma vector=TIMERA0_VECTOR __interrupt void Timer_A (void) { i++; _BIC_SR_IRQ(LPM3_bits); } unsigned int getRnd () { lfsr = (lfsr >> 1) ^ (-(lfsr & 1u) & 0xB400u); ++period; return lfsr; } kylej1050 and 1HzCoder 2 Quote Link to post Share on other sites
bluehash 1,581 Posted June 25, 2011 Share Posted June 25, 2011 Is there any way you could post a video or a soundclip? I'm waiting to hear this. :mrgreen: Quote Link to post Share on other sites
GeekDoc 226 Posted June 25, 2011 Share Posted June 25, 2011 DEFINITELY making one or two of these! :twisted: Quote Link to post Share on other sites
zeke 693 Posted June 25, 2011 Share Posted June 25, 2011 Uhm... What is it? :oops: Quote Link to post Share on other sites
gordon 229 Posted June 25, 2011 Share Posted June 25, 2011 ThinkGeek product page Quote Link to post Share on other sites
Brian2898 2 Posted June 25, 2011 Author Share Posted June 25, 2011 bluehash 1 Quote Link to post Share on other sites
zeke 693 Posted June 26, 2011 Share Posted June 26, 2011 I'm glad I don't work in your office. I think that thing would drive me to Vlad the Impaler mode. Quote Link to post Share on other sites
bluehash 1,581 Posted June 26, 2011 Share Posted June 26, 2011 hmmm.Did miss it.. I kind of heard only two beeps, or may be I'm missing the point. Quote Link to post Share on other sites
zeke 693 Posted June 26, 2011 Share Posted June 26, 2011 ThinkGeek product page This description is the one I would fear most. The youtube video triggered my tl;dr filter. Quote Link to post Share on other sites
Brian2898 2 Posted June 26, 2011 Author Share Posted June 26, 2011 hmmm.Did miss it.. I kind of heard only two beeps, or may be I'm missing the point. Yeah, it's not a very interesting video. The point is to stash it near a co-worker or something along those lines and over time these beeps will start compounding in their minds and annoying them. Ideally you will want to have a speaker at an annoying frequency. lastaid 1 Quote Link to post Share on other sites
lastaid 15 Posted June 27, 2011 Share Posted June 27, 2011 hi again, fixed my code ^^ brian: do you use piezo that automaticly generates a sound? because your code just turn port 1.6 on, then off without any PWM second: as the code uses timerA, can i use a value line device with only one timer to generate sound AND timing with one Timer ? anyway, here is my code, which is completly based on brians code https://gist.github.com/1049184 it uses an http://en.wikipedia.org/wiki/Linear_feedback_shift_register to generate the delays and silly wait loops to generate PWM. have fun Brian2898 and bluehash 2 Quote Link to post Share on other sites
sergiocampama 7 Posted June 27, 2011 Share Posted June 27, 2011 I'm not really sure how a piezo works, but i think you just power it and it generates sound, so no PWM is needed. I also made a twist to the annoyatron on https://github.com/sergiocampama/Launch ... Annoyatron it now works only in low power mode, i don't really like whiles to wait. I also set the PIEZO as the green led, because i don't have a piezo with me right now, but changing it to the actual pin is trivial proper credit given to this post Brian2898 and bluehash 2 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.