Author Topic: how detect black and white color?  (Read 2543 times)

0 Members and 1 Guest are viewing this topic.

Offline RoboteccanTopic starter

  • Jr. Member
  • **
  • Posts: 20
  • Helpful? 0
how detect black and white color?
« on: November 06, 2010, 03:27:08 PM »
hi, we are making a SumoRobot, and we need that detect white and black color, we are using the AVR studio 4 software and axon microcontroller hardware, and a CNY70 sensor, but the AVR dont have library of CNY70 sensor and I dont know how conect and I dont know how program this sensor, this is my code.

#include "sys/axon.h"

DDRA = 0xFF;

void appInitHardware(void){
pin_make_output(C0, TRUE);
pin_make_input(A0, TRUE);

TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
    return 0;

TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) {

if (pin_is_high(A0)){
   return 1;

please help me.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,696
  • Helpful? 173
    • Society of Robots
Re: how detect black and white color?
« Reply #1 on: November 11, 2010, 10:30:48 AM »
To connect, you should first look at the datasheet:
and look at the picture in the top left.

Then you want to follow the top schematic here:
(read the entire tutorial)

The IR sensor uses an LED, so use this tutorial to select your LED resister (R1):

And use this tutorial to select the resister on the sensor (R2):

A little more reading to understand what's going on:

Now in code, you want to use the analog sensor code in WebbotLib, with the device plugged into the ADC header of your Axon.


Get Your Ad Here