To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.handyboardOpen lugnet.robotics.handyboard in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Handy Board / 8337
8336  |  8338
Subject: 
Re: Sample Code
Newsgroups: 
lugnet.robotics.handyboard
Date: 
Thu, 15 Mar 2001 19:34:12 GMT
Viewed: 
1107 times
  
    Here a fonction to read an analog port and compare it to two value.
Entrie are the nummer of analog entrie (0..7). The function return 0 if
lower than the first value, 1 if between the two and 2 if greater than the
second.
    Comment and variable names are in French.



/* Couleurs : */
#define BLANC 0
#define VERT 1
#define NOIR 2

/* Seuils de détection de couleurs : */
#define SEUILVERT 20
#define SEUILNOIR 230

/***************************************************************************
***/
/* Fonction : Couleur().
Objet : Renvoyer la couleur lue par un capteur.
Entrée : Numéro du capteur (0..7).
Sortie : Couleur.
*/
/***************************************************************************
***/

int Couleur(int i_Capteur)
{
    return (analog(i_Capteur)>SEUILVERT) + (analog(i_Capteur)>SEUILNOIR); /*
tests additionnés (true=1, false=0) */
}

/* sample main */
void main()
{
    ao(); /* ensure that motor are off */
    printf("%d\n", Couleur(0));
    while(1); /* prevent the processor to exit main and execute garbage
code*/
}



Message is in Reply To:
  Sample Code
 
I am a beginner programmer, and I am having a little trouble getting started. I have an analog input that I need to compare to some values stored in memory. If anyone has a similar program that I could reference, I would really appreciate it. Or if (...) (23 years ago, 15-Mar-01, to lugnet.robotics.handyboard)

2 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR