CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Playing wave sounds, change speed

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Skirmitt



Joined: 19 May 2009
Posts: 60

View user's profile Send private message

Playing wave sounds, change speed
PostPosted: Wed Jun 03, 2009 7:49 am     Reply with quote

With the help of a script out of the library I made a working engine noise generator. Now I want to control the speed of it with the help of a PWM servo signal. How can I do this best without interrupting the sound ?

Code:
#include <18F1320.h>

#fuses INTRC_IO, NOWDT, NOPROTECT, BROWNOUT, PUT, MCLR
#use delay(clock = 8000000)

#include "pullc.c"

int delayval;

void main(){
int8 i;
int8 c;
int8 currentbit;

c = sound_data[i];

setup_oscillator(OSC_8MHZ|OSC_INTRC);
setup_adc(ADC_CLOCK_INTERNAL|ADC_TAD_MUL_0);

while(1)
{

for (i=0; i<sound_length; i++){ 
c = sound_data[i];

for (currentbit = 0; currentbit < 8; currentbit++){

   if(  bit_test(c,currentbit)  ){ 
      output_high(pin_b3);
   }
   else{
      output_low(pin_b3);
   }

   delay_us(delayval);

   }
}
}
}


As you see, I have to change the delayval.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group