HiTechnic Prototype board
Page 1 of 1

Author:  DRV47 [ Sat Jun 19, 2010 5:59 am ]
Post subject:  HiTechnic Prototype board


I've just started using the HiTechnic Prototype board. I am using mightor's 3rd-party drivers and I've not been able to understand one thing: how to read the B inputs.

This is HTPB-exp7.c, the code for the 7th experiment of the HiTechnic Experimenters Kit A (magnetic sensor connected to B0 and LED to B4):

#include "drivers/common.h"
#include "drivers/HTPB-driver.h"

task main() {
  // The data to be written: 0x10 = 010000 binary,
  // makes B4 digital port an output.
  HTPBsetupIO(HTPB, 0x10);

  while(true) {
    if(HTPBreadIO(HTPB, 0xF3) == 0) {
      nxtDisplayTextLine(1, "Magnet present");
      HTPBwriteIO(HTPB, 0x10);
    } else {
      nxtDisplayTextLine(1, "Magnet absent");
      HTPBwriteIO(HTPB, 0x00);

Here the mask used to read is 0xF3. Why is that? (bin 11110011 does not seem logical to me...) This code doesn't work for me by the way: it only works when I use 0x01 as the mask.

Could anybody explain what mask is to be used to read any B input? Is it possible to read simultaneously two or more inputs, or a combination of outputs (i.e if I want to check that B0, and B1 are true and B3, and B4 are false ignoring B5)?

Thanks in advance,


Author:  mightor [ Sat Jun 19, 2010 12:31 pm ]
Post subject:  Re: HiTechnic Prototype board


It's been a while since I wrote those programs. It does seem a little odd to use 0xF3 as a value for that. I'll look into it. If your magnet is connected to B0 then 0x01 is indeed the correct mask.

- Xander

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group