Visual Programming for chipKIT

Drag-and-drop visual programming for chipKIT using ArduBlock
Drag-and-drop visual programming for chipKIT using ArduBlock

Newbie programmers, have you ever wanted to program visually by dragging and dropping your “code” instead of tediously writing lines and lines of it? If so, ArduBlock is for you! And Tayeb, of RedAcacia blog, has posted a tutorial to get ArduBlock up and running with your chipKIT board! To get started, you’ll need one of the following: chipKIT Uno32 (or chipKIT uC32), chipKIT Basic I/O Shield, breadboard, light sensor LDR, 10KOhm resistor, and buzzer.

What are you waiting for! 🙂

VN:F [1.9.22_1171]
Rating: 9.0/10 (2 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Getting Started with chipKIT DP32

chipKIT DP32 Pin Diagram by Jay Weeks
chipKIT DP32 Pin Diagram

If you’ve never checked out the chipKIT DP32 board, you now have a good reason. The truth of the matter is that the DP32 is a hidden gem in the collection of chipKIT boards because of its low price and its built-in breadboard.

To explore this little gem visit the tutorial on Instructables (or click the image above), and you’ll find all you need to get started!

VN:F [1.9.22_1171]
Rating: 5.5/10 (2 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Debouncing a Pushbutton

Overview:

A pushbutton is a Mechanical Switch. Switches play an important and extensive role in practically every computer, microprocessor and microcontroller application. Mechanical switches are inexpensive, simple and reliable. However, switches can be very noisy electrically. When a switch, such as a pushbutton is pressed, the connection actually makes and breaks several, perhaps even hundreds, of times before the final switch state settles. The problem is known as switch bounce.

The consequences of uncorrected switch bounce can range from being just annoying to catastrophic.

A software technique called “Debouncing” is one way to solve this problem. Here’s how it works:

Usually, the switch is connected to a pin on the Microcontroller so that it maintains either a HIGH or LOW condition when the switch is open (not pressed). If the switch closes (is pressed) then that condition will change. The Microcontroller detects that change. Instead of reacting right away, the Microcontroller will wait a period of time, say 5 mS, to give the switch a chance to stop bouncing and then checks that pin again. If the pin still reads that the switch is closed, then the Microcontroller will do something about it.

In this tutorial, a pushbutton press (BTN1) will trigger LD1 to light. Otherwise, LD1 will be OFF.

 

Reference:

This tutorial introduces the if/else statement. This type of statement gives your sketch the ability to make decisions based on conditions occurring outside of the Microcontroller or as a result of some sort of internal condition such as the result of some mathematical operation.

We recommend you read the following before proceeding:

 

Hardware Used:

The hardware used in this tutorial will be the chipKIT uC32 along with a chipKIT Basic I/O Shield both manufactured by Digilent Inc. The reference guide for each board, schematics and other resources are available on their individual homepages:

 

Procedure:

  1. Create a new sketch in MPIDE.
  2. Save the sketch with a meaningful name.
  3. Add the following code to your new sketch:
    int ledPin = 26;   // LED connected to digital pin 26
    int pbPin = 4;   //pushbutton BTN1 connected to digital pin 4
    int pbState = LOW; //this variable will hold the value or state of BTN1
                       // i.e. if not pressed, pbState = LOW, if pressed, pbState = HIGH
    
    void setup()
    {
      pinMode(ledPin, OUTPUT);   // sets the digital pin 26 as output
      pinMode(pbPin, INPUT); //sets digital pin 4 as input
      digitalWrite(ledPin, LOW); //make sure LD1 is OFF
    }
    
    void loop()
    {
    
      pbState = digitalRead(pbPin); //read the value, HIGH or LOW, on the pushbutton pin
    
      if (pbState == HIGH) //is pbState HIGH indicating BTN1 is pressed??
      //if yes, do the code inside the curly braces. This is the debounce section
      {
        delay(5); //wait 5 mS for any pushbutton bounce to disappear
        pbState = digitalRead(pbPin); //read the value on the pushbutton pin again
    
        if(pbState == HIGH) //is it still HIGH (pressed)
        {
          digitalWrite(ledPin, HIGH); //Light LD1>
        }
      }
    
      //otherwise
      else
      {
          digitalWrite(ledPin, LOW); //keep LD1 OFF
      }
    
    }
     
  4. In the MPIDE, verify that the chipKIT uC32 and the associated communication port are selected.
  5. Upload the code to the chipKIT Board.
   

Verifying Operation

After the sketch is sent to the chipKIT uC32 board’s Microcontroller, LED 1 (LD1) on the chipKIT Basic I/O Shield should light when pushbutton BTN1 is pressed.

   
VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)