View unanswered posts | View active topics It is currently Sun Aug 09, 2020 5:14 am

Reply to topic  [ 2 posts ] 
HiTechnic Prototype board 
Author Message

Joined: Sat Dec 19, 2009 5:46 am
Posts: 22
Post 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,


Sat Jun 19, 2010 5:59 am
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post 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

| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]

Sat Jun 19, 2010 12:31 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

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 post attachments in this forum

Search for:
Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.