How to make the GY-87 work probably ?

Hey, This my first question and ... action here with this new account :) My problem is I'm making a quad-copter, which needs some balance and no problem of adding some features like alt. measurement and so. I bought a GY-87 10DOF chip which combines 5 sensors :- MPU6050 Gyroscope MPU6050 Accelerometer BMP085 Barometer BMP085 Temperature sensor HMC5883L Magnometer I don't know yet how to make the quad-copter balance using the chip but I'm focusing now on making the chip work at all. After 7 hours of searching I could get a messy code using KALMAN filter to get the gyro and accel angels which worked fine eccept that the code combines the Z axis with the compass reading and I need to understand how to make every reading separate, which get us to the secong problem, the compass is stuck at 50.3 degrees, after reading i found that i must enable the I2C cuz both of the MPU and the HMC uses the same bus ways, I added a delay (100) ms to let the HMC get it's reading, i could make it work till I realized that the reading is not from 0- 360, it's between 200 and ... maybe 342 ! although making the BMP work was difficult a bit.. now my questions are :- -Understand how the gyro code works or at least add the Z axis of the the gyro not the compass -How to make the compass work probably Files:- https://drive.google.com/open?id=0BxGMyrtCX-KJVHB5S1luZ3VLeGM Libs:- https://drive.google.com/open?id=0BxGMyrtCX-KJcXZ6VlZmejRDR2c

Question by Mavrick23 


Need help with signal generator 5kHz and 8.7 kHz

Hi, I'd like some help. I'm trying to make a simple signal generator that will produce a 5kHz and an 8.7kHz square wave signal. I have some basic (very) electronics skills, and know how to follow a schematic and solder things up. The ones I've found online are outdated, using obsolete IC's. Any help would be appreciated. Thanks in advance.

Topic by NorthWind   |  last reply


Can I substitute a vertical antenna for a dipole? (Also, how do I protect it from lightning?)

I have a project that requires a 87 foot long dipole antenna. Would it be possible to use a 44 foot long quarter-wave vertical antenna in place of it, to save space? And is there any DIY way to protect the antenna from lightning? How well do they work compared to store-bought lightning arrests?

Question by ElectricUmbrella   |  last reply


look at this bug!

Look at this error:update: here is the message:org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:249) at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:92) at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:87) at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:218) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2174) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2610) at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:52) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) at com.instructables.hibernate.SessionProvider.closeCurrentSession(SessionProvider.java:62) at com.instructables.filter.HibernateSessionRequestFilter.doFilter(HibernateSessionRequestFilter.java:94) at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70) at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:173) at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229) at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:274) at com.caucho.server.port.TcpConnection.run(TcpConnection.java:511) at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:520) at com.caucho.util.ThreadPool.run(ThreadPool.java:442) at java.lang.Thread.run(Thread.java:595)Caused by: java.sql.BatchUpdateException: Data truncation: Data too long for column 'body' at row 1 at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:665) at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723) at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242) ... 22 more

Topic by coolz   |  last reply


How to use audio jack with 5" Raspberry pi Touchscreen? Answered

I've been building a portable pi recently and have finally gotten the touchscreen working... The only problem is that the audio is forced through HDMI instead of the audio jack, (my touchscreen doesn't have audio). I was wondering how I could edit the /boot/config.txt file to use the audio jack without messing with the display.                 /boot/config.txt code   GNU nano 2.2.6            File: /boot/config.txt                              # --- added by elecrow-pitft-setup Mon 18 Sep 16:41:00 CDT 2017 --- hdmi_force_hotplug=1 max_usb_current=1 hdmi_drive=1 hdmi_group=2 hdmi_mode=2 hdmi_mode=87 hdmi_cvt 800 480 60 6 0 0 0 dtoverlay=ads7846,cs=1,penirq=25,penirq_pull=2,speed=50000,keep_vref_on=0,swapx$ display_rotate=0 # --- end elecrow-pitft-setup Mon 18 Sep 16:41:00 CDT 2017 --- Thank you.

Question by mderton   |  last reply


Need help solving a wiring problem...

Hi, I'm new here; hoping someone can help me with a problem I have &, over time, maybe I can help others. I've attached a diagram for the headlight circuit on a car I built.  The headlights work, but I've not been successful adding an LED to indicate whether they are in low beam or high beam and need to get that working. I have an RGB, common cathode LED and have wired it as shown in the picture.  It may be obvious to some of you with more electrical experience than me, but but instead of off; green for low beam; blue for high beam -- I'm getting off; green when I turn the headlights on; both green & blue when I flip to high beams; stays both green & blue when I flip back to low beams; goes off if I turn the headlights off. The one thing I found while trying to trouble shoot that I wasn't expecting is that the wires connected to the 87 pins on relays 2 & 3 show +12V.  That makes sense given the lights simply have a coil between the + & - sides but I wasn't expecting that -- not sure if I'm backfeeding 12V to ground [which might explain a couple of gremlins I've been chasing in other parts of my wiring system]. So, net, I have two questions: 1.  Is there anything wrong with the headlight circuit the way it is set up in the diagram? 2.  Why wouldn't the LED be lighting as expected vs. what I'm getting per above? Note - I didn't draw in the resistors required for the LEDs to work with 12V power, but I do have them on the LED.  Both the blue & green sides do light properly when I connect them directly to the battery to test. I appreciate any help you can offer! Thanks in advance.

