I gots a computer question

Hey guys, I got a bit of a question to ask. I'm back at school and the school gave me a laptop to use (I'm in highschool) but it's one that doesn't have "their" school modified disk image on it with their crap like deepfreeze (resets the entire system each reboot) and of course, pretty much everything is cut out of the start menu and it's just generally shit (hence why I had removed the image and installed my own XP on it). Long story short, the tech teacher I was talking with said that (well actually he kept switching his story around) he had the wifi key written down somewhere but couldn't remember where he put it (suuurree). Then he told me a schoolboard admin was coming thursday (this past thurs) and the guy would set it up on my laptop for me. He did come but he never did anything for me, him and the teacher spent all day playing with some new photocopier they got. So yesturday I went on one of THEIR laptops (ironically it was said teacher's laptop he used in the school cept he wasn't there so I was able to use it). I went looking through the computer for where the wifi utility that both I and the school use for managing connection profiles and their keys instead of letting xp handle the wifi. Standard ibm software I got of their site. It appears that the keys are stored in the regristry and not in files, they're listed in folders for each profile. So what I did was save the directory of profiles (there was only one for the wifi). Now it looked like they were hex keys, and I'm pretty sure it is HEX but it's longer than what will fit in the settings for wifi in the ibm program. So I was wondering if the numbers are hashed or something so you have to crack the codes to access the actual hex key? If anyone knows how I can get the key out of the number I can send you the .reg file that I saved. I'm not trying to hack into the school, they know that I need access to it so I can print my work out but the tech teacher seems to be a dumbass (not to mention he looks like captain picard/mr.clean, a combo of both maybe?!!??!).

Posted by Punkguyta 10 years ago


Best way to host svg, stl, source code, other files for an Instructable

I've got several Instructables that explain how to move from a computer file (3d model or Illustrator file) to physical object (3d print, laser engraving, etc.) I would love to be able to put a link to those files in the body of the Instructable itself, so any reader could download them and use them freely. Similar comment for code snippets; inline code works (with careful editing) but it isn't optimal for longer bits of code.

Posted by nomuse 4 years ago


Broke a torx screwdriver in a recessed hex bolts. Removal?

So I was tinkering with the rear suspension of my new GT LTS bike, where I'm going to fit a monster 8.5x2.5 Fox RP shock in place of the standard 5.25x1 shock. When tightening it back up, I learned the meaning of "the right tool for the right job" I used a torx driver instead of a hex key, and it snapped inside. At this point, I don't know how to handle it. I've tried all unobtrusive methods that I know of. Melted hot glue, magnet, banging on the opposite side with a center punch and hammer.. nothing freed it. Problem is it's twisted, and that's holding it in. I figured i'd ask the pros for advice. Picture attached. I'm thinking I may have to drill it out, tap it with a left hand thread, screw that in, and screw the messed up bolt out. Then my only problem is finding a replacement.

Posted by cvxdes 9 years ago


Unable to download Hex and C files

I am trying to download a few .Hex files and all I keep getting is .tmp files. Does anyone have any suggestions? -- Todd

Posted by toddbg 8 years ago


Makefiles and Hex files

I am sorry for my stupidity but I am no AVR programmer. Here is my trouble. I am not so sure how to create a makefile in winavr or a hex file from some source code that I have. Whenever I do have code, it already has the makefile and the HEX file. Also, if you edit source code is the HEX file going to change too or will it stay the same? I noticed, that although an ATtiny85 is supposed to be compatible with the ATtiny25 when I try to program code into an ATtiny85 with ATtiny25 it doesn't work. Is there a place I change it to work with the ATtiny85...?

Posted by blinkyblinky 6 years ago


burning a hex using arduino isp

I had programmed attiny with arduino via arduino as isp . I was programing with atmel studio for a while and wanted to burn the hex file to a chip using arduino isp. i tried a lot but always  was unsuccessful  stk500_getsync(): not in sync: resp=0x00 popped  ny idea how to get rid of this and program it

Posted by geekrex 3 years ago


Oops, you're hex is showing

Looks like the ad banner next to the topographical hand is not translating the weird charaters (BZh91 ... lozenges (etc)). Also, same problem on the main page, a bit lower and to the right, ah there yes. Don't wan't you to lose your sponsers. Other than that, keep up the good work.

Posted by RonGarza 9 years ago


Who likes my new avavtar?

Personally, I really like my new avatar. Isn't it pretty? Feel free to use my avatar, if you want. It's hex-tastic!

Posted by carbon 11 years ago


AVR Programmer

I am building a  AVR Programmer refering from site : http://www.fischl.de/usbasp/ So Please can any body give the  .Hex   file to burn my Atmeg8( the on AVR circuit board). Would be a great Help to me  !  ! Thank a lot - Akshay Jadhav

Posted by akshayjadhav 6 years ago


What to do with an old hexbug

