Welcome!

Welcome to Mr. Campbell's page at Kellenberg Memorial High School. Mr. Campbell is an instructor for the Computer 12 - Computer Science elective, moderator of the Computer Club, and moderator of the KM2ARC Amateur Radio Club

Computer Club Sample 20180417

/*
*Kellenberg Computer Club
*Sonar Demonstration
*/
// defines pins numbers
const int TriggerPin = 9;
const int EchoPin = 10;
const int GreenLight = 5;
const int RedLight = 6;
 
// defines variables
long duration;
int distance;
 
int LoopCount=0;
int FirstTime=1;
 
 
/*This is the Setup Routine.  The Setup Routine will only execute one time per power cycle
 * or reset of the Arduion device
 */
void setup() {
           
          /*First we configure our pins as INPUT and OUTPUT*/
          pinMode(TriggerPin, OUTPUT); // Sets the pin (9) as output.  It is sending a signal
          pinMode(EchoPin, INPUT); // Sets the pin (10) as Input.  Gets the signal
          pinMode(GreenLight,OUTPUT);
          pinMode(RedLight,OUTPUT);
           
          /*Now we are opening the serial line so that we can
           * Send messages to the serial Monitor
           */
          Serial.begin(9600); // We will us the serial port to monitor what is happening in the serial monitor
          
          /*Now we set the TriggerPin Low in initialize it*/
          digitalWrite(TriggerPin, LOW);
          delayMicroseconds(2);
}
 
/*After setup is called, the loop function is called.  once loop gets to the bottom, starts over again.
 * 
 */
void loop() {
                  
           
          // Sets the TriggerPin on HIGH state for 10 micro seconds
          digitalWrite(TriggerPin, HIGH);
          delayMicroseconds(10);
          digitalWrite(TriggerPin, LOW);
           
          // Reads the echoPin, returns the sound wave travel time in microseconds
          duration = pulseIn(EchoPin, HIGH);
 
          // Calculating the distance
          distance= duration*0.034/2;

          if(distance<100){
            Serial.println("Getting too close");
            digitalWrite(GreenLight,LOW);
            digitalWrite(RedLight,HIGH);
          }else{
            digitalWrite(GreenLight,HIGH);
            digitalWrite(RedLight,LOW);
          }
          delay(500); 
          // Prints the distance on the Serial Monitor
          Serial.print("Distance: ");
          Serial.println(distance);
}

mrcampbell / April 17, 2018 / Uncategorized

main.cpp

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.cpp
 * Author: jfcampbelljr
 *
 * Created on April 10, 2018, 12:15 PM
 */
#include "MainDefs.h"
#include <stdio.h>
#include <Windows.h>
#include <cstdlib>

using namespace std;

extern DWORD ListenThread(LPVOID Parms);
int ProgramRunning=1;
/*
 * 
 */
int main(int argc, char** argv) {
    
    DWORD dwListenThread;
    HANDLE hListenerThread;


    char buffer[BUFFER_SIZE];
    printf("Welcome to Computer 12!\n");
    printf("Type X on a line by itself to end.\n");

    hListenerThread=CreateThread(NULL,0,ListenThread,NULL,0,&dwListenThread );
    if(!hListenerThread){
        printf("Error Creating Server / Listener Thread-Program Terminating\n");
        return(0);
    }else{
        /*In windows a handle is a finite resource*/
        /*Our Program may only have so many handles open*/
        /*If we aren't going to use the handle we should close it*/
        CloseHandle(hListenerThread);
    }

    int counter=0;
    while (ProgramRunning){
        
        Sleep(5000);
    }

    return 0;
}


mrcampbell / April 16, 2018 / Uncategorized

Picture of Sparkfun RedBoard

Computer Club – Introduction to Arduino

