NETMF for education, a community effort

but on a serious note, you could go fully ‘fluent’ with the code style:


While (LOOPING)
            BrainPad.TrafficLight.Red.On()
            BrainPad.Wait.InSeconds(0.5)
            BrainPad.TrafficLight.Red.Off()
            BrainPad.Wait.InSeconds(0.5)
End While

or…


While (LOOPING)
            BrainPad.TrafficLight.Red.On()
            BrainPad.Wait(0.5).Seconds()
            BrainPad.TrafficLight.Red.Off()
            BrainPad.Wait(0.5).Seconds()
End While

1 Like

I understand. The problem, though, is when you’re ready to teach arguments you have no good tools to use. BTW, you’ve already introduced arguments with the Wait()… :wink:

@ ianlee74 - it is always a challenge to decided how much to simplify the code. You still want them to learn programming at the end. This is where we need everyone’s help to try the examples with actual students.

@ Gus - so, is it a final decision to teach coding in VB.NET? :slight_smile:

@ iamin - Curly brackets and semicolon is a no go for middle school :slight_smile: I still prefer C# if we found a way to explain it well.

1 Like

Yea for COBOL! However, I would suggest a PERFORM statement to create a loop.

1 Like

Great… Another generation of programmers who will grow up wondering when to use “END LOOP” vs “END WHILE” vs “END FOR” vs “LOOP”. Perhaps it’s time to port NETMF to Python and just end the confusion once and for all. :wink: Don’t take that harshly as I know I’m in that sick 1% of the population that actually enjoys programming and one of the best days of my career was when I was able to throw VB to the waste basket of my brain and move forward to C#.

Many moons ago when my oldest was in middle school, I taught a class of middle schoolers how to program in C# in a program I called “Code Scouts” which lasted about 6 months. Curly brackets and semicolons weren’t an issue. The only real issue was keeping them interested. This was before I was using NETMF and before Gadgeteer was even an idea. So, I tried basing the course around gaming. We started with around 12 students and at every step up in complexity of the programs we would lose another student or two. Eventually, the class got down to just a few core students which were interested but it was no longer worth my time to keep going since my son was one of the ones no longer interested. It was fun while it lasted but a heck of a lot of work to constantly be coming up with ideas for how to demonstrate new concepts in a way that would keep both them and myself interested.

Is this really “a community effort” or a call for the community to beta test a GHI effort? When you start a “community” project with inflexible statements like that I think you’re likely to scare away many good contributors. Either way is fine just be careful of calling something a “community effort” if GHI is making all the rules.

@ ianlee74 - Strong feeling towards VB vs C#. I am only sharing the experience we had with the kids we are working with. Please feel free to share your input (which you are doing) and please share any experience you had in the past. This Si a community effort but this doesn’t mean we will stop and wait. So please continue sharing. Is till do not understand your response but please let me know how we can make this better.

@ ianlee74 - …also, if you seen the document I sent to everyone you would have seen that C# is part of it. Still, if you prefer C# (which I do) doesn’t mean this is not a community effort!

@ ianlee74 - I am still scratching my head trying to understand your reply!! In my last response I said “I still prefer C# if we found a way to explain it well.” So, maybe you have a way to tech it and you like to share it?! Not sure how I feel now ???

@ Gus - sorry if that came across harsher than I intended. Put simply what I was trying to say is that I have never bought into the argument that VB is a simpler language to learn than C#. I prefer languages that are consistent and VB makes every attempt to be as inconsistent as it can by requiring silly things like “end if”, “end while”, “wend” and “next” (not sure if wend is actually used anymore…). I think kids can understand being taught brackets faster than they can be taught four or five different statements that serve the same purpose. Aside from that, the two languages are nearly identical these days. So, I tend to fall towards using a language with broader acceptance.