I have the original hex bug toy. It is the one that has the antenna to direct itself. (  http://www.hexbug.com/original ) I was wondering if there was any thing i could do with this toy as like taking it apart and making something new. PLEASE RESOND -Jason ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Posted by Frank Lampard 13 6 years ago


Taser/Shock wand from Car Antenna

I have an old ball-tipped car antenna lying around and I want to turn it into a shock-wand. Any ideas on how to do so? It's still has the hex and threading at the base. Any help is welcome.

Posted by DSJesterXII 3 years ago


Troubles with a Torx Security screw

This is a Tamper Resistant screw called Torx Security because it has a pin in the middle and a common hex driver can't go in. I need to take it out without having to buy a Torx driver (very expensive) and not knowing the size either (I guess 2/4" or 6mm). Thank you for your input!

Posted by Butlersmiles 2 years ago


need help with programming

Im new at programming microcontrollers and im trying to program an attiny13. i have the cradle and a USB Programmer but im really confused on how to add the code to the microcontroller. i tried to download a sample version here to test it out but i dont understand what im looking at (the code i want to test with is called test_leds.hex( this just makes the leds flash to test it) and its near the bottom under "pulling it together".i downloaded the WinAVR program which i believe is used to right the code and im using the notepad it came with to right the code but i dont understand how to transfer that code to the microcontroller and i cant seem to make it into a hex file.can anyone tell me what steps i need to take to program the attiny13? and how to use avrdude and to make hex files with winavr? i know its a lot to ask but i seriously want to learn how to do this.

Posted by KT Gadget 9 years ago


Microcontroller inputs in C language?

I'm having problems finding and figuring how to do inputs with mirocontrollers VIA button press >> led goes on.(I have a ATTINY2313)Outputs are as simple as PORTB = 0x10 (being hex for pin 16). Keep in mind I'm very new to micros and C. The most I've done was fast-slow blink patterns. How can i do inputs though? SIMPLE code sample is welcomed!

Posted by Killa-X 10 years ago


All Terrain Hex Limbed Extra Terrestrial Explorer

Here is some inspiration for those robotics hobbyists out there. It is the ATHLETE Robot designed by Jet Propulsion Lab in Pasadena, California. The fast motion videos are my favorite. It has some nice moves, however they might be a little slow.http://www.popsci.com/military-aviation-space/article/2008-04/lunar-habitat-hauler( A portion of the article)The Winnebago isn't exactly a marvel of technology. But there is a good chance that NASA's next generation of lunar travelers will live and work out of a two-piece system mobile robot and habitat combination that will allow astronauts to bring base camp with them that has plenty in common with the humble RV.What you see on this page is the part that makes this home mobile: Athlete (All-Terrain Hex-Limbed Extra-Terrestrial Explorer), a six-limbed habitat-hauler being developed by the Jet Propulsion Laboratory in Pasadena, California. Made of aluminum, this prototype Athlete is eight feet wide and seven feet tall. It gets around using six independently controlled legs equipped with ultra-light wheels. In more-challenging terrain, the wheels can lock in place and function as feet, allowing Athlete to tiptoe through boulder-strewn fields or climb up steep hills. The mission-ready robot, which will be about twice the size of the prototype pictured here and made of steel, should be able to haul a load of up to 15 tons pretty much anywhere it wants to as long as it obeys a 3mph speed limit. That is about as fast as you can go without risking flipping over because of the low gravity, explains Brian Wilcox, the primary investigator on the Athlete project.Here is an informational video of the ATHLETE. Here is a video of the ATHLETE in action! ( Photo from http://www.pestaola.gr/img1/nasa-athlete-rover.jpg)

Posted by Brennn10 10 years ago


ESP8266 WiFi Module

You need a separate grouping for this module under Technology This is a Microprocessor running at 80Mhz to 160 Mhz  with 512 kB to 4 Mb of program memory It costs $3 and is programmed with various languages compiled to machine hex and uploaded by a variety of programs to run entirely on its own with a 3.3Volt power supply . It connects to your modem , acts as a modem , serves web pages and sends to web pages and a whole lot of other stuff I have not used yet See here in the wiki for more detail   http://www.esp8266.com/wiki/doku.php

Posted by tytower 3 years ago


PIC Microcontrollers

Hello. I'm just making my entrance into the world of microcontrollers. But as I self learning everything I have a few questions. I recently purchased 2 PICS (16F648A) and a programming board. The board works fine and I got it to connect to the computer and reconize the PIC. I guess my first question is, Is all hex code PIC specific? Meaning would I be able to use this code "http://www.voti.nl/blink/index_1.html#16F630" for my PIC? The models are very similar but not exact. If not, I would like to do the standard "Blink an LED" as my first project. How would I write my code for this PIC and what materials would I need? Thanks!

Posted by jefferson987 10 years ago


Want to learn image encoding & decoding????

I remember how i learned html css xml by opening files in notepad also I remember once i tried to open a 1X1pixels .bmp image in hex editor but it was all blur everything went above my head i was not able to locate magic no. & changing some string made it invalid file. So in short i want a book/ website/ instructable or anything which can teach me to edit image file by watching them in base 16 or base 2 languages or somthing like that . also if there is nothing just tell me the easiest encoded image format maybe i get lucky trying myself. Thanks in advance

Posted by Atul009 5 years ago


Twitter LED table

Macetech has modified this IKEA table with a 9x9 array of RGB LEDs that are controlled by twitter. Anyone can start changing the colors by sending a tweet. Want to try it? Here's an example tweet: #ledtable 0,3,red; 1,2,green; 4,4,#FD2245; #ledtable - lets the table get the message. X,Y,color; - X and Y are coordinates from 0 to 8 and the color is what color you want it to be. You can use a name or a hex code Be sure to end each color with a semicolon. Try it out and see the results in the stream below. For more information, check out the link. Twitter table via Make Free video chat by Ustream

Posted by fungus amungus 8 years ago


Call for pre-made parts!

We're rolling out some new parts for the Kits in 123D Design.  That means you'll soon have some real-world models at your disposal in the Design app, and I wanted to see if there were some specific requests out there for parts that you might use on the regular. I've put in for some tools and hardware - like metric and SAE wrenches and hex bolts - but is there anything that you'd like to see as a part or a template?   M4 screws for an Arduino enclosure? 4" 2-way gate hinges? Eye-Hooks? Light bulbs? Threaded rod? Phone cases?

Posted by andrewt 5 years ago


Any PIC Experts out there?

Can somebody help? I have a few PIC16F628, ISD2532 sound chips and 4-digit seven segment LED displays with MM5450 chips from some old laser-gaming boards that I’d like to do something with but have got completely baffled by the data sheets and the complications of PIC programming. Basically, what I’d like to do is create a ‘dummy bomb’ as a present for my local gaming field along the lines of:- • Have a hex keypad enter an ‘unlock code’. Display and save that code • Use the hex keypad to input the time to start counting down from (Minutes & Seconds). Display and lock in that time • Have a button start to ‘arm’ the bomb and start decrementing the time and display it • When the timer reaches 00.00 then ‘fire’ the sound effect in the MM5450 and have an output go low for triggering something else • The device can be ‘defused’ by entering the correct code (equal to that previously stored) or by cutting the ‘correct’ wire – other wires triggering the device. It would seem to me that the ‘wire cutting’ scenario could be accomplished by using tied inputs – one changing state defuses, the others trigger the device. In an ideal world, the device would have 2 operating modes – timer and non-timer, the non-timer mode allowing for the device to be triggered by trip-wire, breaking an IR beam, a ‘hit’ from a gaming gun, etc. In a perfect world, it could also send a 56Khz IR data stream to ‘kill’ all the gaming guns within range but I don’t know the coding for that data stream and it may be in the realms of fantasy anyway… I don’t have a PIC programmer yet but they don’t seem difficult to build or hard to find – only having a laptop means USB though and that does limit things… I can do all the wiring and packaging but is there somebody who could help me out with the programming and/or general advice? Thanks Duncan

Posted by duncan_a 9 years ago


want help with schaer programmer

Hi every one i just have proplem i want any body help me to solve it 1) i build a schaer programmer with 74ls07 hex buffer and i get the power from transformer power supply i integrated in same circuit i getted from it rigth voltage 13 for vpp and 5 for vdd and i found that ic prog only support schaer programer i make hardware check on programmer and get good rating at vpp and vdd and clock and data in schaer clock and data only avalible when vdd is available i tried to program 16f628a i failed may reason vpp get after vdd ? and i also tried to program 16f684a and faied also i dont realy reason when i try to read from pic i some times get garbage data is it noise on data and clock ? is so how to remove it ? can i use this programmer with winpic800 ? if so tell me how ?

Posted by m_fathy 10 years ago


(Arduino) automated macro-photography rail

Hi everyone, I would like to build an Arduino automated macro-photography rail (let's call it AAMR). I'm a decent software engineer and I want to learn electronics, so I'm looking for someone telling me I'm going in the right direction... The idea sounds simple, I want to : 1/ place the subject on the AAMR 2/ input the # of pictures needed to perform a "focus stacking" (https://en.wikipedia.org/?title=Focus_stacking) 3/ push the start button and make the AAMR loop n times through the following steps : - trigger the camera to take a picture of the subject - move the subject 1 millimetre toward the camera After a couple weeks reading and day-dreaming, here are my thoughts. I need : - to read more :) - a steeper motor and its driver (I own bipolar steppers and L298 / L293 IC) - to trigger the camera (Canon EOS 70d : remote cable is quite easy to make) - a potentiometer and 2* 7segment displays (input and display the # of pictures) - a start button - a reset button to make the rail come back at position Zero - two "end of course" buttons (not sure about the English terminology), just in case the motor wants to jump over the board - power (5v for the arduino and the logic, 12v for the motors) I. Arduino ---------- First things first, I plan to use an Arduino Uno during prototyping and replace it by a home made board in the final product. Uno has 14 Digital I/O Pins and 6 Analog Input Pins : - stepper => 6 Digital pins (3 ?? if using http://www.bristolwatch.com/L298N/L298N_arduino.htm) - 7segment led => 3 Digital pins if using shift registers (https://www.instructables.com/id/Different-methods-of-driving-7-Segment-LED-display/step5/null/) - start button => 1 Digital pin - reset button => 1 Digital pin - "end of course" buttons => 2 Digital pins - camera trigger => 1 Digital pin (to drive an opto isolator / solid state relay) - potentiometer => 1 Analog pin 14 Digital pins ! Uno should do the job, am I right ? (I know I could use Analog pins as Digital ones, but it seems I don't need it...) II. PSU ------- Next interrogation is about power supply : I don't want a battery powered device and my options are scarce : - ATX PSU supplies both 5 and 12v, but Arduino seems to like >5v, so ATX doesn't seem a good choice - home made PSU from an existing wall wart -> voltage divider to get ~7v and ~14v -> 7805/7812 voltage regulator (may need heatsinks and/or little fan) If I do the math : - Arduino : 50ma - Stepper motor : 700mA max - L298 : 70mA (quiescent current) - 2* 7Segment LED (multiplexed) : 2 * 80mA (estimated) - Shift registers IC (SN74HC595N) : 1ma (optional : Hex inverter 74LS04 : ?? mA) Total : around 980mA... Am I doing right ? I have tons of questions left (Hex inverter, filter capacitors, motor noise reduction, solid state relays...), but it's a good start :) Sorry for the long post, and thanks in advance for your answers ! D

Posted by djezzz 3 years ago


Understanding/Interpreting a firmware update

Hi, I'll try to break this down as simply as I can, because there are bits I barely understand myself. Here's what I've got physically: Orca electronic speed control (ESC) for my RC car (based on unknown, unmarked MCU) Orca USB Link for updating firmware on the ESC (USB link is based on Silabs F321) Here's what I've got electronically: I've got a .bin file in my iMac that is the latest update for the ESC and the Orca update software, that acts as the link between the devices Here's what I've already done: I already have a firm grasp on loading new firmware on to the ESC Here's what I want to do: I'd like to be able to toy around with the data in the .bin file, but I honestly have no idea of how to interpret the data contained therein. I've played with it in a few hex editing programs and got a few words to appear in something approaching English, but nothing concrete. I guess the basic problem is understanding what "language" this was written in. (I'm not even sure if it's 8 or 32 bit) I think after that's figured out, I can work backwards from there. Ultimately, I'd like to understand how all of this works and how the MCU interprets the information and signals it's being fed. Any thoughts you can offer on the subject would be appreciated. Here's a kink to the firmware update, should you choose to look at it. Thanks! http://www.orcarc.com/download/ORCAQ%20ver2.1%20111125A.BIN

Posted by monkeyracing 5 years ago


(newsletter) Geiger Lamp, Homemade Paper, Viking Shoes...

Sign-up for this newsletter: Earthjustice United States of Efficiency Contest - Create an energy-saving Instructable and you could win a MacBook Pro! April Fools Contest - Share your best pranks, tricks, and practical jokes! Klutz Rubber Band-Powered Contest - Open to any rubber band-powered contraption. Win cool books from Klutz!Burning Questions 7 - Answer our questions and win the love of thousands, or at least a spiffy new t-shirt! ThinkGeek Hacks Contest - Hack or modify any ThinkGeek item and win a $250 gift certificate! Epilog Challenge - Enter any awesome project with a green twist for the chance to win an Epilog Zing laser cutter or gift certificates from Ponoko! Viking Shoes JB Weld Casting Build Your Own Earth Box VHS Cassette Clock Win a laser cutter! Stretch, twist, and power something cool Ultimate DeskSquid / Helping Hand Get Your Two Year old to Spell Her Name Homemade Paper Baked Brie Featured questions from our new Answers section: What's the best poison oak treatment? Is there an easy way to run a computer/laptop from a car battery? Unclog Sink Pipes Geiger Lamp Make Your Own Wedding Invitations Build a Simple Security Camera Safe Let your geekiness shine! Share your best tricks! Key Ring Hex Bit Use Spaghetti to Paint Like Jackson Pollock Layered Glass Art Make a Quick Knife from a Clutch Finger Sign-up for this newsletter:

Posted by noahw 9 years ago


Structure advice needed for future teaching sessions of an AS child

Here is my dilema:  I haven't a lot to spend, nor do the parents of the child I am mentoring (Asperger's Syndrome).  Kits and puzzles are great, but can range in price from a few dollars to over $100 a PIECE.   I have been trying to go through Instructables and pick out "low cost", made from scratch, projects that would be suited for an 8 year old (soldering is out, but squshy circuits look good, etc), and would keep her engaged.   My biggest problem is not knowing "what" to look under.  I haven't a critiera idea on how to get to what I want quickly (I don't always have a LOT of time on line). I would like to make plans for at least 4-6 months ahead of time, so I can start on "putting together" what is needed for those projects. ANY suggestions will be helpful and I would be very grateful for any help in this matter.   Those experienced in teaching may have the best ideas, but all others are welcome too.  Out next session looms and the kit I got is a bit too advanced for the present situation;  so I am "projectless" other then a few small things like showing her how I made my Bristle Bot, and etc. So far, shes constructed 2 soda can bots,  a skeliton of a T.Rex excavated from a block of  P.O.P. (I think), a hex bot, a few T.Rex models, the Hadogenes Troglodyte puzzle her and I built,, a model of the solar system, etc and etc. She is going to be a real challange for me to find new and engaging things to create..... Thanks ahead of time for all that can assist...