Question by CustomV8MGB   |  last reply


Controlling a motor with a touch screen ?

So i am trying to control a motors speed using PWM (running through a transistor). I know how to make that happen but i am unsure how to use a touch screen to control the motor,  I have one of the test codes that is a touch pad 0-9 with enter and clear. I was wondering if there was a way that i can punch the number in push enter and have the motor run at that speed(starting with just 0-255) The touch screen is 3.2LCD TFT Touch Screen SD Reader http://www.ebay.com/itm/SainSmart-Mega2560-3-2-TFT-LCD-Shield-Touch-Screen-SD-Reader-4-Arduino-2560-/280930557613?pt=LH_DefaultDomain_0&hash;=item4168c41ead The code is // ITDB02_Touch_ButtonTest (C)2010 Henning Karlsen // web: http://www.henningkarlsen.com/electronics // Modified to work with UTFT on Mega w/Arduino 1.0.1 (C)2012 Otmar Ebenhoech, // // This program is a quick demo of how create and use buttons. // // This program requires the ITDB02_Graph library (8bit mode) // or ITDB02_Graph16 (16bit mode). // // It is assumed that the ITDB02 module is connected to a // ITDB02 Shield, a ITDB02 Mega Shield or that you know how // to change the pin numbers in the setup. // #include #include // Declare which fonts we will be using extern uint8_t BigFont[]; // Uncomment the next line for Arduino 2009/Uno //UTFT myGLCD(ITDB32S,19,18,17,16);   // Remember to change the model parameter to suit your display module! //ITDB02_Touch  myTouch(15,10,14,9,8); // Uncomment the next line for Arduino Mega UTFT myGLCD(ITDB32S,38,39,40,41);   // Remember to change the model parameter to suit your display module! ITDB02_Touch  myTouch(6,5,4,3,2); //// //// ////   ////THIUS IS WHAT I ADDED ETK int motor = 9; ////    //// //// //// int x, y; char stCurrent[20]=""; int stCurrentLen=0; char stLast[20]=""; void setup() {//// //// //// //// tHIS IS WHAT I ADDED ETK pinMode (motor, OUTPUT); //// ////   ////    //// // Initial setup   myGLCD.InitLCD(LANDSCAPE);   myGLCD.clrScr();   myTouch.InitTouch(LANDSCAPE);   myTouch.setPrecision(PREC_MEDIUM);   myGLCD.setFont(BigFont);   myGLCD.setBackColor(0, 0, 255);   // Draw the upper row of buttons   for (x=0; x<5; x++)   {     myGLCD.setColor(0, 0, 255);     myGLCD.fillRoundRect (10+(x*60), 10, 60+(x*60), 60);     myGLCD.setColor(255, 255, 255);     myGLCD.drawRoundRect (10+(x*60), 10, 60+(x*60), 60);     myGLCD.printNumI(x+1, 27+(x*60), 27);   } // Draw the center row of buttons   for (x=0; x<5; x++)   {     myGLCD.setColor(0, 0, 255);     myGLCD.fillRoundRect (10+(x*60), 70, 60+(x*60), 120);     myGLCD.setColor(255, 255, 255);     myGLCD.drawRoundRect (10+(x*60), 70, 60+(x*60), 120);     if (x<4)       myGLCD.printNumI(x+6, 27+(x*60), 87);   }   myGLCD.print("0", 267, 87); // Draw the lower row of buttons   myGLCD.setColor(0, 0, 255);   myGLCD.fillRoundRect (10, 130, 150, 180);   myGLCD.setColor(255, 255, 255);   myGLCD.drawRoundRect (10, 130, 150, 180);   myGLCD.print("Clear", 40, 147);   myGLCD.setColor(0, 0, 255);   myGLCD.fillRoundRect (160, 130, 300, 180);   myGLCD.setColor(255, 255, 255);   myGLCD.drawRoundRect (160, 130, 300, 180);   myGLCD.print("Enter", 190, 147);   myGLCD.setBackColor (0, 0, 0); } void updateStr(int val) {   if (stCurrentLen<20)   {     stCurrent[stCurrentLen]=val;     stCurrent[stCurrentLen+1]='\0';     stCurrentLen++;     myGLCD.setColor(0, 255, 0);     myGLCD.print(stCurrent, LEFT, 224);   }   else   {     myGLCD.setColor(255, 0, 0);     myGLCD.print("BUFFER FULL!", CENTER, 192);     delay(500);     myGLCD.print("            ", CENTER, 192);     delay(500);     myGLCD.print("BUFFER FULL!", CENTER, 192);     delay(500);     myGLCD.print("            ", CENTER, 192);     myGLCD.setColor(0, 255, 0);   } } // Draw a red frame while a button is touched void waitForIt(int x1, int y1, int x2, int y2) {   myGLCD.setColor(255, 0, 0);   myGLCD.drawRoundRect (x1, y1, x2, y2);   while (myTouch.dataAvailable())     myTouch.read();   myGLCD.setColor(255, 255, 255);   myGLCD.drawRoundRect (x1, y1, x2, y2); } void loop() {   while (true)   {     if (myTouch.dataAvailable())     {       myTouch.read();       x=myTouch.getX();       y=myTouch.getY();             if ((y>=10) && (y<=60))  // Upper row       {         if ((x>=10) && (x<=60))  // Button: 1         {           waitForIt(10, 10, 60, 60);           updateStr('1');         }         if ((x>=70) && (x<=120))  // Button: 2         {           waitForIt(70, 10, 120, 60);           updateStr('2');         }         if ((x>=130) && (x<=180))  // Button: 3         {           waitForIt(130, 10, 180, 60);           updateStr('3');         }         if ((x>=190) && (x<=240))  // Button: 4         {           waitForIt(190, 10, 240, 60);           updateStr('4');         }         if ((x>=250) && (x<=300))  // Button: 5         {           waitForIt(250, 10, 300, 60);           updateStr('5');         }       }       if ((y>=70) && (y<=120))  // Center row       {         if ((x>=10) && (x<=60))  // Button: 6         {           waitForIt(10, 70, 60, 120);           updateStr('6');         }         if ((x>=70) && (x<=120))  // Button: 7         {           waitForIt(70, 70, 120, 120);           updateStr('7');         }         if ((x>=130) && (x<=180))  // Button: 8         {           waitForIt(130, 70, 180, 120);           updateStr('8');         }         if ((x>=190) && (x<=240))  // Button: 9         {           waitForIt(190, 70, 240, 120);           updateStr('9');         }         if ((x>=250) && (x<=300))  // Button: 0         {           waitForIt(250, 70, 300, 120);           updateStr('0');         }       }       if ((y>=130) && (y<=180))  // Upper row       {         if ((x>=10) && (x<=150))  // Button: Clear         {           waitForIt(10, 130, 150, 180);           stCurrent[0]='\0';           stCurrentLen=0;           myGLCD.setColor(0, 0, 0);           myGLCD.fillRect(0, 224, 319, 239);         }         if ((x>=160) && (x<=300))  // Button: Enter         {           waitForIt(160, 130, 300, 180);           if (stCurrentLen>0)           {          for (x=0; x             {               stLast[x]=stCurrent[x];             }             stCurrent[0]='\0';             stCurrentLen=0;             myGLCD.setColor(0, 0, 0);             myGLCD.fillRect(0, 208, 319, 239);             myGLCD.setColor(0, 255, 0);             myGLCD.print(stLast, LEFT, 208);             ////             ////              ////             ////THIS IS WAHT I ADDED ETK             analogWrite(motor,stLast);             ////             ////              ////             ////           }           else           {             myGLCD.setColor(255, 0, 0);             myGLCD.print("BUFFER EMPTY", CENTER, 192);             delay(500);             myGLCD.print("            ", CENTER, 192);             delay(500);             myGLCD.print("BUFFER EMPTY", CENTER, 192);             delay(500);             myGLCD.print("            ", CENTER, 192);             myGLCD.setColor(0, 255, 0);           }         }       }     }   } } The stuff i added has these //// on top and bottom with a comment "THIS WAS ADDED  ETK" the part that dont work is "analogWrite(motor,stLast);" and stLast is a char so it give me char to int error. And as you can tell i am no good at this so anything that can point me in the right direction would be greatly appreciated ETK