Obviously, I haven’t seen the materials you’ve distributed to the group. So, my comments about that were only based on what I can see in this thread. I haven’t signed up not because I’m not interested but just because I don’t really have time to commit to it right now. So, I have no idea what’s really going on behind the scenes. I’m only responding to what is in this thread. When I see things like “Curly brackets and semicolon is a no go” said so early in a community project that just raises red flags for me. I would expect something more along the lines of “the working group [community] is still making these decisions and is open to your suggestions on how to best teach curly brackets”. But, I understand that you probably already had a lot of code developed before opening this up for input.

I want this to succeed! So, please don’t think I am trying to do anything except help.

@ ianlee74 - at this very really stage, we are simply trying different things with actual students. Nothing is set yet. To me, the kids should decide on vb vs c#, not me and you.

1 Like

I don’t see what is inconsistent within VB. You call “End If” and alike end statements silly, I call them logical (common sense driven). Personally, the left side is much more informative than a right side to me (see the attached picture).

Btw, here is a very nice summary why I love VB and why I think it should be chosen to teach young pupils: http://stackoverflow.com/a/11493481

1 Like

Vb :frowning:

I’m one of those that wishes Vb.net would expire already. It seems like such an ugly step child of a language. I understand it is good for old timers used to pre .net vb…to help them acclimate to .net…but teaching it to another generation as a [em]starting[/em] point just seems cruel imho…like teaching an infant Esperanto as their first speaking language…

1 Like

But your picture shows the inconsistency so well. In C# the rule is the same no matter what type of block you are dealing with - open with { and end with }. In VB there’s a different rule for every type of block. Anyway, this is one of those debates that has been had many times over between us old timers. There is a reason so many other languages have copied this style, though. I can’t think of any new languages that have copied the BASIC style.

I agree. Setup some identical projects in both languages and do some trials before committing to one direction or the other.

Here is what students will have access to