On Tuesday, March 6, 2018, the Computer Club met formally beginning our Spring meetings.  Each member of the club worked with a SparkFun ReadBoard.  The RedBoard is programmed with Arduino and looks and acts very much like an Arduino Uno.  In fact, when uploading our programs to the RedBoard we tell the Arduino IDE the board is an UNO!

The programs we write are called Sketches.  For our first sketch, we used the example program called “Blink.”  Blink is a program that causes an LED to turn on and off.  The Blink program for Arduino is like a “Hello World” program we might write when trying out a new programming language.  Since there is no built-in display, we use the LED to show that we can make the Arduino “output” something.

Picture of Ardunio Sketch

Our programs for Arduino are called Sketches. Pictured is the sketch to cause an LED to blink.

After uploading our sketch and seeing the result, the blinking LED, we tried changing the delay line to see how that affects the rate of blinking.   We also saw that the LED is labeled with a 13 next to it.  This 13 represents the PIN number the LED is connected to.  This 13 is the same 13 on the headers along the sides of the RedBoard.  Each student was issued an additional LED to connect to PIN 13 and Ground to demonstrate that is was, in fact, the same on the onboard LED.  We also learned that when connecting LEDs we should use resistors to limit the flow of current through the LED which can shorten the life.

Finally, we took a look at the code at http://km2arc.kellenberg.org/introduction-to-the-redboard-and-programming/ , copied and pasted it into a new sketch.  This showed us how the serial monitor works,  demonstrated the difference between local and global variables and showed how the setup() and loop() functions operate.

 

mrcampbell / March 7, 2018 / Computer Club

School Club Roundup – Winter 2018

Kellenberg Memorial High School Amateur Radio Club participated in the School Club Roundup the week of  February 12 – 18th. School Club Roundup is an event sponsored by the Long Island Amateur Radio Club (LIMARC) and the ARRL.  Although the band conditions were not the greatest we were still able to make some contacts on HF (High Frequency) using both digital and phone modes.

Our club ranked 15th with 465 points.  We made 15 contacts using digital modes and 1 phone contact.  Congratulations to all our members that participated in the roundup!

 

 

mrcampbell / March 7, 2018 / KM2ARC

Computer 12 Quiz Thursday, March 8, 2018

For our quiz on Thursday, March 8, 2018, you will be given an example of code and expected to produce the output.  Tuesday you a chance to ask any questions.  Here is an example of what you might expect and how you would answer:

Sample Code:

#include <stdio.h>
int main(int argc, char** argv){

	int x=5;
	printf ("the value of x=%d\n",x);

	do{
	     printf("x is %d\n",x);
             x--;
	}while(x>0);

	printf("DONE!!!\n");
        return(0);
}

This code will produce the following output:

the value of x=5
x is 5
x is 4
x is 3
x is 2
x is 1
DONE!!!

mrcampbell / March 2, 2018 / Computer 12

Computer 12 Python Update

Today we finished our introduction to programming using Python.  Our main objective in this segment is to learn basic programming concepts, including output, input, looping, conditionals, variables, and functions.  The culmination of this segment of instruction was building a simple text-based calculator. Here is a sample of one of our calculators:

#add function
def add(a,b):
    result=a+b
    return(result)
#subtract
def subtract(a,b):
    result=a-b
    return(result)
#multiply
def multiply(a,b):
    result=a*b
    return (result)
#divide
def divide(a,b):
    result=a/b
    return(result)
#Circumference
def Circumference(r):
    circ=2*3.14159*r
    return(circ)