Question by etkoehn 


i am a java beginner can u help me with a couple of questions plz and if u know any websites to improve my jav?

1.      The company pays “straight time” for the first 40 hours worked by each employee and pays “time-and-a-half” for all hours worked in excess of 40 hours. You’re given a list of the employees of the company, the number of hours each employee worked last week and the hourly rate of each employee. Your program should input this information for each employee, and should determine and display the employee's gross pay. This program should allow the user to enter the information of many employees until he/she enters -1.   Sample run: Enter the number of hours worked (-1 to end): 39 Enter hourly rate of the worker: 10 Salary is $390   Enter the number of hours worked (-1 to end): 40 Enter hourly rate of the worker: 10 Salary is $400   Enter the number of hours worked (-1 to end): 41 Enter hourly rate of the worker: 10 Salary is $415.00   Enter the number of hours worked (-1 to end): -1 2. Write a program that reads a series of integers; a positive followed by a negative then by a positive and so on. Once the user enters two successive positive or negatives numbers, the program should stop reading integers and displays the highest and lowest integers entered. (assume the first integer should be positive) Sample run: Enter a series of integers (2 successive negative or 2 successive positive to stop): 56 -896 74 -12 9 -85 319 -202 9584 -5 -96 The lowest integer is: -896 The highest integer is: 9584 3. A number n is called deficient if the sum of its proper divisors is less than n. 8 is a deficient number because the sum of divisors of 8: 1+2+4=7. Write a program that finds all the deficient numbers which are less than or equal 100, display 10 per line. Sample Run: Deficient numbers less than or equal 100: 2 3 4 5 7 8 9 10 11 13 14 15 16 17 19 21 22 23 25 26 27 29 31 32 33 34 35 37 38 39 41 43 44 45 46 47 49 50 51 52 53 55 57 58 59 61 62 63 64 65 67 68 69 71 73 74 75 76 77 79 81 82 83 85 86 87 89 91 92 93 94 95 97 98 99 4. Write a program that keeps prompting the user to enter a character different than a digit. The first digit entered by the user stops the input and the program should then display the number of punctuations characters entered (one of this list ! . , ; ?). When none is found, display a message “Characters entered without punctuation”. Sample run1: Enter any character (a digit 0-9 to stop): a B , R x u ! @ . C W 2 The list you entered contains 3 punctuations signs. Sample run2: Enter any character (a digit 0-9 to stop): r T 0 No punctuation. 5. Write a program that prompts the user to enter two digits (d1 and d2) between 1 and 9. Your program should then generate an integer (n) starting with the smallest digit between d1 and d2 and containing all digits in between till reaching the maximum among them two. Hint: if the integers d1 and d2 are 5 and 2, 2 is min and 5 is max, the integer n can be generated as follow: 2-->2 * 10 -->20 + 3 = 23-->23*10-->230+4-->234*10-->2340+5-->2345 Sample run1: Enter first digit between 1 and 9: 5 Enter second digit between 1 and 9: 2 Integer generated is 2345 Sample run2: Enter first digit: 4 Enter second digit: 9 Integer generated is 456789  