Public Module Module1

    Sub Main()

        ''''''''''''''''''''''''''''''''''''''''''''
        ' Traffic Light
        ''''''''''''''''''''''''''''''''''''''''''''
        ' use this wthout argum,ent first
        BrainPad.TrafficLight.RedLightOn()
        BrainPad.TrafficLight.RedLightOff()
        ' then use this with arguments, to teach arguments
        BrainPad.TrafficLight.TurnOn(BrainPad.Color.Red)
        BrainPad.TrafficLight.TurnOff(BrainPad.Color.Red)
        ' use the wrong color to show an exception
        BrainPad.TrafficLight.TurnOn(BrainPad.Color.Blue)
        ' set the light intensity to half
        BrainPad.TrafficLight.SetLevel(BrainPad.Color.Red, 0.5)

        '''''''''''''''''''''''''''''''''''''''''''
        ' buttons
        ''''''''''''''''''''''''''''''''''''''''''''
        BrainPad.Buttons.IsButtonPressed(BrainPad.Buttons.Button.Left)

        '''''''''''''''''''''''''''''''''''''''''''
        ' Buzzer
        ''''''''''''''''''''''''''''''''''''''''''''
        ' play a note
        BrainPad.Buzzer.PlayTone(BrainPad.Buzzer.Note.A)
        ' play a frequency
        BrainPad.Buzzer.PlayFrequency(5000)
        ' stop playing
        BrainPad.Buzzer.StopPlaying()

        '''''''''''''''''''''''''''''''''''''''''''''
        ' light sensor
        ''''''''''''''''''''''''''''''''''''''''''''
        BrainPad.LightSensor.GetLevel()

        ''''''''''''''''''''''''''''''''''''''''''''
        ' delay helper
        ''''''''''''''''''''''''''''''''''''''''''''
        ' wait half a second
        BrainPad.Wait.Seconds(0.5)
        ' using milliseonds
        BrainPad.Wait.Milliseconds(500)

        ''''''''''''''''''''''''''''''''''''''''''''
        ' Touch pads
        ''''''''''''''''''''''''''''''''''''''''''''
        ' see if it is touched
        BrainPad.TouchPad.IsPadTouched(BrainPad.TouchPad.Pad.Left)
        ' depending on what is connected we may need ot calibrate
        ' read the raw values
        BrainPad.TouchPad.RawRead(BrainPad.TouchPad.Pad.Left)
        ' Set it what threshold the pin is touched
        BrainPad.TouchPad.SetThreshold(BrainPad.TouchPad.Pad.Left, 1234)

        ''''''''''''''''''''''''''''''''''''''''''''
        ' Display
        ''''''''''''''''''''''''''''''''''''''''''''
        ' more to be added but here is a start
        BrainPad.Display.Clear()
        BrainPad.Display.Write("Hello World!")

        ''''''''''''''''''''''''''''''''''''''''''''
        ' Temperature Sensor
        ''''''''''''''''''''''''''''''''''''''''''''
        BrainPad.TemperatureSensor.ReadTemperature()

        ''''''''''''''''''''''''''''''''''''''''''''
        ' Accelereometer
        ''''''''''''''''''''''''''''''''''''''''''''
        BrainPad.Accelerometer.ReadX()

        ''''''''''''''''''''''''''''''''''''''''''''
        ' multicolor light bulb
        ''''''''''''''''''''''''''''''''''''''''''''
        ' simple set to a color
        BrainPad.LightBulb.SetColor(BrainPad.Color.Blue)
        BrainPad.LightBulb.TurnOff()
        ' this is a chance to tech overloaded functions
        BrainPad.LightBulb.SetColor(1, 0, 0) ' red

        ''''''''''''''''''''''''''''''''''''''''''''
        ' Communication using UART
        ''''''''''''''''''''''''''''''''''''''''''''
        BrainPad.Communication.Write("Hello")
        BrainPad.Communication.Read()

        ''''''''''''''''''''''''''''''''''''''''''''
        ' Servo Motor
        ''''''''''''''''''''''''''''''''''''''''''''
        ' move the servo to 90 degree position
        BrainPad.ServoMotor.SetPosition(90)
        ' deactivate teh dignal going to the motor
        BrainPad.ServoMotor.Deacticvate()

        ''''''''''''''''''''''''''''''''''''''''''''
        ' DC Motor (fan)
        ''''''''''''''''''''''''''''''''''''''''''''
        ' go half speed
        BrainPad.DcMotor.SetSpeed(0.5)
        ' stop
        BrainPad.DcMotor.SetSpeed(0)

        ''''''''''''''''''''''''''''''''''''''''''''
        ' Debug message
        ''''''''''''''''''''''''''''''''''''''''''''
        ' this will show in the oputput window of VS
        BrainPad.DebugMessage.Send("I am here")

        ''''''''''''''''''''''''''''''''''''''''''''
        ' expansion pin enum
        ''''''''''''''''''''''''''''''''''''''''''''
        'BrainPad.Expansion.Pin.Di0()


        While (BrainPad.LOOPING)

            BrainPad.TrafficLight.RedLightOn()
            BrainPad.Wait.Seconds(0.5)
            BrainPad.TrafficLight.RedLightOff()
            BrainPad.Wait.Seconds(0.5)
        End While

    End Sub

End Module

And the C# version!



public static class Module1
{


	public static void Main()
	{
		///'''''''''''''''''''''''''''''''''''''''''
		// Traffic Light
		///'''''''''''''''''''''''''''''''''''''''''
		// use this wthout argum,ent first
		BrainPad.TrafficLight.RedLightOn();
		BrainPad.TrafficLight.RedLightOff();
		// then use this with arguments, to teach arguments
		BrainPad.TrafficLight.TurnOn(BrainPad.Color.Red);
		BrainPad.TrafficLight.TurnOff(BrainPad.Color.Red);
		// use the wrong color to show an exception
		BrainPad.TrafficLight.TurnOn(BrainPad.Color.Blue);
		// set the light intensity to half
		BrainPad.TrafficLight.SetLevel(BrainPad.Color.Red, 0.5);

		///''''''''''''''''''''''''''''''''''''''''
		// buttons
		///'''''''''''''''''''''''''''''''''''''''''
		BrainPad.Buttons.IsButtonPressed(BrainPad.Buttons.Button.Left);

		///''''''''''''''''''''''''''''''''''''''''
		// Buzzer
		///'''''''''''''''''''''''''''''''''''''''''
		// play a note
		BrainPad.Buzzer.PlayTone(BrainPad.Buzzer.Note.A);
		// play a frequency
		BrainPad.Buzzer.PlayFrequency(5000);
		// stop playing
		BrainPad.Buzzer.StopPlaying();

		///''''''''''''''''''''''''''''''''''''''''''
		// light sensor
		///'''''''''''''''''''''''''''''''''''''''''
		BrainPad.LightSensor.GetLevel();

		///'''''''''''''''''''''''''''''''''''''''''
		// delay helper
		///'''''''''''''''''''''''''''''''''''''''''
		// wait half a second
		BrainPad.Wait.Seconds(0.5);
		// using milliseonds
		BrainPad.Wait.Milliseconds(500);

		///'''''''''''''''''''''''''''''''''''''''''
		// Touch pads
		///'''''''''''''''''''''''''''''''''''''''''
		// see if it is touched
		BrainPad.TouchPad.IsPadTouched(BrainPad.TouchPad.Pad.Left);
		// depending on what is connected we may need ot calibrate
		// read the raw values
		BrainPad.TouchPad.RawRead(BrainPad.TouchPad.Pad.Left);
		// Set it what threshold the pin is touched
		BrainPad.TouchPad.SetThreshold(BrainPad.TouchPad.Pad.Left, 1234);

		///'''''''''''''''''''''''''''''''''''''''''
		// Display
		///'''''''''''''''''''''''''''''''''''''''''
		// more to be added but here is a start
		BrainPad.Display.Clear();
		BrainPad.Display.Write("Hello World!");

		///'''''''''''''''''''''''''''''''''''''''''
		// Temperature Sensor
		///'''''''''''''''''''''''''''''''''''''''''
		BrainPad.TemperatureSensor.ReadTemperature();

		///'''''''''''''''''''''''''''''''''''''''''
		// Accelereometer
		///'''''''''''''''''''''''''''''''''''''''''
		BrainPad.Accelerometer.ReadX();

		///'''''''''''''''''''''''''''''''''''''''''
		// multicolor light bulb
		///'''''''''''''''''''''''''''''''''''''''''
		// simple set to a color
		BrainPad.LightBulb.SetColor(BrainPad.Color.Blue);
		BrainPad.LightBulb.TurnOff();
		// this is a chance to tech overloaded functions
		BrainPad.LightBulb.SetColor(1, 0, 0);
		// red

		///'''''''''''''''''''''''''''''''''''''''''
		// Communication using UART
		///'''''''''''''''''''''''''''''''''''''''''
		BrainPad.Communication.Write("Hello");
		BrainPad.Communication.Read();

		///'''''''''''''''''''''''''''''''''''''''''
		// Servo Motor
		///'''''''''''''''''''''''''''''''''''''''''
		// move the servo to 90 degree position
		BrainPad.ServoMotor.SetPosition(90);
		// deactivate teh dignal going to the motor
		BrainPad.ServoMotor.Deacticvate();

		///'''''''''''''''''''''''''''''''''''''''''
		// DC Motor (fan)
		///'''''''''''''''''''''''''''''''''''''''''
		// go half speed
		BrainPad.DcMotor.SetSpeed(0.5);
		// stop
		BrainPad.DcMotor.SetSpeed(0);

		///'''''''''''''''''''''''''''''''''''''''''
		// Debug message
		///'''''''''''''''''''''''''''''''''''''''''
		// this will show in the oputput window of VS
		BrainPad.DebugMessage.Send("I am here");

		///'''''''''''''''''''''''''''''''''''''''''
		// expansion pin enum
		///'''''''''''''''''''''''''''''''''''''''''
		//BrainPad.Expansion.Pin.Di0()



		while ((BrainPad.LOOPING)) {
			BrainPad.TrafficLight.RedLightOn();
			BrainPad.Wait.Seconds(0.5);
			BrainPad.TrafficLight.RedLightOff();
			BrainPad.Wait.Seconds(0.5);
		}

	}

}


Clarification: This is a proposal for trial and testing. Your feedback is most welcome.