21 07, 2019

Most popular coding languages (July 2019)

By |2019-07-21T07:01:03+00:0021st July 2019|Code|

These are the current most popular coding languages. The list changes slightly every month and is based on use and discussion. TypeScript has moved up apparently.  1. JavaScript 2. Java 3. Python 4. PHP 5. C++ (tie) 5. C# (tie) 7. CSS 8. Ruby 9. C 10. TypeScript 11. Swift 12. Objective-C 13. Scala

11 07, 2019

Why learn to code

By |2019-07-11T08:36:41+00:0011th July 2019|Code|

Learning to code is for anyone and everyone, no matter what your age or gender. It is easy to get started and is as difficult as you want to make it. It is a skill that can be used in surprising ways and for things you never expected. The best way to understand what it is for is to try it, it then becomes clearer and clearer. It will take you on a path that will boost your confidence and [...]

3 07, 2018

Sketch B3_5 (serial input LED)

By |2018-09-14T07:53:57+00:003rd July 2018|Arduino, Code|

Sketch B3_5 (serial input LED) Switching on a LED with inputting H and L You will need to use the Serial Monitor  In the box at the top of the Serial Monitor you will type in H or L and press ‘Send’ Use of char is introduced Char is one character or letter input is a made up word ✏️ // sketch B3_5 void setup()  {   Serial.begin(9600);   pinMode(11, OUTPUT);   Serial.println("Enter 'H' for on or 'L' for off"); [...]

2 07, 2018

Sketch B3_4 (debounce the bounce)

By |2018-09-14T07:53:57+00:002nd July 2018|Arduino, Code|

Sketch B3_4 (debounce the bounce) This is the much improved sketch from sketch 3_3 When you press the button it doesn’t bounce (no longer unstable) A button on pin 1 and an LED on pin 11 Integers (int) used when numbers are relatively small Long (long) used when numbers become too big for integers especially when using milliseconds (millis) The debounce time is set at 50  Adjust it if you get any bouncing buttonPin, ledPin, ledState, buttonState, lastButtonState, lastDebounceTime, debounceDelay [...]

27 06, 2018

Sketch B3_3 (LED one press)

By |2018-09-14T07:54:46+00:0027th June 2018|Arduino, Code|

Sketch B3_3 (LED one press) The LED is switched on with one press of the button and then off with another press of the button  As you will see this sketch is far from satisfactory (see the debounce sketch 3_4 for an improvement) If you hold the button down continually it will cycle through every second If you have it much less than 500 it becomes erratic valueToggle, delayPeriod and buttonValue are made up words unsigned means it can never [...]

26 06, 2018

Sketch B3_2 (LED with button)

By |2018-09-14T07:54:46+00:0026th June 2018|Arduino, Code|

Sketch B3_2 (LED with button) In this sketch we are going to switch the LED on with the press of a button Button on digital pin 1 (even though it is an INPUT) LED on pin 11 All the digital pins are on HIGH as default Introducing the 'not the same as' comparison != buttonValue is a made up word ✏️ // sketch B3_2 void setup()  {   pinMode(11, OUTPUT);   pinMode(1, INPUT);  } void loop()  {   int buttonValue [...]

25 06, 2018

Sketch B3_1 (blink without delay)

By |2018-09-14T07:54:46+00:0025th June 2018|Arduino, Code|

Sketch B3_1 (blink without delay) There are quite a few variables in this sketch The problem with delay is that the Arduino stops while in that mode so it can't do any other function Using millis overcomes this problem It takes about 8 milliseconds to cycle through the sketch millis starts counting as soon as the sketch begins in milliseconds So very quickly it can reach quite a big number That is why it is given an unsigned long integer [...]

24 06, 2018

Sketch B2_19 (smoothing the array)

By |2018-09-14T07:54:46+00:0024th June 2018|Arduino, Code|

Sketch B2_19 (smoothing the array) Takes an average over the last 10 readings Smooths out an variations over time Useful when creating a graph or chart of the results Analog A0 is read 10 times and averages out Uses arrays [] Define the number of samples to keep track of The higher the number of readings the slower the output will respond to the input Reads repeatedly from an analog input  It calculates a running average  It is then printed [...]

12 06, 2018

Sketch B2_18 (LED pin array)

By |2018-09-14T07:54:46+00:0012th June 2018|Arduino, Code|

Sketch B2_18 (LED pin array) Switches the LEDs on one at a time in one direction and then the other Uses arrays [] to call each pin in turn delayPeriod, ledPins and pinCount are made up words ✏️ // sketch B2_18 int delayPeriod = 100;            int ledPins[] = {11, 12, 13}; int pinCount = 3; void setup()  {   for (int i = 0; i < pinCount; i++)    {     pinMode(ledPins[i], OUTPUT);   [...]

11 06, 2018

Sketch B2_17 (brightness more random)

By |2018-09-14T07:54:46+00:0011th June 2018|Arduino, Code|

Sketch B2_17 (brightness more random) Introducing random brightness The LED will change brightness every half a second randomly This is to demonstrate the random function The brightness will now be generated from a random number rather than counting through randNumber is a variable and is a made up word as is ledPin It generates a random number up to and including 255 There is no setup necessary  ✏️ // sketch B2_17 int randNumber = 0; int ledPin = 11; void [...]