Posted by Goodhart 6 years ago


MPLAB and PIC16F628A, basic EEPROM functions wont work

Hello all Ive got a query about the simulator in MPLAB.  I'm using a PIC16F628A-IP and Ive written a couple of subs to run the EEPROM functions, but when I try and run the program in the simulator and observe the registers, I'm noticing that EECON1 is not accepting bit changes, and when reading from the EEPROM, i get as far as getting the correct value into W register (MOVFW EEDATA), then the next step, simply a RETURN command, for no reason wipes the W register back to 0 and hence the routine always returns a 0 Can somebody have a look and see whats going wrong, this is one of the easiest routines to write as there are so many examples on the web, Ive even used code straight from Microchip's Code Library and that didnt work either, its driving me MAD!!! All I am trying to do with the following code is simply read the EEPROM contents of address 05, display the returned contents to PORTB, wait a second, then increment the contents by 1 and resave into the EEPROM at address 05, so by rights on power up I should see FF then 00 then 01 then 02, etc, incrementing every second, on PORTB....I'm a bit of a stickler for custom keywords so sorry if its a bit confusing, makes perfect sense to me of course! ;  GENERIC PROGRAMMING HEADER  LIST P=16F628A   ; DETERMINE CORE TYPE  INCLUDE "P16F628A.INC" ; INCLUDE DEFAULT ASSEMBLY FILE FOR THIS CORE  ORG 00H     ; START PROGRAM AT LINE 0  RADIX HEX    ; ASSUME HEX UNLESS SPECIFIED  ERRORLEVEL -302  ; NO BANK WARNINGS DURING ASSEMBLY   ;  SET BURN CONIFGURATION FOR NO WDT AND INTERNAL OSC AT 4MHZ  __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_OFF &_INTRC_OSC_NOCLKOUT & _MCLRE_OFF & _LVP_OFF ;  CONSTANTS AND VARIABLES OPT  EQU 81H  ; OPTION REGISTER NN  EQU 02AH ; GENERAL N REGISTER FOR COUNTING DELAYS XX  EQU 02BH ; GENERAL X REGISTER FOR COUNTING DELAYS YY  EQU 02CH ; GENERAL Y REGISTER FOR COUNTING DELAYS TEMP EQU 02DH ; GENERAL TEMPORARY FOLDER 1 TMP  EQU 02EH ; GENERAL TEMPORARY FOLDER 2 FLAGS EQU 020H ; MISCELLANEOUS PROGRAM SPECIFIC FLAGS N  EQU 021H X  EQU 022H ; GENERAL TEMP STORES Y  EQU 023H ;  CUSTOM INSTRUCTIONS #DEFINE   BANK0     BCF       STATUS,RP0          ; Sel Bank 0 #DEFINE   BANK1     BSF       STATUS,RP0          ; Sel Bank 1 #DEFINE   READNVM CALL READ #DEFINE   WRITENVM CALL WRITE #DEFINE   W10MS  CALL DELAY #DEFINE   W1S  CALL DELAY1S ;----------------------------------------------------------------- ;  INITIALISE MICRO ;----------------------------------------------------------------- INIT   BANK1   CLRF  TRISB ; PORT B DEFINED ALL OUTPUTS   MOVLW 0FFH   MOVWF TRISA ; PORT A ALL INPUTS   BANK0 ;  SET TO MIMIC 16F84 BY TURNING OFF COMPARATOR   MOVLW 07H   MOVWF CMCON ;  PURGE GENERAL RAM FILES   CLRF NN   CLRF XX   CLRF YY   CLRF TEMP    CLRF TMP    CLRF FLAGS   CLRF N   CLRF X   CLRF Y   CLRF PORTA   CLRF PORTB   CLRF OPT   CLRF INTCON   ;------------------------------------------------------------------- ;  MAIN PROGRAM ;------------------------------------------------------------------- MAIN; ORIGIN   MOVLW 05   READNVM   MOVWF PORTB   W1S   MOVLW 05   MOVWF EEADR   MOVF PORTB,W   INCF W,1   MOVWF EEDATA   WRITENVM   GOTO  MAIN ;--------------------------------------------------------------------------- ;  END OF MAIN PROGRAM BODY ;---------------------------------------------------------------------------   GOTO FINISH  ; PROGRAM LOOP FALLOUT ;--------------------------------------------------------------------------- ;  SUBROUTINES ;--------------------------------------------------------------------------- ; LIST OF AVAILABLE SUBS: ; DELAY  = 10mS DELAY ; DELAY1S  = 1 sec DELAY ; WRITE  = WRITE TO EEPROM, MUST BE LOADED WITH EEDATA AND EEADR B4 ENTRY ; READ  = READ FROM EEPROM ADDRESS HELD IN W BEFORE ENTRY, RETURN RESULT IN W ;  10mS DELAY DELAY       MOVLW 0AH   MOVWF XX OUTER   MOVLW 0C7H   MOVWF YY INNER   NOP         NOP         DECFSZ  YY,1         GOTO    INNER                 DECFSZ  XX,1         GOTO    OUTER   NOP   NOP   NOP   NOP   NOP   NOP   NOP         RETURN DELAY1S   ; 100x10mS DELAYS   MOVLW  064H   MOVWF NN D1L  W10MS   DECFSZ NN,1   GOTO D1L    RETURN   WRITE       BANK1         CLRF EECON1                        BSF EECON1,WREN            ; enable write   W10MS   W10MS   BCF INTCON,GIE         MOVLW H'55'                ; magic sequence         MOVWF EECON2                       MOVLW H'AA'                          MOVWF EECON2                       BSF EECON1,WR   W10MS   W10MS             eeloop BTFSC EECON1,WR            ; wait for WR to go low         GOTO eeloop                ; not yet         BCF EECON1,WREN                    BCF INTCON,GIE           ; clear the interrupt flag         BANK0   W10MS   W10MS         RETURN READ BCF EECON1,WREN   MOVWF EEADR                ; set up eeprom address from W         BANK1   BSF EECON1,RD              ; set the read bit         BANK0   MOVFW EEDATA              ; return value in W         RETURN   ;  PROGRAM ENDS FINISH   END Note, this will probably make more sense if its copied and pasted into an ASM in MPLAB, as the tab stops and comments become more apparent THanks for looking  