Question by gougi88   |  last reply


programming a stealth USB caps locker problems? Answered

I have a problem programming my stealth USB caps locker (link)  the PCB is ready, the components soldered on, and ive made connections to my ghetto programmer. now, i opened programmers notepad and wanted to program it, but now it just gives a whole load of errors: > "make.exe" program set -e; avr-gcc -MM -mmcu=attiny45 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.lst  -std=gnu99 main.c \     | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > main.d; \     [ -s main.d ] || rm -f main.d main.c:19:20: error: usbdrv.h: No such file or directory main.c:20:21: error: oddebug.h: No such file or directory Compiling: main.c avr-gcc -c -mmcu=attiny45 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.lst  -std=gnu99 main.c -o main.o In file included from main.c:16: c:/winavr-20090313/lib/gcc/../../avr/include/util/delay.h:85:3: warning: #warning "F_CPU not defined for " main.c:19:20: error: usbdrv.h: No such file or directory main.c:20:21: error: oddebug.h: No such file or directory main.c:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'reportBuffer' main.c:26: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'idleRate' main.c:27: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'reportCount' main.c:33: error: 'USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH' undeclared here (not in a function) main.c: In function 'buildReport': main.c:65: error: 'uchar' undeclared (first use in this function) main.c:65: error: (Each undeclared identifier is reported only once main.c:65: error: for each function it appears in.) main.c:65: error: expected ';' before 'key' main.c:68: error: 'reportCount' undeclared (first use in this function) main.c:69: error: 'key' undeclared (first use in this function) main.c:73: error: 'reportBuffer' undeclared (first use in this function) main.c: In function 'timerPoll': main.c:87: error: 'reportCount' undeclared (first use in this function) main.c: At top level: main.c:104: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'usbFunctionSetup' main.c: In function 'calibrateOscillator': main.c:143: error: 'uchar' undeclared (first use in this function) main.c:143: error: expected ';' before 'step' main.c:144: error: expected ';' before 'trialValue' main.c:149: error: 'trialValue' undeclared (first use in this function) main.c:149: error: 'step' undeclared (first use in this function) main.c:150: warning: implicit declaration of function 'usbMeasureFrameLength' main.c:157: error: 'optimumValue' undeclared (first use in this function) main.c: In function 'main': main.c:193: error: 'uchar' undeclared (first use in this function) main.c:193: error: expected ';' before 'i' main.c:194: error: expected ';' before 'calibrationValue' main.c:196: error: 'calibrationValue' undeclared (first use in this function) main.c:200: warning: implicit declaration of function 'odDebugInit' main.c:201: warning: implicit declaration of function 'usbDeviceDisconnect' main.c:202: error: 'i' undeclared (first use in this function) main.c:205: warning: implicit declaration of function 'usbDeviceConnect' main.c:211: warning: implicit declaration of function 'usbInit' main.c:215: warning: implicit declaration of function 'usbPoll' main.c:222: warning: implicit declaration of function 'usbInterruptIsReady' main.c:222: error: 'reportCount' undeclared (first use in this function) main.c:224: warning: implicit declaration of function 'usbSetInterrupt' main.c:224: error: 'reportBuffer' undeclared (first use in this function) make.exe: *** [main.o] Error 1 > Process Exit Code: 2 > Time Taken: 00:03 maybe its this: ""Download capslocker.hex and use AVR Studio or a standalone programming tool to write into the ATTiny45 Flash. Oh, you'll also need to select the fuse for PLL/1k clock source." thats what the maker of this thingie said, but what is the fuse for PLL/1k clock source? could it be that? when i use the .hex file, i get about the same. whats the problem? i didnt change anything.

