Search for ATMega328P in Topics


Choosing Resonator for AtMega328P design?

The ATMega328P datasheet specifies a load capacitance for a resonator from 12-22pF but the only 2 Resonators that will fit in my design (from Digikey) have 10pF and 33pF internal capacitors. Which one should I use, the 10pF or the 33pF, and what are the tradeoffs? Here is the atmega328p datesheet

Question by DELETED_MakiY2    |  last reply


ADC conversion error in code ATMEGA328p?

I am trying to read values from ADC0 on the ATMEGA328p. The values expected are between 0-5v. This is due to ADC0 being connected to a potentiometer connected to the 5v output of a Xplained mini. I am getting either 0v or 5v usually. With no variation when the potentiometer is changed. Here is the date sheet of atmega328p I have looked at multiple ADC examples and tutorials online but cant find the error in my code. void adc_initialise (){     //set vref to AVcc, channel selection is initially ADC0 as wanted     ADMUX |= (1<<6);     //set ADC enable, Set adc clock prescalar 64     ADCSRA |= (1<<7)|(1<<2)|(1<<1); } uint16_t adc_read (){     ADCSRA |= (1<<6); // start conversion     while( ADCSRA & (1<     return ADCW; } float adc_calculation(uint16_t adcValue){     float stepSize = (5.0/1024.0);     float voltageIn = adcValue*stepSize;     return voltageIn;   } then in my main i have while(1){       adc_initialise();     uint16_t adcValue = adc_read();     float voltageIn = adc_calculation(adcValue);     adcConverterToUART(voltageIn);//I know that this part of the code is working as I have hardcoded many test values and all have transmitted correctly. } And as mentioned above I know the error is not in my UART code but somewhere in the above ADC code. Cheers in advance for any help.

Question by DELETED_MakiY2    |  last reply


How to make a circuit for the ATmega328P-PU?

I have been wanting to build a standalone circuit for the ATmega328P-PU but i understand where to connect the power to it, i have been looking online and all i can find is how you make a DIY Arduino and they only show pictures of the wiring that does not show what is connected to the prongs coming off of the ATmega. I have generated a list of questions below: How to provide power to the ATmega through USB what prongs i should connect the power to. what prong does what. I put a picture of a diagram of the ATmega below that i found online for reference.

Question by bman46    |  last reply


How to burn arduino bootloader to atmega328p using arduino Pro mini?

For past 3-4 hours I've been trying to burn arduino bootloader to atmega328p using a pro mini. But i can't figure it out. I've reffered to many tutorials and THIS one seems to be using a pro mini.. I've built a standalone arduino circuit according to arduino.cc's guide connected to the pro mini and when i hit "burn bootloader" it show the following error. avrdude: Expected signature for ATmega328P is 1E 95 0F          Double check chip, or use -F to override this check. Wrong microcontroller found.  Did you select the right board from the Tools > Board menu? But I'm using atmega328p. why does it say "wrong microcontroller found" ?? can anyone point me to the right direction?

Question by Suraj Bhawal    |  last reply


What is the easiest way to burn the arduino bootloader to an atmega328p?

With a fresh ATMega328p Chip and an arduino duemilanove board. ISP looks like the best option but, how to use it? Make / buy a parallel/serial/usb programmer. what is the easiest or cheapest way...

Question by nerd608    |  last reply


How i wipe the arduino bootloader from the ATMega328p?

I have an "ATMega328p" microcontroller with arduino bootloader burned on it but now i want to erase the bootloader so i can write the code in Embedded C and use an AVR ISP Programmer ,, i want to know how i wipe the bootloader from the chip ?? Thanks in advance

Question by ahmed.hzzaa    |  last reply


Can this microcontroller be used for ARDUINO ???

Hi ... can this microcontroller uk.farnell.com/atmel/atmega328p-mu/mcu-8bit-avr-32k-flash-32qfn/dp/1748522 be used to create "ARDUINO" ??? There seems to be a small difference in the pins in compare to uk.farnell.com/atmel/atmega328p-pu/mcu-8bit-avr-32k-flash-28pdip/dp/1715487  - that's what's making me confused. Thank you in advance for your answers. Zholy

Question by zholy    |  last reply



Want to move "tv b gone" project from Arduino(Atmega328P) to Atmega8A

Hello. I found "Tv b gone" project which i can write to my arduino. It worls perfectly. I want to make it smaller but i don't want to waste my arduino board and Atmega328P which sits inside of an arduino. Here is a video on YouTube https://www.youtube.com/watch?v=rfdVdPwPhWU Works on one IR diode (would be glad if can do the same on atmega8a) There is a link to download the code for arduino: http://arcfn.com/files/arduino-tv-b-gone-1.2.zip Project page (guy changed the code to working on arduino) http://www.righto.com/2009/12/tv-b-gone-for-arduino.html Original project page where originally everything is working on ATtiny85. https://learn.adafruit.com/tv-b-gone-kit/design-notes If needed I've got Arduino UNO, USBasp (can burn program with USBasp using Eclipse C/C++ or ArduinoIDE) I want to know if i could make it work on Atmega8 (internal oscilator/external crystal?) (got many of these, don't want to buy new microcontroller) without any effort? I would appreciate if someone help me. Sorry for my English. I'm from Europe.

Topic by DELETED_AndrzejŁ    |  last reply


does anyone know how to burn an Arduino Bootloader onto 10 ATMEGA328P-PU chips all at once ?!? Answered

Hi folks! im back with another mad plan, lol ! i want to be able to burn 10 Atmega328P-PU microcontrollers at once, ive tried to do it with the help of another Arduino Geek, he knows his stuff but i dont and i tried 'daisy chaining' the wires that go to load the bootloader from the Arduino as ISP bootloader instructions and just came out with errors saying something like: Yikes! The device signature is invalid, check all connections etc etc... and i was trying to burn two Atmega Chips using one RBBB set up to use the 'burn bootloader' function in the Arduino IDE and i could burn to only one chip but never the 2nd chip even though i duplicated the wires from the RBBB to both chips in separate ZIF sockets with their accompanying 16 mhz crystals and capacitors... Really been knocking my head against this one for the last 3 months and my brains totally overheated now, lol ! im buying 100 MCU's at a time and just want a faster way of burning the Arduino UNO bootloader onto them as burning only 25 chips takes me 1 hour, so 100 chips takes a damn-good 4 hours which is extremely tedious and just takes too flamin long... please please please could anyone help with a plan or a schematic to burn 10 atmega328P-PU MCU's in ZIF sockets all in one go ???? This way i'd be done burning within an hour or less i assume, its killing my time to keep having to do this one-by-one and ive scouredd the internet through google and still coming up empty for many MONTHS so far... Is there any way anyone could possibly point me in the right direction towards my goal please please please ???!!!??? many thanks in advance for any and all suggestions but i must only be interested in the model number MCU of ATMEGA328P-PU and only the UNO bootloader, many thanks again in advance!

Question by offtherails2010    |  last reply


CNC auto level

I bought a 3 axis CNC machine from amazon, after putting it together with poor instructions, I had what looks to be a auto level prob wire. I am trying to figure out how and where to connect this single wire to the board? the IC in a atmega328p with Arduino loaded . I have some photos that maybe someone could tell me which pin to connect this to? thanks

Topic by DominickP4    |  last reply


Arduino Projects Without Any Electric Component?

So Yesterday I Ordered An Arduino Uno R3 ATmega328p So I Want To Learn Some Projects ASAP So I Can Show Someone That It Is Not A Waste Of Money.Are There Any Projects Which Don't Require Any Electrical Components?And Please I Don't Need One Suggestion Saying That You Can See A Light Turning On And Off (I'm Tired Of It).Sorry If This Question Is Already Asked (Link Me There).Or If You Know Any Article(s) Link Me There.

Question by VruttantB    |  last reply


Arduino bootloading circuit

Hi everyone, I have a short question. I am making a project that uses a ATmega328P and I'd like it to be stand alone, so I have been burning bootloders on this chip but only on the DIP socket and with a shield I made after a tutorial. I know that when burning the ISP you can't have anything connected to the board, and I was wondering if you must have the same conditions for the bootloading procedure since I am going to use the TQFP32 package and it is going to be a little bit difficult to make a shield for it. So if I solder everything to the board and put a connector for the ISP do you think it will burn the bootloader?

Topic by shinystuff  


$13 Arduino Boards now at Evil Mad Scientist Labs

Evil Mad Scientist has just released Diavolino, a low cost option for those who like to do arduino development, take a look:   "Diavolino ("little devil") is a low-cost, easy to build Arduino-compatible development board. Diavolino has the form factor of an Arduino Duemilanove or Arduino Pro, but with nicely rounded corners and a striking appearance. It's a low-profile through-hole version, with a simplified design. It's based on a ATmega328P microcontroller, and comes pre-flashed with the Arduino bootloader. Open source design, with bare basics hardware."   You can buy them here

Topic by frenzy  


FatFs Library

Hello everyone, I have recently been working on porting the FatFs Generic FAT File System library to an Atmega328p for use with a project I'm working on and I'm really having some issues with it.  I've tried a couple of different tutorials and walkthroughs and in the end I either get odd errors that seems will be an incredible hassle to correct, or my program compiles but the actual program won't work correctly (none of the open, write, etc functions actually work) I am writing this in Atmel Studio 6 (AVR Studio) If anyone can please help me out, or if you have ported this for the atmel mega series before and can provide your files that would be awesome Thank you

Topic by BooRan  


How to program atmega32A using arduino uno??

I bought a 40pin atmel's Atmega32A-PU and i was unaware that it needs a different programmer rather than using arduino. I can't buy another programmer just to program that ic. I have arduino uno board which has atmeha328p and i have used it to program another atmega328p. But I don't know how to program a 40 pin ic such as atmega32A using arduino board and arduino ide. I tried this tutorial on this link but nothing happened... http://hardwarefun.com/tutorials/use-arduino-as-an-isp-programmer-to-program-non-arduino-avr-microcontrollers It was successful only upto burning the bootloader. What to do next???

Question by akki5230    |  last reply


CH340G and Standalone UNO R3 Got ERROR "avrdude.exe: stk500_getsync(): not in sync: resp=0x00?"

I bough the CH340G USB-TTL with 6 pin (GND, CTS, VCC, TX, RX, DTR). The CH340 driver already installed, the arduino bootloader also already burn to ATmega328P-PU. When upload the sketch using FTDI or PL2303 or ATmega16U2 is okey and no error found. But if Ia using CH340 and connecteed below pin: Arduino VCC ==> VCC CH340 Arduino GND ==> GND CH340 Arduino RX ==> TX CH340 Arduino TX ==> RX CH340 Arduino RESET ==> DTR CH340 The error always appear as "avrdude.exe: stk500_getsync(): not in sync: resp=0x00?" event the speed on the port setting already change at 9600; 19200 or 115200. Iam also trying with IDE 1.6.0, 1.0.5 and 022 the error message are same. May be someone can help me please?

Question by wachid_elektronik    |  last reply


How to move project to work on Atmega8a?

Hello. I found "Tv b gone" project which i can write to my arduino. It worls perfectly. I want to make it smaller but i don't want to waste my arduino board and Atmega328P which sits inside of an arduino. Here is a video on YouTube https://www.youtube.com/watch?v=rfdVdPwPhWU Works on one IR diode (would be glad if can do the same on atmega8a) There is a link to download the code for arduino: http://arcfn.com/files/arduino-tv-b-gone-1.2.zip Project page (guy changed the code to working on arduino) http://www.righto.com/2009/12/tv-b-gone-for-arduino.html Original project page where originally everything is working on ATtiny85. https://learn.adafruit.com/tv-b-gone-kit/design-notes If needed I've got Arduino UNO, USBasp (can burn program with USBasp using Eclipse C/C++ or ArduinoIDE) I want to know if i could make it work on Atmega8 (internal oscilator/external crystal?) (got many of these, don't want to buy new microcontroller) without any effort? I would appreciate if someone help me. I found also something like this. https://code.google.com/p/mircho-avrcode/source/browse/#hg%2FatmegaCode%2Ftvbgone-atmega8 but I need EU codes Sorry for my English. I'm from Europe.

Question by DELETED_AndrzejŁ  


HOW TO MAKE MIRROR LED WATCH?

Привет! Мне очень понравились часы.Хотите сделать.Я купил все компоненты для часов, и я не могу программировать.Ошибка Arduino: 1.8.5 (Windows 8.1), Доска: "Arduino Nano, ATmega328P"C:\Program файлы (x86)\Arduino\примеры\исходный код часов \ исходный код часов.no: 2: 31: фатальная ошибка: Adafruit_NeoPixel.h: нет такого файла или каталога #включать ^компиляция завершена.статус выхода 1 Ошибка компиляции для Arduino Nano Board. Помогите решить проблему.

Question by strollermoscow  


I am not so good in programing arduino and i have some problems, but can't find answer anywhere

I am have this errors  Arduino: 1.6.0 (Windows 7), Board: "Arduino Pro or Pro Mini, ATmega328 (5V, 16 MHz)" Build options changed, rebuilding all Using library Sprite in folder: C:\Users\Hrvoje\Documents\Arduino\libraries\Sprite (legacy) Using library Matrix in folder: C:\Users\Hrvoje\Documents\Arduino\libraries\Matrix (legacy) D:\Program Files (x86)\Arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10600 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR -ID:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -ID:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs -IC:\Users\Hrvoje\Documents\Arduino\libraries\Sprite -IC:\Users\Hrvoje\Documents\Arduino\libraries\Matrix C:\Users\Hrvoje\AppData\Local\Temp\build3373133583693679666.tmp\LED_1cube_4x4x4_Show_1_74HC595.cpp -o C:\Users\Hrvoje\AppData\Local\Temp\build3373133583693679666.tmp\LED_1cube_4x4x4_Show_1_74HC595.cpp.o LED_1cube_4x4x4_Show_1_74HC595.ino:34:1: error: 'prog_uchar' does not name a type LED_1cube_4x4x4_Show_1_74HC595.ino: In function 'void loop()': LED_1cube_4x4x4_Show_1_74HC595.ino:258:27: error: 'PatternTable' was not declared in this scope Error compiling.   all files i can not compile :S https://mega.co.nz/#F!uY82TLKK!yz8c1fMIYyo-ow7pUiOwgw Include file key

Question by monpg2    |  last reply


Home automation & Home door sequrity including one android apk file project available ???

Please help me for this project. how will be arduino program code , which pin are connect to apparatus to apparatus. please give me all description step by step this project implimentation. Project planning:-                   1.Home automation & Home door sequrity including one android apk file.                   2. 4 Relay:   1. Blue led light.                                 2. Red  led light.                                 3. White led light for bath room using PIR sensor.(this light switch on/off only using pir sensor,                                            because-wet hand electric shock on switch or, damged mobile display).                                 4. Fan using voltage regulator.                                  note:- light switch on/off & fan switch & voltage regulataor incease/decrease including appk file.                   3.Home squrity switch board on/off may be   a.display board on wall of house.                                                                b. display in android apk file.                   4.when open door with corect srquirty,then photo upload in memory card.if incorect password then a lout of sound.                   5.when fire in house ,alarm using gas sensor. Room temperature, huminity show in display. Apparatues:            A: Led light on/off by mobile app.                  1.ESP8266 Serial Wi-Fi Wireless Transceiver Module for IOT.                  2.Generic(unbranded )4-channel relay control board module with optocoupler, 4 way relay module for arduino                  3.Arduino Uno R3 ATmega328P ATMEGA16U2 Compatible with USB Cable.                     or,xcluma Atmel Atmega 2560 Mega2560-16Au (16 Mhz) R3 Board+Usb Cable For Arduino.                  4.Led light 3(Blue,Red,White for Bath room),Motor Fan.                  5.REES52 REES_2 Bread Board or Solderless Pieces Circuit Test Board Project Board.                  6.Jumper Wires Male to Male, male to female, female to female.                  7.Generic KG001 HC-SR501 PIR Sensor Pyroelectric Infrared Module 2pcs(for bath room & door open).                  8.Adraxx LM7805 7508 Positive Voltage Regulator IC, 5V 1A.                  9.Resister 1k ohm.                  10.REES52 MQ2 Arduino Compatible Gas Sensor, Methane, Butane, LPG, Smoke Sensor.           B: Home sequrity.                  1.Quantum QHM495LM 25MP Web Camera.                  2.SanDisk Ultra MicroSDHC 32GB UHS-I Class 10 Memory Card With Adapter.                  3.REES52 621033926893 Universial 16 Key Switch Keypad Keyboard Fit for Arduino by REES52.                  4.Silicon Technolabs 20x4 Line LCD Display With Blue backlight HD44780 for ALL Arduino,Rasp Pi,AVR,ARM,8051 (Blue). Software:      1. Arduino-1.8.5.                2. wampserver & notepad++ (for php web page).                3. Android Apk file.      please help me for this project. how will be arduino program code , which pin are connect to apparatus to apparatus. please give me all description step by step this project implimentation.  i will waiting for you.

Question by somnathpanjaproject2018    |  last reply


Power Supply Question? Answered

I want to build a switching Power Supply, without the use of IC's with everything already inside. I only want to use op amps and passive components. Below are my goals on what to achieve. I would like to make this PSU current limited, or at least shut off when the current goes too high. I basically took the concept of the linear voltage regulator and expanded on it, turning it into a 'proof of concept' switchmode supply. Input Voltage range: . . . .7-24 Volts Voltage: . . . . . . . . . . . . . . 5-24 Volts Max Current: . . . . . . . . . .10 Amps Price: . . . . . . . . . . . . . . . . $5 -- $10         Instead of feeding a voltage reference into an op amp, I modulated it with a few components. (A triangle wave generator, and a array of resistors to lower the amplitude and introduce a DC bias.) The DC bias is controlled by the current protection module, which is simply an op-amp that reads the voltage on a small resistor and multiplies it by 5. This finalized current controlled, DC reference biased triangle wave is fed into a comparator, which will then switch a rather large MOSFET on and off at about 200 Hz, with varying PWM, depending on how much 'droop' there is on the output. Here is a rundown of what the components will do: OK, I refined my plan to this general specs: Input Voltage range: . . . .7-24 Volts Voltage: . . . . . . . . . . . . . . 5-12 Volts Max Current: . . . . . . . . . .10 Amps Price: . . . . . . . . . . . . . . . . $5 -- $10        I basically took the concept of the linear voltage regulator and expanded on it, turning it into a 'proof of concept' switchmode supply. I don't want to use any prebuilt chips where you have a magic black box with inductors, capacitors and resistors connected to it. I want this to be entirely raw, basic, cheap parts. Maybe later, I will replace many of the op amps with a single programmable chip (like an Atmega328P)         Instead of feeding a voltage reference into an op amp, I modulated it with a few components. (A triangle wave generator, and a array of resistors to lower the amplitude and introduce a DC bias.) The DC bias is controlled by the current protection module, which is simply an op-amp that reads the voltage on a small resistor and multiplies it by 5. This finalized current controlled, DC reference biased triangle wave is fed into a comparator, which will then switch a rather large MOSFET on and off at about 200 Hz, with varying PWM, depending on how much 'droop' there is on the output. Here is a rundown of what the components will do: Green field: This contains a voltage regulator which acts as both a 5V power source and a voltage reference. Not only will this module produce a 5V output, but also produce a triangle wave. Blue field: This module will be fed the triangle wave, decrease it's amplitude, and inject it with a bias voltage, controled by the current limiter (red field). Red field: This basic module simply measures current flowing through a 0.1 Ω resistor, and multiply that reading by a factor of 10, and inert it (the circuitry is probably wrong, and I am not sure how this will work, if it even will do what I want it to Will this work?) Yellow field: The final modulated triangle wave is then fed into the last comparator, which will switch a MOSFET on and off at a fixed frequency of 200Hz. The output of this last comparator is now PWM. As the output voltage sags, the pulse width will increase, and cause the final voltage to stabilize at either the peak value of the triangle wave (with little to no load), or near the bottom end of the wave (with a heavy load) ------------------------------------------------------------------------------------------------------------------------------------ My questions:  I try to run this in LTspice simulator but some reason the output of the last comparator is a distorted triangle wave. I think this has to do with my filtering capacitor and MOSFET gate capacitance. Can anyone give suggestions about this design?  I'm sure the current limiting function is not going to work as intended until I finalize it's design (I hope I don't need more than 4 op amps altogether, It would be nice to use a single chip I already have) Any suggestions? I might just omit this part entirely, as it is not necessary.

Question by -max-    |  last reply


need help writing Arduino sketch for Nano to Adafruit FX mini soundboard communications?

Hello everyone.  I am new here, and fairly new to arduino. Im an electrician/ communications tech by trade, but have only been working with code as a hobby for a few weeks (have wanted to learn this for a long time).  I am working on a project that would require an Motion sensor input to play an audio track at random, whilst illuminating a corresponding PWM LED. said LED should fade in sync with the audio file. ITs a robot of sorts that will detect movement and speak a random audio track.  Some nice (0-5) and some not so nice (6-12).  it will have a a diffused glow when on, blue when speaking nice, and red when speaking not so nice.  hence the audio input to act as an anologRead and output to the PWM's I know, a lot to take on for a noob.  but go big or go home.  I have put together what I thought was a good start sketch, but it doesnt even illuminate an LED, communicate with the soundboard, or serial link on the monitor. I think I am on the right track in regards to the parts and overall Idea.  And im pretty sure my sketch needs a lot of work, but i am trying. so here are the parts I had intended to use. (if im going down the wrong path, or you see another way, feel free to say so.  I expect some criticism, I can handle it) Arduino elegoo Nano V3.0, CH340/ATmega328p Adafruit Audio FX Mini soundboard w/o amp Adafruit Mono 2.5W Class D amplifier (PAM8302) Sodial mini IR motion sensor module, 3-pin LED's are undecided for finished product, but i was thinking RGB 6302's (5-7) speaker is an 8 ohm 2W power will be supplied by a small 3.7v lipo (thats the plan) My wiring idea should be easily discernible from the sketch, but i can draw my idea, and add it if need be. I did install the soundboard _library. but thats the only one (didnt think i needed others) Any and ALL help is greatly appreciated. the sketch... [code] /*   Menu driven control of a sound board over UART.   Connect UG to ground to have the sound board boot into UART mode */ #include #include #define SFX_TX 9      // Defines pin D9 as TX to FX Mini #define SFX_RX 10     // Defines pin 10 as RX to FX Mini #define PLAYING 11    // Connect to the ACT pin on the FX Mini #define SFX_RST 13   // Connect to the RST pin on the FX Mini SoftwareSerial ss = SoftwareSerial(SFX_TX, SFX_RX);  // Passes Software Serial to FX Mini SoftwareSerial mySerial(SFX_RX, SFX_TX); Adafruit_Soundboard sfx = Adafruit_Soundboard(&ss;, NULL, SFX_RST); // can also try hardware serial with // Adafruit_Soundboard sfx = Adafruit_Soundboard(&Serial1;, NULL, SFX_RST); int incomingAudio;            // Audio input assigned from FX Mini Right audio output int RedLED = 5;         // the PWM pin the Red LED is attached to int BlueLED = 3;        // the PWM pin the Blue LED is attached to int LED = 4;            // the output the normal state LED is attached to int Button = 12;        // pushbutton test play track pin int Track = random(0,13);     int inputPin = 2;       // choose the input pin (for PIR sensor) int pirState = LOW;           // we start, assuming no motion detected int val = 0;                  // variable for reading the pin status void setup() {   Serial.begin(115200);         // softwareserial at 115200 baud   Serial.println("Adafruit Sound Board!");   ss.begin(115200);      pinMode(LED, OUTPUT);           // assigning LED as an output   pinMode(RedLED, OUTPUT);        // assigning RedLED as an output   pinMode(BlueLED, OUTPUT);       // assigning BlueLED as an output   pinMode(incomingAudio, INPUT);  // assigning incomingAudion as an input   pinMode(Button, INPUT);         // assigning Button as an input   pinMode(inputPin, INPUT);       // declare sensor as input   if (!sfx.reset()) {     Serial.println("Not found");     while (1);   }   Serial.println("SFX board found"); } void loop(){   digitalWrite(LED, HIGH);        // assigning LED to start with +5V   incomingAudio = analogRead(A0);               //read voltage at A0   incomingAudio = (incomingAudio+1)/4 - 1;      //scale from 10 bit (0-1023) to 8 bit (0-255)   if (incomingAudio<0){                         //deal with negative numbers     incomingAudio = 0;   }   PORTD = incomingAudio;   Serial.println(PORTD);   val = digitalRead(inputPin);                 // read input value    if (val == HIGH) {                          // check if the input is HIGH       sfx.playTrack(Track);       Serial.println(Track);       if (pirState == LOW) {                   // we have just turned on       Serial.println("Motion detected!");      // We only want to print on the output change, not state       pirState = HIGH;       }     }    else {       if (pirState == HIGH){                   // we have just turned of       Serial.println("Motion ended!");         // We only want to print on the output change, not state       pirState = LOW;     }   }     if (Button=HIGH){                             // pin D12 to button, ground thru 10K res, and +5v       sfx.playTrack(Track);       Serial.println(Track);       }   if (incomingAudio>=128 &&Track;>=0 &&Track;<=6){      digitalWrite(RedLED, incomingAudio-128);      digitalWrite(LED, LOW);      }   else if (incomingAudio>=128 &&Track;>=7 &&Track;<=12){      digitalWrite(BlueLED, incomingAudio-128);      digitalWrite(LED, LOW);      }   else{      digitalWrite(LED, HIGH);      digitalWrite(RedLED, LOW);      digitalWrite(BlueLED, LOW);      delay(15000);   } } [/code]

Question by supramp