Posted by whitebakecase 8 years ago


Virtualwire RF 433mhz Voltage problem

Hi, i am trying to have it switch a 5v relay on pin 8 receiver side only when pin 2 transmitter side in held down. I have set up a XY-MK 5v transmitter , Push button to pin 2 live when pushed 3.3v Data rf transmitter to pin 4 and 5v,gnd and receiver, data pin 2 5v and gnd led to pin 8 and gnd Here are the codes. Transmitter Code= #include const int button = 2; const int transmit_pin = 4; const int receive_pin = 2; const int transmit_en_pin = 3; void setup() {   // Initialise the IO and ISR   Serial.begin(9600);   vw_set_tx_pin(transmit_pin);   vw_set_rx_pin(receive_pin);   vw_set_ptt_pin(transmit_en_pin);   vw_set_ptt_inverted(true); // Required for DR3100   vw_setup(2000);  // Bits per sec } byte count = 1; void loop() {   char msg[7] = {'h','e','l','l','o',' ','#'};   if     (digitalRead(button) == HIGH)   {Serial.println("on its way");   msg[6] = count;   //digitalWrite(led_pin, HIGH); // Flash a light to show transmitting   vw_send((uint8_t *)msg, 7);   Serial.println("on its way");   vw_wait_tx(); // Wait until the whole message is gone   //digitalWrite(led_pin, LOW);   //delay(1000);   count = count + 1; } } And receiver code = #include const int led_pin = 8; const int transmit_pin = 12; const int receive_pin = 2; const int transmit_en_pin = 3; void setup() {     delay(1000);     Serial.begin(9600); // Debugging only     Serial.println("setup");     // Initialise the IO and ISR     vw_set_tx_pin(transmit_pin);     vw_set_rx_pin(receive_pin);     vw_set_ptt_pin(transmit_en_pin);     vw_set_ptt_inverted(true); // Required for DR3100     vw_setup(2000);  // Bits per sec     vw_rx_start();       // Start the receiver PLL running } void loop() {     uint8_t buf[VW_MAX_MESSAGE_LEN];     uint8_t buflen = VW_MAX_MESSAGE_LEN;     if (vw_get_message(buf, &buflen;)) // Non-blocking     { int i;         digitalWrite(led_pin, HIGH); // Flash a light to show received good message // Message with a good checksum received, print it. Serial.print("Got: "); for (i = 0; i < buflen; i++) {      Serial.print(buf[i], HEX);      Serial.print(' '); } Serial.println();         digitalWrite(led_pin, LOW);     } } I have tried many different codes i have found and this works the best but.........the voltage is only going from 0.20v to 0.40 on the receiver pin 8. i need this to be 5v any ideas?

Posted by Senken 3 years ago


MIcrochip - ''can't open include file''