#main function
def main():
    #set selection = to 1 so the condition to start
    #our while loop is true
    selection=1
    while selection>0:
        #print the menu
        print("1: Add")
        print("2: Subtract")
        print("3: Multiply")
        print("4: Divide")
        print("5: Circumference")
        #get the user input
        UserChoice=input("Please make a choice or 0 to exit: ")
        #convert it to an integet
        selection=int(UserChoice)
        #if the choice is 0 we are finished!
        if(selection==0):
            print ("Goodbye")
        elif selection>0 and selection<5: #an operation requiring 2 numbers
            #Do Math!
            #Get 2 Numbers and convert them to integers
            num1=int(input("Enter the first number: "))
            num2=int(input("Enter the second number: "))
            #perform the desired operation
            if selection==1:
                x=add(num1,num2)
            if selection==2:
                x=subtract(num1,num2)
            if selection==3:
                x=multiply(num1,num2)
            if selection==4:
                x=divide(num1,num2)
            #display the result
            print("The result of your operation is: ",x)
        elif selection==5: # we only need the radius to calculate the Circumference
            num1=int(input("Enter the radius: "))
            x=Circumference(num1)
            print("The Circumference is: ",x)
        elif selection>5: #any value over 5 is invalid
            #invalid selection
            print("Error!  Invalid Choice!")
#Tell the interpreter to start the program!
main()
              

mrcampbell / February 15, 2018 / Computer 12

Learning To Use An HT

On January 11, 2018, members of the Kellenberg Amateur Radio Club met for the first time for 2018!  In our meeting, we went over how to use an HT, or handheld radio.  Each member of the club had the opportunity to participate in a short QSO or conversation using an HT radio.

Members learned concepts like “push then talk” which means push the push to talk button, wait for a second, then begin speaking.  This gives the radio a moment to begin transmitting and if using a repeater, for the repeater to begin retransmitting.

Members of the club also reviewed our newly posted website pages “How Do I Call Someone On A Repeater” and “Local Nets”.  Local Nets is a list of nets that licensed operators may want to participate in.  Members of the club we advised to at least listen in so they become familiar with net operations and when they feel comfortable to begin participating.

How Do I Call Someone On A Repeater is a short guide to calling someone specific or just looking to have a conversation with anyone available on a repeater.

Any Kellenberg student interested in learning more about Amateur Radio or participating in Amateur Radio Club can stop by the library conference room any Thursday at 3:05 PM or see Mr. Campbell.

 

mrcampbell / January 12, 2018 / KM2ARC

Computer Club Meeting 10-24-2017

In our meeting today we wrote a program to get user input and then display that input on the console.  The following listing is an example of the program:


/*we include the stdio.h header file which contains the prototypes for
* the printf and getc functions
*/

#include <stdio.h>

/*the main function is the entry point of our program
*when we execute our program this is where it starts from
*/
int main(int argc, char** argv) {

    /*We create a variable type char to store our user input.
    *Our variable which we call  UserInput and we allocate 255 bytes of storage.
    */
    char UserInput[255];

    /*Another variable called PlaceHolder.  This is an integer and we initialize it to 0*/
    int PlaceHolder=0;

    /*We prompt the user to enter his or her name*/
    printf ("What is your name? ");

    /*Now we enter the do loop.  We will get one character at a time until the user presses return*/
    do{
        /*the getc  function reads one character at a time
         * We store that charcter in UserInput at the position indicated by
         * Placeholder
         */
         UserInput[PlaceHolder]=getc(stdin);


         /*We increment placeholder by 1 so that the next call
         * to getc stores the result in the next position
         */
         PlaceHolder++;

    }while(UserInput[(PlaceHolder-1)]!='\n');
    /*We have to use PlaceHolder-1 in the line about to check for return
    *This is because we already increased PlaceHolder for the next position which we have
    *not read in yet.
    */

    /*Now we display Hello and what the user entered at our prompt
    */
    printf("Hello %s",UserInput);

    /*The program is complete*/
    return 0;
}

mrcampbell / October 24, 2017 / Computer Club

mrcampbell / February 17, 2017 / KM2ARC

It’s School Club Roundup Time

Attention All! The Kellenberg Amateur Radio Club will be participating in the Winter School Club Roundup running from February 13, 2017 until February 17, 2017. All students are invited to participate in this event. Please see Mr. Campbell for details and to sign up for a time to operate.

mrcampbell / February 6, 2017 / Uncategorized