Zombie Attack! Easy to Build!
by simonfrfr in Circuits > Electronics
34272 Views, 74 Favorites, 0 Comments
Zombie Attack! Easy to Build!
Hello, I am here, presenting you, another project, which is low in cost, that is easy to build. Zombies are attacking, and you need a way to defend against them, so you decide to build the zombie rifle to defend against Zombies. Overall, this project is a low cost, quick build. Most if not all of the materials, you can buy at Radio Shack, or Sparkfun. No, this project is not on an Arduino, because the next step of this project, is to bare-bones it. You will be using the cheapest development board known to man, it is by Texas Instruments; yes, TI is a calculator company, but they also manufacture cool development kits. The name of the Development kit is MSP430 LaunchPad; which you can order at the TI E-Store or Sparkfun, or really any other major electronics distributor. It costs about $6 by the way, and it comes with one of the chips you will use, and another free chip, which you can use for any other project.
**Please click on the orange vote ribbon in the upper right-hand corner of this page if you enjoy this Instructable.**
This is a Zombie Game and it uses processing to create a GUI based thread. I used Processing because it is easy for anybody to use and I used the TI MSP430 LaunchPad because it is a versatile platform and also easy to use. I worked on this project, by myself, for about an hour. My plans and ideas did not change while creating the project, because I thoroughly calculated all of the needed resistances and capacitances, so there should be not problem. I made this at home, so I think that anybody could really be able to build this. I learned that it is always best to calculate values to my electronic components because it shortens build time and brings the cost down. The biggest challenge in this build was actually calculating the needed component values. I think that the only thing that I would change, when I do another build of this project, is embed a serial adapter on the board with the MSP430G2553 embedded, so that there would be no extra headers on board.
(Thank-you juani_c [the original]: http://forum.43oh.com/topic/182-killing-zombies-with-the-launchpad/)
Materials
1 .01uF Polyester-Film capacitor
1 .022uF Polyester-Film capacitor
1 10K POT
1 22K Resistor
1 small Perf-Board
1 8 pin DIP socket, or 8 pin female Headers
1 Five pin Male headers (or just 2 pin male headers and one 3 pin male headers)
1 Button
1 LDR
Some wire
1 USB-B mini B cable
(or connect a wire from Pin 3 of the POT to pin 6 of the Female header.)
Now for the "Gun"
Program the MSP430
After installing, open CCS use when it asks you about the workspace, allow it to make one with the name it generated.
Then press File->New->CCSProject
A window will pop up, name your project, Zombie Game.
Then Select MSP430 series
Then in the search type in: MSP430G2553 (or just find it)
Select the template Blink LED and on opening of the blink program, Delete all of it.
Paste the code posted here and press the little bug. If you have no problems, then you will have a small toolbar after it programs the chip, which is a debug console, and there will be a > button, press it and the MSP430 Launchpad will be sending back data via UART, so you can check the data on terminal.
#include "msp430g2553.h"
#include <intrinsics.h> // Intrinsic functions
#include <stdint.h> // Standard integer types
#define TXD BIT1 // TXD on P1.1
#define Bitime 104 //9600 Baud, SMCLK=1MHz (1MHz/9600)=104
unsigned char BitCnt; // Bit count, used when transmitting byte
unsigned int TXByte; // Value sent over UART when Transmit() is called
unsigned int i,j,h;
unsigned int ADCVal;
// Function Definitions
void Transmit(void);
void Single_Measure(unsigned int);
#define NSAMPLES 16 // Number of samples in each block
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
unsigned int uartUpdateTimer = 10; // Loops until byte is sent
uint32_t average=0; // Average value of block
BCSCTL1 = CALBC1_1MHZ; // Set range
DCOCTL = CALDCO_1MHZ; // SMCLK = DCO = 1MHz
P1DIR |= 0x01; // Set P1.0 to output direction
P1SEL |= TXD; //
P1DIR |= TXD; //
__bis_SR_register(GIE); // interrupts enabled\
/* Main Application Loop */
while(1)
{
if ((--uartUpdateTimer == 0))
{
//__bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
if(0x08 & P1IN){
for (i = 0; i < 1000; i++); // Dummy delay for debounce
if(0x08 & P1IN){
P1OUT &= ~0x01; //board led OFF
}
}
else{
for (i = 0; i < NSAMPLES; ++i) {
Single_Measure(INCH_4);
ADCVal = ADC10MEM;
average += ADCVal; // Accumulate sum
}
average /= NSAMPLES; // Arithmetic mean of samples
P1OUT |= 0x01;//board led ON
average=average & 0xFF;
TXByte = average;
}
Transmit();
average=0;//reset avarage
uartUpdateTimer = 10;
for (h = 0; h < 10000; h++); // Dummy delay between communication cycles
}
}
}
// Function Transmits Character from TXByte
void Transmit()
{
CCTL0 = OUT; // TXD Idle as Mark
TACTL = TASSEL_2 + MC_2; // SMCLK, continuous mode
BitCnt = 0xA; // Load Bit counter, 8 bits + ST/SP
CCR0 = TAR;
CCR0 += Bitime; // Set time till first bit
TXByte |= 0x100; // Add stop bit to TXByte (which is logical 1)
TXByte = TXByte << 1; // Add start bit (which is logical 0)
CCTL0 = CCIS0 + OUTMOD0 + CCIE; // Set signal, intial value, enable interrupts
while ( CCTL0 & CCIE ); // Wait for TX completion
TACTL = TASSEL_2; // SMCLK, timer off (for power consumption)
}
// Timer A0 interrupt service routine
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A (void)
{
CCR0 += Bitime; // Add Offset to CCR0
if ( BitCnt == 0) // If all bits TXed, disable interrupt
CCTL0 &= ~ CCIE ;
else
{
CCTL0 |= OUTMOD2; // TX Space
if (TXByte & 0x01)
CCTL0 &= ~ OUTMOD2; // TX Mark
TXByte = TXByte >> 1;
BitCnt --;
}
}
/********************************************************
// ADC10 interrupt service routine
********************************************************/
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
__bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)
}
void Single_Measure(unsigned int chan)
{
ADC10CTL0 &= ~ENC; // Disable ADC
ADC10CTL0 = ADC10SHT_3 + ADC10ON + ADC10IE; // 16 clock ticks, ADC On, enable ADC interrupt
ADC10CTL1 = ADC10SSEL_3 + chan; // Set 'chan', SMCLK
ADC10CTL0 |= ENC + ADC10SC; // Enable and start conversion
}