Hi ALL! Please help me to find the bug! Yesterday I did the new instalation of the MPLAB X  last version v3.45 after deleting the old. I did the following tutorial to find bugs in the compilation and chip injection: https://www.youtube.com/watch?v=mUofSucHx_E The problem apear when I try to inject the software in the chip with the PICKIT3 when before nevar did so new problem. Today I reinstall all the software again two times and nothing pass than the same error. Script aded here of the only both files. Thank you in advance. Me -------------------------------------- Output feedback START -------------------------------------- make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf make[1]: Entering directory 'C:/Users/Toshiba/MPLABXProjects/PIC18F2550_LED_Flashing.X' make  -f nbproject/Makefile-default.mk dist/default/production/PIC18F2550_LED_Flashing.X.production.hex make[2]: Entering directory 'C:/Users/Toshiba/MPLABXProjects/PIC18F2550_LED_Flashing.X' "C:\Program Files (x86)\Microchip\xc8\v1.38\bin\xc8.exe" --pass1  --chip=18F2550 -Q -G  --double=24 --float=24 --emi=wordwrite --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=-3 --asmlist -DXPRJ_default=default  --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,-download,+config,+clib,-plib   --output=-mcof,+elf:multilocs --stack=compiled:auto:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s"    -obuild/default/production/main.p1  main.c main.c:10: error: (141) can't open include file "main.h": No such file or directory make[2]: *** [build/default/production/main.p1] Error 1 make[1]: *** [.build-conf] Error 2 (908) exit status = 1 nbproject/Makefile-default.mk:100: recipe for target 'build/default/production/main.p1' failed make[2]: Leaving directory 'C:/Users/Toshiba/MPLABXProjects/PIC18F2550_LED_Flashing.X' nbproject/Makefile-default.mk:84: recipe for target '.build-conf' failed make[1]: Leaving directory 'C:/Users/Toshiba/MPLABXProjects/PIC18F2550_LED_Flashing.X' make: *** [.build-impl] Error 2 nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed BUILD FAILED (exit value 2, total time: 606ms) -------------------------------------- Output feedback END -------------------------------------- JAVA are in the last one version up to date My system: SATELLITE L50-A-1F2 Windows 8.1 64-bit 4th generation Intel® Core™ i7-4700MQ processor with Intel® Turbo Boost Technology 2.0 39.6cm (15.6”) , Toshiba TruBrite® HD TFT High Brightness display with 16 : 9 aspect ratio and LED backlighting Hard disk 1 TB Shining silver finish with stripe pattern, black keyboard 8,192 (4,096 + 4,096) MB, DDR3L RAM (1,600 MHz) NVIDIA® GeForce® GT 740M with CUDA™ Technology and NVIDIA® Optimus™ Technology maximum life : up to 4h00min (Mobile Mark™ 2012) weight : starting at 2.40 kg W x D x H : 377.5 x 244.0 x 25.95 mm

Posted by IvanV18 1 year ago


Need a LED circuit to simulate candle

Hey guys, I'm hoping somebody here can help me out. I'm a newbie when it comes to electronics and whatnot. I can read basic electronic schematics (I know symbols for resistors, LEDs, ground, etc). What I'm wanting to do is create some Halloween decorations for my niece and nephew and their friends, which is basically a hand held lantern that has flickering LED's behind frosted glass to give the appearance of a flickering candle. There are several nice instructables I've found here that cover LED flickering, but at most they're dealing with things I'm not really comfortable with (555 timers and other IC's, programmable chips that use hex coding, etc). The effect I'm looking for is a red LED that doesn't flash along with a orange and yellow LED that do flash to give the appearance of a flickering candle flame. I've found a few places that sell these kinds of kits, but I'd only prefer to buy them as a last resort. Since I'm building several of these lanterns by hand, it would really be easier if I could buy several parts (LED's, resistors, caps, etc) and put them all together myself to save money. As I understand it, you can vary the values of the caps and resistors to get not only varying times of flash, but also a fade in/out effect. I think using a 555 timer would probably be easiest to get random flash patterns for the yellow and orange LED's. I'm not opposed to using a 555 timer, it's just I've never used one before and it's been difficult looking at the instructables here that feature 2 LED's that flash or 40 LED's flashing and trying to figure out how I add a solid non-flashing LED into the mix. Would it be simplest to simply buy a flashing orange and yellow LED and then use a cap and resister of varying amounts attached to a battery along with the non-flashing red LED to achieve this affect? Or would it just be simpler to use a 555 timer with two regular LED's to make them flash, and then wire the red LED I don't want flashing outside of the timer's circuit (I guess parallel to it so it still runs off the same battery?). I had considered using 5mm LED, though I'm honestly not sure how bright these would be. I'm not wanting the room to light up like the ceiling light was turned on, but bright enough to definitely be noticeable. I'd also prefer to either run these off of a 9v battery for mobile use or wire up a 12v DC adapter to it for a more permanent solution. I've seen a few sites that offer "single flasher led" schematics, but again, I just don't know how to add another LED to that circuit to have two that flash at different intervals as well as how to add a third LED to it that WON'T flash. I've also seen people use the modified LED tea candles, but again, that is a single LED and I just don't know how to combine that with another (or 2+) LED's in a circuit so they all operate safely off of the same power source. If anybody could lay out the diagram for the three LED's (or if you think it would be brighter to use 2 of each of the 5mm LED's I want to flash for a total of 5 LED's) along with either the r/c circuit or the 555 timer circuit, I'd greatly appreciate it. Like I said before, I've scoured through all of the flashing LED tutorials here, and while they're all really great, there aren't really any that fit my needs and because I'm a novice with this, I don't know how to take the information that's given and apply it to my needs :(. Maybe I need layman's terms for the setup lol. I'm sorry if this is all long winded and a long read, I just wanted to supply as much info as I could to make sure I was (hopefully) understood fully :)

Posted by SmokeGSU 7 years ago


I need help with this code

