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

Help with this program

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



Joined: 30 Nov 2016
Posts: 1
Location: peron

View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger

Help with this program
PostPosted: Wed Nov 30, 2016 5:12 pm     Reply with quote

Code:

#include <12F675.h>
#Fuses Intro_io,nowdt,noprotect,nomclr
#use delay (clock=400000)
#define trig pin_b1
#define echo input (pin_b6)

int16 mide_distancia()
{
   int16 centimetros=0; //De 2 a 500cm
   output_high(trig);
   delay_ms(30);
   output_low(trig);
   delay_ms(30);
   while (echo==0);
   while (echo==1);
   {
   centimetros ++;
   delay_ms(60);
   }
   return (centimetros);


void main (void)
   {
      {
         distancia=mide.distancia();
         if(distancia <100)
      }
      {
         output_high(pin_b5);
         delay_ms(1000);
         output_low(pin_b5);
         delay_ms(500);
      }
      else
      output_low(pib_b5);
   } //Fin del while
}// fin del voin main (void)

This have 11 errors and i cant resolve them
_________________
peron
temtronic



Joined: 01 Jul 2010
Posts: 9244
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Nov 30, 2016 5:40 pm     Reply with quote

re:
#use delay (clock=400000)

invalid clock option ?

400KHz probably isn't correct

I 'think' it should be 4000000 or 4M. Four Megahertz ?


When posting a program use the 'code' button, 5th option in the 'Message body' line under the Subject line....

That will really help !!


Jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Nov 30, 2016 6:12 pm     Reply with quote

It's clear that you copied that program from here:
http://www.forosdeelectronica.com/f26/sensor-distancia-hc-sr04-78308/
It's also clear that you hand typed it, and made many mistakes in typing.
You also left off braces. Just copy and paste code. Don't hand type it.

It looks like they got the code from here:
http://campos-inventronica.blogspot.com/2012/04/como-usar-sensor-ultrasonico-hc-sr04.html
The page above has many more explanations of how the code works
(in Spanish).

Also, the 12F675 doesn't have a Port B. You can't use pins such as
PIN_B6. It only has Port A. You can only use:
Quote:
PIN_A0
PIN_A1
PIN_A2
PIN_A3
PIN_A4
PIN_A5


Finally, attention to detail is important in writing programs. You have
mis-spelled words:
Quote:
Intro_io
output_low(pib_b5);
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