Question by godofal   |  last reply


ArduinoISP Does Not Support PORT Commands?

I was planning to make a drum machine that only requires two pins on the Arduino and so, wanted to use an AtTiny85v but it gives me errors like: 'DDRD' was not declared in this scope ArduinoBeats.cpp: In function 'void setup()': ArduinoBeats:97: error: 'DDRD' was not declared in this scope ArduinoBeats.cpp: In function 'void playKick()': ArduinoBeats:288: error: 'PORTD' was not declared in this scope ArduinoBeats:294: error: 'PORTD' was not declared in this scope ArduinoBeats.cpp: In function 'void playSnare()': ArduinoBeats:304: error: 'PORTD' was not declared in this scope ArduinoBeats:310: error: 'PORTD' was not declared in this scope ArduinoBeats.cpp: In function 'void playHat()': ArduinoBeats:320: error: 'PORTD' was not declared in this scope ArduinoBeats:326: error: 'PORTD' was not declared in this scope ArduinoBeats.cpp: In function 'void playCrash()': ArduinoBeats:335: error: 'PORTD' was not declared in this scope ArduinoBeats:341: error: 'PORTD' was not declared in this scope I had named the sketch ArduinoBeats so that explains all the ArduinoBeats stuff. Does anybody know how to add this command to the AtTiny library? Any help would be appreciated. Here is the code from Little Scale: /* Arduino Beats by Sebastian Tomczak 6 April 2008 */ // Working Variables byte byteA; byte byteB; int delayTime = 100; int barLength = 16; // Beats byte bar1[] = { 1, 0, 1, 0, 2, 4, 1, 2, 1, 0, 1, 0, 2, 1, 3, 0 }; byte bar2[] = { 1, 0, 1, 0, 2, 0, 1, 2, 1, 0, 1, 0, 2, 2, 2, 2 }; byte bar3[] = { 1, 3, 1, 3, 2, 3, 1, 2, 1, 3, 1, 2, 1, 1, 4, 4 }; byte bar4[] = { 1, 0, 1, 0, 2, 2, 0, 2, 2, 1, 1, 4, 1, 1, 4, 4 }; // Samples byte kick[] = { 127, 80, 42, 5, 165, 242, 241, 233, 128, 73, 48, 22, 127, 69, 55, 113, 151, 183, 209, 217, 223, 228, 233, 215, 161, 117, 91, 76, 65, 49, 37, 31, 31, 48, 83, 120, 146, 166, 183, 198, 206, 210, 209, 199, 178, 145, 111, 88, 78, 73, 69, 67, 72, 80, 88, 97, 109, 124, 137, 150, 163, 171, 174, 172, 168, 160, 144, 125, 114, 110, 108, 104, 104, 106, 109, 110, 112, 117, 124, 129, 135, 142, 145, 145, 143, 140, 137, 132, 128, 125, 122, 119, 118, 119, 119, 119, 118, 118, 120, 124, 126, 129, 132, 135, 137, 137, 135, 132, 131, 130, 129, 128, 126, 126, 124, 123, 121, 120, 120, 122, 123, 124, 126, 128, 129, 130, 130, 131, 131, 131, 130, 130, 130, 129, 129, 128, 126, 125, 125, 124, 124, 124, 124, 125, 126, 126, 128, 128, 128, 129, 129, 129, 129, 129, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, 128, 127, 126, 128, 128, 128, 128, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126 }; byte snare[] = { 127, 215, 65, 212, 56, 102, 135, 122, 51, 201, 220, 46, 175, 80, 152, 95, 123, 116, 184, 155, 59, 122, 100, 161, 143, 173, 101, 155, 97, 73, 112, 98, 176, 96, 140, 77, 134, 109, 132, 149, 112, 149, 97, 161, 98, 151, 98, 155, 149, 112, 157, 103, 133, 106, 167, 97, 166, 108, 129, 124, 136, 146, 124, 136, 129, 150, 94, 130, 105, 141, 146, 128, 129, 99, 150, 121, 141, 99, 142, 116, 131, 114, 118, 143, 127, 143, 115, 144, 120, 137, 109, 129, 131, 139, 129, 113, 144, 119, 145, 117, 135, 129, 134, 136, 124, 130, 130, 139, 121, 136, 121, 132, 128, 127, 126, 122, 130, 126, 138, 120, 136, 122, 131, 123, 130, 128, 127, 128, 118, 132, 125, 131, 122, 131, 125, 131, 122, 126, 128, 126, 129, 121, 129, 123, 132, 129, 127, 131, 123, 128, 125, 130, 123, 131, 123, 128, 131, 129, 128, 126, 125, 124, 131, 121, 124, 129, 130, 126, 124, 126, 127, 130, 125, 126, 128, 126, 128, 126, 126, 126, 126, 125, 128, 126, 126, 126, 126, 126, 126, 125, 128, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, 126, 128, 126, 127, 126, 128, 125, 127, 128, 128, 126, 126, 128, 126, 126, 128, 128, 128, 128, 128, 126, 128, 126, 126, 128, 128, 126, 126, 128, 128, 126, 126, 127, 126, 128, 126, 126, 128, 128, 128, 126, 126, 126, 128, 128, 126, 126, 126, 128, 128, 126, 128, 128, 126, 126 }; byte hat[] = { 127, 128, 225, 217, 99, 38, 61, 153, 152, 144, 133, 73, 122, 144, 65, 188, 87, 170, 164, 111, 122, 151, 114, 88, 174, 77, 140, 92, 122, 141, 156, 124, 121, 123, 126, 133, 132, 139, 119, 120, 127, 141, 130, 122, 129, 127, 132, 121, 139, 118, 130, 131, 129, 132, 130, 134, 126, 128, 130, 126, 122, 132, 129, 127, 131, 126, 128, 127, 126, 125, 127, 125, 128, 125, 128, 128, 127, 127, 126, 127, 128, 128, 128, 127, 127, 127, 127, 127, 128, 127, 127, 126, 127, 127, 128, 127, 128, 126, 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 126, 126, 128, 127, 126, 127, 126, 127, 127, 126, 127, 126, 127, 127, 127, 127, 127, 126, 127, 127, 127, 126, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 126, 126, 126, 127, 127, 127, 126, 127, 127, 127, 126, 127, 127, 126, 127, 127, 127, 127, 127, 127, 126, 126, 126, 126, 126, 126, 126, 127, 127, 126, 127, 126, 126, 127, 126, 127, 126, 126, 126, 126, 126, 126, 126, 127, 127, 126, 127, 127, 127, 127, 126, 126, 127, 127, 127, 126, 127, 126, 127, 127, 127, 127, 127, 126, 126, 127, 127, 126, 127, 127, 127, 127, 126, 127, 127, 127, 127, 127, 127, 127, 127 }; byte crash[] = { 127, 128, 225, 217, 99, 38, 61, 153, 152, 144, 133, 73, 122, 144, 65, 188, 87, 170, 164, 111, 122, 151, 114, 88, 174, 77, 140, 92, 122, 141, 156, 124, 121, 123, 126, 133, 132, 139, 119, 120, 127, 141, 130, 122, 129, 127, 132, 121, 139, 118, 130, 131, 129, 132, 130, 134, 126, 128, 130, 126, 122, 132, 129, 127, 131, 126, 128, 127, 126, 125, 127, 125, 128, 125, 128, 128, 127, 127, 126, 127, 128, 128, 128, 127, 127, 127, 127, 127, 128, 127, 127, 126, 127, 127, 128, 127, 128, 126, 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 126, 126, 128, 127, 126, 127, 126, 127, 127, 126, 127, 126, 127, 127, 127, 127, 127, 126, 127, 127, 127, 126, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 126, 126, 126, 127, 127, 127, 126, 127, 127, 127, 126, 127, 127, 126, 127, 127, 127, 127, 127, 127, 126, 126, 126, 126, 126, 126, 126, 127, 127, 126, 127, 126, 126, 127, 126, 127, 126, 126, 126, 126, 126, 126, 126, 127, 127, 126, 127, 127, 127, 127, 126, 126, 127, 127, 127, 126, 127, 126, 127, 127, 127, 127, 127, 126, 126, 127, 127, 126, 127, 127, 127, 127, 126, 127, 127, 127, 127, 127, 127, 127, 127 }; void setup() { DDRD = DDRD | B11111100; //In attempt to try and use an ATtiny, I got an error here } void loop() { for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar2[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar3[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar2[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar4[j]); } } // Playback Functions void playBeat(byte beat) { if(beat == 0) { for(int i = 0; i < 256; i ++) { delayMicroseconds(analogRead(0) + 1); } } else if(beat == 1) { playKick(); } else if(beat == 2) { playSnare(); } else if(beat == 3) { playHat(); } else if(beat == 4) { playCrash(); } delay(delayTime); } void playKick() { for(int i = 0; i < 256; i ++) { PORTD = kick[i]; delayMicroseconds(analogRead(0) + 1); } PORTD = 127; } void playSnare() { for(int i = 0; i < 256; i ++) { PORTD = snare[i]; delayMicroseconds(analogRead(0) + 1); } PORTD = 127; } void playHat() { for(int i = 0; i < 256; i ++) { PORTD = hat[i]; delayMicroseconds(analogRead(0) + 1); } PORTD = 127; } void playCrash() { for(int i = 0; i < 256; i ++) { PORTD = crash[i]; delayMicroseconds(analogRead(0) + 1); } PORTD = 127; }