Hello, I'm creating a PIR Sensor Alarm with Arduino. I'm using Arduino Uno, PIR Sensor, Breadboard, LED, Piezo Buzzer, TTL JPEG Camera, SD Card and SD Card Module (Breakout Board) I tested my code and it didn't give me any errors. However, the LED and the Buzzer are on all the time, my idea is to have them on once the PIR Sensor detects motions. I know that I'm having problem with the code. Therefore, I'd appreciate it so much if someone could find out which parts of my code should I change. ---------------------------- #include #include #include int pirPin = 7; int ledPin = 8;                // choose the pin for the LED int pinSpeaker = 10;           //Set up a speaker on a PWM pin (digital 9, 10, or 11) int minSecsBetweenEmails = 60; // 1 min long lastSend = -minSecsBetweenEmails * 1000l; byte ZERO = 0x00; byte incomingbyte; SoftwareSerial mySerial(2,3);          // Set Arduino pin 2 and 3 as softserial long int a=0x0000,j=0,k=0,count=0,i=0; uint8_t MH,ML; boolean EndFlag=0; File  myFile; void SendResetCmd(); void SetBaudRateCmd(); void SetImageSizeCmd(); void SendTakePhotoCmd(); void SendReadDataCmd(); void StopTakePhotoCmd(); void setup() {   pinMode(pirPin, INPUT);   pinMode(ledPin, OUTPUT);      // declare LED as output   pinMode(pinSpeaker, OUTPUT);   Serial.begin(9600);   Serial.begin(115200); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } mySerial.begin(38400); Serial.print("Initializing SD card..."); // On the Ethernet Shield, CS is pin 4. It's set as an output by default. // Note that even if it's not used as the CS pin, the hardware SS pin // (10 on most Arduino boards, 53 on the Mega) must be left as an output // or the SD library functions will not work. pinMode(10, OUTPUT); if (!SD.begin(10)) { Serial.println("initialization failed!"); return; } Serial.println("initialization done."); } void loop() {   long now = millis();   if (digitalRead(pirPin) == HIGH)   {     digitalWrite(ledPin, HIGH);  // turn LED ON     playTone(300, 160);     delay(150);     if (now > (lastSend + minSecsBetweenEmails * 1000l))     {       Serial.println("MOVEMENT");       lastSend = now;     }     else     {       digitalWrite(ledPin, LOW); // turn LED OFF       playTone(0, 0);       delay(300);         Serial.println("Too soon");     }   }   delay(300); } // duration in mSecs, frequency in hertz void playTone(long duration, int freq) {     duration *= 1000;     int period = (1.0 / freq) * 1000000;     long elapsed_time = 0;     while (elapsed_time < duration) {         digitalWrite(pinSpeaker,HIGH);         delayMicroseconds(period / 2);         digitalWrite(pinSpeaker, LOW);         delayMicroseconds(period / 2);         elapsed_time += (period);     } byte a[32]; int ii; SendResetCmd(); delay(4000);                            //Wait 2-3 second to send take picture command SendTakePhotoCmd(); while(mySerial.available()>0) {   incomingbyte=mySerial.read(); } myFile = SD.open("pic.jpg", FILE_WRITE); //The file name should not be too long while(!EndFlag) {   j=0;   k=0;   count=0;   SendReadDataCmd();   delay(200); //250 for regular   while(mySerial.available()>0)   {      incomingbyte=mySerial.read();     k++;     if((k>5)&&(j<32)&&(!EndFlag))     {      a[j]=incomingbyte;      if((a[j-1]==0xFF)&&(a[j]==0xD9))     //tell if the picture is finished      EndFlag=1;      j++;     count++;     }   } for(j=0;j { if(a[j]<0x10) Serial.print("0"); Serial.print(a[j],HEX);           // observe the image through serial port Serial.print(" "); } for(ii=0; ii myFile.write(a[ii]); Serial.println(); i++; } myFile.close(); Serial.print("Finished writing data to file"); while(1); } void SendResetCmd() { mySerial.write(0x56); mySerial.write(ZERO); mySerial.write(0x26); mySerial.write(ZERO); } void SetImageSizeCmd() { mySerial.write(0x56); mySerial.write(ZERO); mySerial.write(0x31); mySerial.write(0x05); mySerial.write(0x04); mySerial.write(0x01); mySerial.write(ZERO); mySerial.write(0x19); mySerial.write(0x11); } void SetBaudRateCmd() { mySerial.write(0x56); mySerial.write(ZERO); mySerial.write(0x24); mySerial.write(0x03); mySerial.write(0x01); mySerial.write(0x2A); mySerial.write(0xC8); } void SendTakePhotoCmd() { mySerial.write(0x56); mySerial.write(ZERO); mySerial.write(0x36); mySerial.write(0x01); mySerial.write(ZERO); } void SendReadDataCmd() { MH=a/0x100; ML=a%0x100; mySerial.write(0x56); mySerial.write(ZERO); mySerial.write(0x32); mySerial.write(0x0c); mySerial.write(ZERO); mySerial.write(0x0a); mySerial.write(ZERO); mySerial.write(ZERO); mySerial.write(MH); mySerial.write(ML); mySerial.write(ZERO); mySerial.write(ZERO); mySerial.write(ZERO); mySerial.write(0x20); mySerial.write(ZERO); mySerial.write(0x0a); a+=0x20; } void StopTakePhotoCmd() { mySerial.write(0x56); mySerial.write(ZERO); mySerial.write(0x36); mySerial.write(0x01); mySerial.write(0x03); } --------------------------- Thanks a lot!

Posted by fhussein1 4 years ago


: Arduino + Adafruit wave sheild + IR + Keypad sound board