Topic by blinkyblinky 


ArduinoISP does not support PORT Output commands?

I was planning to make a drum machine that only requires two pins on the Arduino and so, wanted to use an AtTiny85v but it gives me errors like: 'DDRD' was not declared in this scope ArduinoBeats.cpp: In function 'void setup()': ArduinoBeats:97: error: 'DDRD' was not declared in this scope ArduinoBeats.cpp: In function 'void playKick()': ArduinoBeats:288: error: 'PORTD' was not declared in this scope ArduinoBeats:294: error: 'PORTD' was not declared in this scope ArduinoBeats.cpp: In function 'void playSnare()': ArduinoBeats:304: error: 'PORTD' was not declared in this scope ArduinoBeats:310: error: 'PORTD' was not declared in this scope ArduinoBeats.cpp: In function 'void playHat()': ArduinoBeats:320: error: 'PORTD' was not declared in this scope ArduinoBeats:326: error: 'PORTD' was not declared in this scope ArduinoBeats.cpp: In function 'void playCrash()': ArduinoBeats:335: error: 'PORTD' was not declared in this scope ArduinoBeats:341: error: 'PORTD' was not declared in this scope I had named the sketch ArduinoBeats so that explains all the ArduinoBeats stuff. Does anybody know how to add this command to the AtTiny library? Any help would be appreciated. Here is the code from Little Scale: /* Arduino Beats by Sebastian Tomczak 6 April 2008 */ // Working Variables byte byteA; byte byteB; int delayTime = 100; int barLength = 16; // Beats byte bar1[] = { 1, 0, 1, 0, 2, 4, 1, 2, 1, 0, 1, 0, 2, 1, 3, 0 }; byte bar2[] = { 1, 0, 1, 0, 2, 0, 1, 2, 1, 0, 1, 0, 2, 2, 2, 2 }; byte bar3[] = { 1, 3, 1, 3, 2, 3, 1, 2, 1, 3, 1, 2, 1, 1, 4, 4 }; byte bar4[] = { 1, 0, 1, 0, 2, 2, 0, 2, 2, 1, 1, 4, 1, 1, 4, 4 }; // Samples byte kick[] = { 127, 80, 42, 5, 165, 242, 241, 233, 128, 73, 48, 22, 127, 69, 55, 113, 151, 183, 209, 217, 223, 228, 233, 215, 161, 117, 91, 76, 65, 49, 37, 31, 31, 48, 83, 120, 146, 166, 183, 198, 206, 210, 209, 199, 178, 145, 111, 88, 78, 73, 69, 67, 72, 80, 88, 97, 109, 124, 137, 150, 163, 171, 174, 172, 168, 160, 144, 125, 114, 110, 108, 104, 104, 106, 109, 110, 112, 117, 124, 129, 135, 142, 145, 145, 143, 140, 137, 132, 128, 125, 122, 119, 118, 119, 119, 119, 118, 118, 120, 124, 126, 129, 132, 135, 137, 137, 135, 132, 131, 130, 129, 128, 126, 126, 124, 123, 121, 120, 120, 122, 123, 124, 126, 128, 129, 130, 130, 131, 131, 131, 130, 130, 130, 129, 129, 128, 126, 125, 125, 124, 124, 124, 124, 125, 126, 126, 128, 128, 128, 129, 129, 129, 129, 129, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, 128, 127, 126, 128, 128, 128, 128, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126 }; byte snare[] = { 127, 215, 65, 212, 56, 102, 135, 122, 51, 201, 220, 46, 175, 80, 152, 95, 123, 116, 184, 155, 59, 122, 100, 161, 143, 173, 101, 155, 97, 73, 112, 98, 176, 96, 140, 77, 134, 109, 132, 149, 112, 149, 97, 161, 98, 151, 98, 155, 149, 112, 157, 103, 133, 106, 167, 97, 166, 108, 129, 124, 136, 146, 124, 136, 129, 150, 94, 130, 105, 141, 146, 128, 129, 99, 150, 121, 141, 99, 142, 116, 131, 114, 118, 143, 127, 143, 115, 144, 120, 137, 109, 129, 131, 139, 129, 113, 144, 119, 145, 117, 135, 129, 134, 136, 124, 130, 130, 139, 121, 136, 121, 132, 128, 127, 126, 122, 130, 126, 138, 120, 136, 122, 131, 123, 130, 128, 127, 128, 118, 132, 125, 131, 122, 131, 125, 131, 122, 126, 128, 126, 129, 121, 129, 123, 132, 129, 127, 131, 123, 128, 125, 130, 123, 131, 123, 128, 131, 129, 128, 126, 125, 124, 131, 121, 124, 129, 130, 126, 124, 126, 127, 130, 125, 126, 128, 126, 128, 126, 126, 126, 126, 125, 128, 126, 126, 126, 126, 126, 126, 125, 128, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, 126, 128, 126, 127, 126, 128, 125, 127, 128, 128, 126, 126, 128, 126, 126, 128, 128, 128, 128, 128, 126, 128, 126, 126, 128, 128, 126, 126, 128, 128, 126, 126, 127, 126, 128, 126, 126, 128, 128, 128, 126, 126, 126, 128, 128, 126, 126, 126, 128, 128, 126, 128, 128, 126, 126 }; byte hat[] = { 127, 128, 225, 217, 99, 38, 61, 153, 152, 144, 133, 73, 122, 144, 65, 188, 87, 170, 164, 111, 122, 151, 114, 88, 174, 77, 140, 92, 122, 141, 156, 124, 121, 123, 126, 133, 132, 139, 119, 120, 127, 141, 130, 122, 129, 127, 132, 121, 139, 118, 130, 131, 129, 132, 130, 134, 126, 128, 130, 126, 122, 132, 129, 127, 131, 126, 128, 127, 126, 125, 127, 125, 128, 125, 128, 128, 127, 127, 126, 127, 128, 128, 128, 127, 127, 127, 127, 127, 128, 127, 127, 126, 127, 127, 128, 127, 128, 126, 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 126, 126, 128, 127, 126, 127, 126, 127, 127, 126, 127, 126, 127, 127, 127, 127, 127, 126, 127, 127, 127, 126, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 126, 126, 126, 127, 127, 127, 126, 127, 127, 127, 126, 127, 127, 126, 127, 127, 127, 127, 127, 127, 126, 126, 126, 126, 126, 126, 126, 127, 127, 126, 127, 126, 126, 127, 126, 127, 126, 126, 126, 126, 126, 126, 126, 127, 127, 126, 127, 127, 127, 127, 126, 126, 127, 127, 127, 126, 127, 126, 127, 127, 127, 127, 127, 126, 126, 127, 127, 126, 127, 127, 127, 127, 126, 127, 127, 127, 127, 127, 127, 127, 127 }; byte crash[] = { 127, 128, 225, 217, 99, 38, 61, 153, 152, 144, 133, 73, 122, 144, 65, 188, 87, 170, 164, 111, 122, 151, 114, 88, 174, 77, 140, 92, 122, 141, 156, 124, 121, 123, 126, 133, 132, 139, 119, 120, 127, 141, 130, 122, 129, 127, 132, 121, 139, 118, 130, 131, 129, 132, 130, 134, 126, 128, 130, 126, 122, 132, 129, 127, 131, 126, 128, 127, 126, 125, 127, 125, 128, 125, 128, 128, 127, 127, 126, 127, 128, 128, 128, 127, 127, 127, 127, 127, 128, 127, 127, 126, 127, 127, 128, 127, 128, 126, 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 126, 126, 128, 127, 126, 127, 126, 127, 127, 126, 127, 126, 127, 127, 127, 127, 127, 126, 127, 127, 127, 126, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 126, 126, 126, 127, 127, 127, 126, 127, 127, 127, 126, 127, 127, 126, 127, 127, 127, 127, 127, 127, 126, 126, 126, 126, 126, 126, 126, 127, 127, 126, 127, 126, 126, 127, 126, 127, 126, 126, 126, 126, 126, 126, 126, 127, 127, 126, 127, 127, 127, 127, 126, 126, 127, 127, 127, 126, 127, 126, 127, 127, 127, 127, 127, 126, 126, 127, 127, 126, 127, 127, 127, 127, 126, 127, 127, 127, 127, 127, 127, 127, 127 }; void setup() { DDRD = DDRD | B11111100; //In attempt to try and use an ATtiny, I got an error here } void loop() { for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar2[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar3[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar2[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar1[j]); } for(int j = 0; j < barLength; j ++) { playBeat(bar4[j]); } } // Playback Functions void playBeat(byte beat) { if(beat == 0) { for(int i = 0; i < 256; i ++) { delayMicroseconds(analogRead(0) + 1); } } else if(beat == 1) { playKick(); } else if(beat == 2) { playSnare(); } else if(beat == 3) { playHat(); } else if(beat == 4) { playCrash(); } delay(delayTime); } void playKick() { for(int i = 0; i < 256; i ++) { PORTD = kick[i]; delayMicroseconds(analogRead(0) + 1); } PORTD = 127; } void playSnare() { for(int i = 0; i < 256; i ++) { PORTD = snare[i]; delayMicroseconds(analogRead(0) + 1); } PORTD = 127; } void playHat() { for(int i = 0; i < 256; i ++) { PORTD = hat[i]; delayMicroseconds(analogRead(0) + 1); } PORTD = 127; } void playCrash() { for(int i = 0; i < 256; i ++) { PORTD = crash[i]; delayMicroseconds(analogRead(0) + 1); } PORTD = 127; }

Question by blinkyblinky   |  last reply