Hi , was wondering if you could point me in the right direction I'm very new to Arduino I built last year a simple board with adafruit wave shield and added a simple 12 digit key pad to play 12 sounds + power up I have got the codes for the KEYES IR receiver so know the IR is correctly connected and library loaded im trying to integrate the IR code so can change the sounds by IR remote ideally with option of the buttons (if have to loose the buttons and just use remote that's fine) have copied the code below for how it works now just buttons   I found some code for Cylon Pumpkin that works great with just the remote but would also like to integrate the 12 digit keypad Thank you in advance for any help or pointers you can suggest Richard CODE FOR 12 DIGIT BUTTON PRESS /* ADAVOICE is an Arduino-based voice pitch changer plus WAV playback. Fun for Halloween costumes, comic convention getups and other shenanigans! Hardware requirements: - Arduino Uno, Duemilanove or Diecimila (not Mega or Leonardo compatible). - Adafruit Wave Shield - Speaker attached to Wave Shield output - Battery for portable use If using the voice pitch changer, you will also need: - Adafruit Microphone Breakout - 10K potentiometer for setting pitch (or hardcode in sketch) If using the WAV playback, you will also need: - SD card - Keypad, buttons or other sensor(s) for triggering sounds Software requirements: - WaveHC library for Arduino - Demo WAV files on FAT-formatted SD card This example sketch uses a 3x4 keypad for triggering sounds...but with some changes could be adapted to use several discrete buttons, Hall effect sensors, force-sensing resistors (FSRs), I2C keypads, etc. (or if you just want the voice effect, no buttons at all). Connections: - 3.3V to mic amp+, 1 leg of potentiometer and Arduino AREF pin - GND to mic amp-, opposite leg of potentiometer - Analog pin 0 to mic amp output - Analog pin 1 to center tap of potentiometer - Wave Shield output to speaker or amplifier - Matrix is wired to pins A2, A3, A4, A5 (rows) and 6, 7, 8 (columns) - Wave shield is assumed wired as in product tutorial Potentiometer sets playback pitch. Pitch adjustment does NOT work in realtime -- audio sampling requires 100% of the ADC. Pitch setting is read at startup (or reset) and after a WAV finishes playing. POINT SPEAKER AWAY FROM MIC to avoid feedback. Written by Adafruit industries, with portions adapted from the 'PiSpeakHC' sketch included with WaveHC library. */ #include #include SdReader card; // This object holds the information for the card FatVolume vol; // This holds the information for the partition on the card FatReader root; // This holds the information for the volumes root directory FatReader file; // This object represent the WAV file for a pi digit or period WaveHC wave; // This is the only wave (audio) object, -- we only play one at a time #define error(msg) error_P(PSTR(msg)) // Macro allows error messages in flash memory #define ADC_CHANNEL 0 // Microphone on Analog pin 0 // Wave shield DAC: digital pins 2, 3, 4, 5 #define DAC_CS_PORT PORTD #define DAC_CS PORTD2 #define DAC_CLK_PORT PORTD #define DAC_CLK PORTD3 #define DAC_DI_PORT PORTD #define DAC_DI PORTD4 #define DAC_LATCH_PORT PORTD #define DAC_LATCH PORTD5 uint16_t in = 0, out = 0, xf = 0, nSamples; // Audio sample counters uint8_t adc_save; // Default ADC mode // WaveHC didn't declare it's working buffers private or static, // so we can be sneaky and borrow the same RAM for audio sampling! extern uint8_t buffer1[PLAYBUFFLEN], // Audio sample LSB buffer2[PLAYBUFFLEN]; // Audio sample MSB #define XFADE 16 // Number of samples for cross-fade #define MAX_SAMPLES (PLAYBUFFLEN - XFADE) // Remaining available audio samples // Keypad information: uint8_t rows[] = { A2, A3, A4, A5 }, // Keypad rows connect to these pins cols[] = { 6, 7, 8, 9 }, // Keypad columns connect to these pins r = 0, // Current row being examined prev = 255, // Previous key reading (or 255 if none) count = 0; // Counter for button debouncing #define DEBOUNCE 10 // Number of iterations before button 'takes' // Keypad/WAV information. Number of elements here should match the // number of keypad rows times the number of columns, plus one: const char *sound[] = { "Crashing" , "Damaged", "InFlight" , "PowerUp" , // Row 1 = Darth Vader sounds "Brkdown3" , "Brkdown2" , "Brkdown" , "PowerUp" , // Row 2 = Godzilla sounds "Landing", "drain" , "Shutdown" , "PowerUp" , // Row 3 = Dug the dog sounds "Silent", "TakeOff", "Vortex" , "PowerUp" , // Row 4 = Cartoon/SFX sound "PowerUp" }; // Extra item = boot sound //////////////////////////////////// SETUP void setup() { uint8_t i; Serial.begin(9600); // The WaveHC library normally initializes the DAC pins...but only after // an SD card is detected and a valid file is passed. Need to init the // pins manually here so that voice FX works even without a card. pinMode(2, OUTPUT); // Chip select pinMode(3, OUTPUT); // Serial clock pinMode(4, OUTPUT); // Serial data pinMode(5, OUTPUT); // Latch digitalWrite(2, HIGH); // Set chip select high // Init SD library, show root directory. Note that errors are displayed // but NOT regarded as fatal -- the program will continue with voice FX! if(!card.init()) SerialPrint_P("Card init. failed!"); else if(!vol.init(card)) SerialPrint_P("No partition!"); else if(!root.openRoot(vol)) SerialPrint_P("Couldn't open dir"); else { PgmPrintln("Files found:"); root.ls(); // Play startup sound (last file in array). playfile(sizeof(sound) / sizeof(sound[0]) - 1); } // Optional, but may make sampling and playback a little smoother: // Disable Timer0 interrupt. This means delay(), millis() etc. won't // work. Comment this out if you really, really need those functions. TIMSK0 = 0; // Set up Analog-to-Digital converter: analogReference(EXTERNAL); // 3.3V to AREF adc_save = ADCSRA; // Save ADC setting for restore later // Set keypad rows to outputs, set to HIGH logic level: for(i=0; i pinMode(rows[i], OUTPUT); digitalWrite(rows[i], HIGH); } // Set keypad columns to inputs, enable pull-up resistors: for(i=0; i pinMode(cols[i], INPUT); digitalWrite(cols[i], HIGH); } while(wave.isplaying); // Wait for startup sound to finish... startPitchShift(); // and start the pitch-shift mode by default. } //////////////////////////////////// LOOP // As written here, the loop function scans a keypad to triggers sounds // (stopping and restarting the voice effect as needed). If all you need // is a couple of buttons, it may be easier to tear this out and start // over with some simple digitalRead() calls. void loop() { uint8_t c, button; // Set current row to LOW logic state... digitalWrite(rows[r], LOW); // ...then examine column buttons for a match... for(c=0; c if(digitalRead(cols[c]) == LOW) { // First match. button = r * sizeof(cols) + c; // Get button index. if(button == prev) { // Same button as before? if(++count >= DEBOUNCE) { // Yes. Held beyond debounce threshold? if(wave.isplaying) wave.stop(); // Stop current WAV (if any) else stopPitchShift(); // or stop voice effect playfile(button); // and play new sound. while(digitalRead(cols[c]) == LOW); // Wait for button release. prev = 255; // Reset debounce values. count = 0; } } else { // Not same button as prior pass. prev = button; // Record new button and count = 0; // restart debounce counter. } } } // Restore current row to HIGH logic state and advance row counter... digitalWrite(rows[r], HIGH); if(++r >= sizeof(rows)) { // If last row scanned... r = 0; // Reset row counter // If no new sounds have been triggered at this point, and if the // pitch-shifter is not running, re-start it... if(!wave.isplaying && !(TIMSK2 & _BV(TOIE2))) startPitchShift(); } } //////////////////////////////////// HELPERS // Open and start playing a WAV file void playfile(int idx) { char filename[13]; (void)sprintf(filename,"%s.wav", sound[idx]); Serial.print("File: "); Serial.println(filename); if(!file.open(root, filename)) { PgmPrint("Couldn't open file "); Serial.print(filename); return; } if(!wave.create(file)) { PgmPrintln("Not a valid WAV"); return; } wave.play(); } //////////////////////////////////// PITCH-SHIFT CODE void startPitchShift() { // Read analog pitch setting before starting audio sampling: int pitch = analogRead(1); Serial.print("Pitch: "); Serial.println(pitch); // Right now the sketch just uses a fixed sound buffer length of // 128 samples. It may be the case that the buffer length should // vary with pitch for better results...further experimentation // is required here. nSamples = 128; //nSamples = F_CPU / 3200 / OCR2A; // ??? //if(nSamples > MAX_SAMPLES) nSamples = MAX_SAMPLES; //else if(nSamples < (XFADE * 2)) nSamples = XFADE * 2; memset(buffer1, 0, nSamples + XFADE); // Clear sample buffers memset(buffer2, 2, nSamples + XFADE); // (set all samples to 512) // WaveHC library already defines a Timer1 interrupt handler. Since we // want to use the stock library and not require a special fork, Timer2 // is used for a sample-playing interrupt here. As it's only an 8-bit // timer, a sizeable prescaler is used (32:1) to generate intervals // spanning the desired range (~4.8 KHz to ~19 KHz, or +/- 1 octave // from the sampling frequency). This does limit the available number // of speed 'steps' in between (about 79 total), but seems enough. TCCR2A = _BV(WGM21) | _BV(WGM20); // Mode 7 (fast PWM), OC2 disconnected TCCR2B = _BV(WGM22) | _BV(CS21) | _BV(CS20); // 32:1 prescale OCR2A = map(pitch, 0, 1023, F_CPU / 32 / (9615 / 2), // Lowest pitch = -1 octave F_CPU / 32 / (9615 * 2)); // Highest pitch = +1 octave // Start up ADC in free-run mode for audio sampling: DIDR0 |= _BV(ADC0D); // Disable digital input buffer on ADC0 ADMUX = ADC_CHANNEL; // Channel sel, right-adj, AREF to 3.3V regulator ADCSRB = 0; // Free-run mode ADCSRA = _BV(ADEN) | // Enable ADC _BV(ADSC) | // Start conversions _BV(ADATE) | // Auto-trigger enable _BV(ADIE) | // Interrupt enable _BV(ADPS2) | // 128:1 prescale... _BV(ADPS1) | // ...yields 125 KHz ADC clock... _BV(ADPS0); // ...13 cycles/conversion = ~9615 Hz TIMSK2 |= _BV(TOIE2); // Enable Timer2 overflow interrupt sei(); // Enable interrupts } void stopPitchShift() { ADCSRA = adc_save; // Disable ADC interrupt and allow normal use TIMSK2 = 0; // Disable Timer2 Interrupt } ISR(ADC_vect, ISR_BLOCK) { // ADC conversion complete // Save old sample from 'in' position to xfade buffer: buffer1[nSamples + xf] = buffer1[in]; buffer2[nSamples + xf] = buffer2[in]; if(++xf >= XFADE) xf = 0; // Store new value in sample buffers: buffer1[in] = ADCL; // MUST read ADCL first! buffer2[in] = ADCH; if(++in >= nSamples) in = 0; } ISR(TIMER2_OVF_vect) { // Playback interrupt uint16_t s; uint8_t w, inv, hi, lo, bit; int o2, i2, pos; // Cross fade around circular buffer 'seam'. if((o2 = (int)out) == (i2 = (int)in)) { // Sample positions coincide. Use cross-fade buffer data directly. pos = nSamples + xf; hi = (buffer2[pos] << 2) | (buffer1[pos] >> 6); // Expand 10-bit data lo = (buffer1[pos] << 2) | buffer2[pos]; // to 12 bits } if((o2 < i2) && (o2 > (i2 - XFADE))) { // Output sample is close to end of input samples. Cross-fade to // avoid click. The shift operations here assume that XFADE is 16; // will need adjustment if that changes. w = in - out; // Weight of sample (1-n) inv = XFADE - w; // Weight of xfade pos = nSamples + ((inv + xf) % XFADE); s = ((buffer2[out] << 8) | buffer1[out]) * w + ((buffer2[pos] << 8) | buffer1[pos]) * inv; hi = s >> 10; // Shift 14 bit result lo = s >> 2; // down to 12 bits } else if (o2 > (i2 + nSamples - XFADE)) { // More cross-fade condition w = in + nSamples - out; inv = XFADE - w; pos = nSamples + ((inv + xf) % XFADE); s = ((buffer2[out] << 8) | buffer1[out]) * w + ((buffer2[pos] << 8) | buffer1[pos]) * inv; hi = s >> 10; // Shift 14 bit result lo = s >> 2; // down to 12 bits } else { // Input and output counters don't coincide -- just use sample directly. hi = (buffer2[out] << 2) | (buffer1[out] >> 6); // Expand 10-bit data lo = (buffer1[out] << 2) | buffer2[out]; // to 12 bits } // Might be possible to tweak 'hi' and 'lo' at this point to achieve // different voice modulations -- robot effect, etc.? DAC_CS_PORT &= ~_BV(DAC_CS); // Select DAC // Clock out 4 bits DAC config (not in loop because it's constant) DAC_DI_PORT &= ~_BV(DAC_DI); // 0 = Select DAC A, unbuffered DAC_CLK_PORT |= _BV(DAC_CLK); DAC_CLK_PORT &= ~_BV(DAC_CLK); DAC_CLK_PORT |= _BV(DAC_CLK); DAC_CLK_PORT &= ~_BV(DAC_CLK); DAC_DI_PORT |= _BV(DAC_DI); // 1X gain, enable = 1 DAC_CLK_PORT |= _BV(DAC_CLK); DAC_CLK_PORT &= ~_BV(DAC_CLK); DAC_CLK_PORT |= _BV(DAC_CLK); DAC_CLK_PORT &= ~_BV(DAC_CLK); for(bit=0x08; bit; bit>>=1) { // Clock out first 4 bits of data if(hi & bit) DAC_DI_PORT |= _BV(DAC_DI); else DAC_DI_PORT &= ~_BV(DAC_DI); DAC_CLK_PORT |= _BV(DAC_CLK); DAC_CLK_PORT &= ~_BV(DAC_CLK); } for(bit=0x80; bit; bit>>=1) { // Clock out last 8 bits of data if(lo & bit) DAC_DI_PORT |= _BV(DAC_DI); else DAC_DI_PORT &= ~_BV(DAC_DI); DAC_CLK_PORT |= _BV(DAC_CLK); DAC_CLK_PORT &= ~_BV(DAC_CLK); } DAC_CS_PORT |= _BV(DAC_CS); // Unselect DAC if(++out >= nSamples) out = 0; } CODE I FOUND FOR IR  ClyonPumpkin That I want to integrate in above   /* * Text-to-speech example to speak the first n digits of pi. * The number is stored in flash, each digit is spoken one at a time. */ #include #include #include SdReader card;    // This object holds the information for the card FatVolume vol;    // This holds the information for the partition on the card FatReader root;   // This holds the information for the volumes root directory FatReader file;   // This object represent the WAV file for a pi digit or period WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time char eyesound[13]="eye2.wav"; int mute = 0; /* * Define macro to put error messages in flash memory */ #define error(msg) error_P(PSTR(msg)) // IR Remote code int RECV_PIN = 9;  // pin 11 used by SD card interface so select pin 9 for IR IRrecv irrecv(RECV_PIN); decode_results results; long lasttime=0, lastcode=0, timediff=0; //////////////////////////////////// SETUP void setup() {   // set up Serial library at 9600 bps   Serial.begin(9600);               if (!card.init()) {     error("Card init. failed!");   }   if (!vol.init(card)) {     error("No partition!");   }   if (!root.openRoot(vol)) {     error("Couldn't open dir");   }   irrecv.enableIRIn(); // Start the IR receiver } /////////////////////////////////// LOOP void loop() {   if(mute == 0) playcomplete(eyesound);   // check for keypress happened   if (irrecv.decode(&results;)) {      Serial.println(results.value, HEX);      switch (results.value) {        case 0x83228B74:    // 1          playcomplete("command.wav");          break;        case 0x83228F70:    // 2          playcomplete("entertan.wav");          break;        case 0x8322906F:    // 3          playcomplete("extermin.wav");          break;        case 0x83228A75:    // 4          playcomplete("leader.wav");          break;        case 0x8322847B:    // 5          playcomplete("survivor.wav");          break;         case 0x83227887:    // 6          playcomplete("atention.wav");          break;        case 0x8322629D:    // vol up          mute = 0;         // mute off          break;         case 0x83226E91:    // mute          { Serial.println("mute detected");            timediff=millis()-lasttime;            Serial.println(timediff);            if(lastcode!=results.value || (lastcode==results.value && (timediff>1600)) ) {               if( mute == 0 ) { // is mute off?                  Serial.println("toggle off to on");                  mute = 1;      // turn on                  // delay(1000);    // wait a bit for debounce                  break;                 }               if( mute == 1 ) { // is mute on?                  mute = 0;      // turn off                  Serial.println("toggle on to off");                  break;                 }              } // end if             break;           } // end case        } // end switch      lastcode = results.value;      lasttime = millis();      irrecv.resume();   // Receive the next value   } } /////////////////////////////////// HELPERS /* * print error message and halt */ void error_P(const char *str) {   PgmPrint("Error: ");   SerialPrint_P(str);   sdErrorCheck();   while(1); } /* * print error message and halt if SD I/O error */ void sdErrorCheck(void) {   if (!card.errorCode()) return;   PgmPrint("\r\nSD I/O error: ");   Serial.print(card.errorCode(), HEX);   PgmPrint(", ");   Serial.println(card.errorData(), HEX);   while(1); } /* * Play a file and wait for it to complete */ void playcomplete(char *name) {   playfile(name);   while (wave.isplaying);     // see if an error occurred while playing   sdErrorCheck(); } /* * Open and start playing a WAV file */ void playfile(char *name) {   if (wave.isplaying) {// already playing something, so stop it!     wave.stop(); // stop it   }   if (!file.open(root, name)) {     PgmPrintln("Couldn't open file ");     Serial.print(name);     return;   }   if (!wave.create(file)) {     PgmPrintln("Not a valid WAV");     return;   }   // ok time to play!   wave.play(); }

Posted by SithLordIII 4 years ago