Added examples provided by Ray aka MrBrunette

This commit is contained in:
Roger Clark 2014-12-30 14:04:35 +11:00
parent a6bf8a4bd7
commit b1964dde17
16 changed files with 808 additions and 0 deletions

View File

@ -0,0 +1,17 @@
/*
Blink: Turns on the built-in LED on for one second, then off for one second, repeatedly.
Arduino 1.6.0rc1
Sketch uses 11,900 bytes (11%) of program storage space. Maximum is 108,000 bytes.
Global variables use 2,592 bytes of dynamic memory.
Ported to Maple from the Arduino example 27 May 2011 By Marti Bolivar
*/
void setup() {
// Set up the built-in LED pin as an output:
pinMode(BOARD_LED_PIN, OUTPUT);
}
void loop() {
toggleLED(); // Turn the LED from off to on, or on to off
delay(1000); // Wait for 1 second (1000 milliseconds)
}

View File

@ -0,0 +1,35 @@
/*
BlinkNcount for Maple Mini by m. ray burnette
Sketch uses 13,808 bytes (12%) of program storage space. Maximum is 108,000 bytes.
Global variables use 2,592 bytes of dynamic memory.
Turns on an LED on for one second, then off for one second, repeatedly.
Counts and displays the count on the attached serial monitor
This example code is in the public domain.
*/
int n = 0;
void setup() {
// initialize the digital pin as an output.
pinMode(BOARD_LED_PIN, OUTPUT);
// Initialize virtual COM over USB on Maple Mini
Serial.begin(9600); // BAUD has no effect on USB serial: placeholder for physical UART
// wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
{
toggleLED();
delay(100); // fast blink
}
Serial.println("Blink LED & count Demo");
}
void loop() {
digitalWrite(BOARD_LED_PIN, HIGH); // set the LED on
delay(500); // wait for a second
digitalWrite(BOARD_LED_PIN, LOW); // set the LED off
Serial.print("Loop #: ");
n++;
Serial.println(n);
delay(500); // wait
}

View File

@ -0,0 +1,38 @@
/*
Fading: This example shows how to fade an LED using the pwmWrite() function.
Created 1 Nov 2008
By David A. Mellis
Modified 17 June 2009
By Tom Igoe
Modified by LeafLabs for Maple http://arduino.cc/en/Tutorial/Fading
For differences between Maple's pwmWrite() and Arduino's analogWrite():
http://leaflabs.com/docs/lang/api/analogwrite.html
*/
// int ledPin = 9; // Connect an LED to digital pin 9, or any other
// PWM-capable pin
int ledPin = BOARD_LED_PIN;
void setup() {
pinMode(ledPin, PWM); // setup the pin as PWM
}
void loop() {
// Fade in from min to max in increments of 1280 points:
for (int fadeValue = 0; fadeValue <= 65535; fadeValue += 1280) {
// Sets the value (range from 0 to 65535):
pwmWrite(ledPin, fadeValue);
// Wait for 30 milliseconds to see the dimming effect:
delay(30);
}
// Fade out from max to min in increments of 1280 points:
for (int fadeValue = 65535 ; fadeValue >= 0; fadeValue -= 1280) {
// Sets the value (range from 0 to 1280):
pwmWrite(ledPin, fadeValue);
// Wait for 30 milliseconds to see the dimming effect:
delay(30);
}
}

View File

@ -0,0 +1,46 @@
/*
IntegerInput by m. Ray Burnette - PUBLIC DOMAIN EXAMPLE
Maple Mini: Compiled under Arduino 1.6.0rc1
Sketch uses 15,624 bytes (14%) of program storage space. Maximum is 108,000 bytes.
Global variables use 3,704 bytes of dynamic memory.
*/
#define BAUD 9600
#define timeoutPeriod 2147483647 // Long time... about 25 days
int a;
int b;
void setup()
{
// initialize the digital pin as an output.
pinMode(BOARD_LED_PIN, OUTPUT);
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
Serial.setTimeout(timeoutPeriod); // default is 1 second
// wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
{
toggleLED();
delay(100); // fast blink
}
}
void loop()
{
Serial.println("Enter first integer: ");
a = Serial.parseInt();
Serial.print("a = ");
Serial.println(a);
Serial.println("Enter second integer: ");
b = Serial.parseInt();
Serial.print("b = ");
Serial.println(b);
Serial.print("Sum a + b =");
Serial.println( a + b);
Serial.print("Dif a - b =");
Serial.println(a - b);
}

View File

@ -0,0 +1,50 @@
/*
IntegerInput_FloatOutput by m. Ray Burnette - PUBLIC DOMAIN EXAMPLE
Maple Mini: Compiled under Arduino 1.6.0rc1
Sketch uses 19,868 bytes (18%) of program storage space. Maximum is 108,000 bytes.
Global variables use 3,704 bytes of dynamic memory.
*/
#define BAUD 9600
#define timeoutPeriod 2147483647 // Long var... about 25 days
float a;
float b;
void setup()
{
// initialize the digital pin as an output.
pinMode(BOARD_LED_PIN, OUTPUT);
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
Serial.setTimeout(timeoutPeriod); // default is 1 second
// wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
{
toggleLED();
delay(100); // fast blink
}
Serial.println("Integer Input - Floating Output");
Serial.println("You may wish to try 355 and 113 (Pi)");
}
void loop()
{
Serial.println("Enter first integer: ");
a = Serial.parseInt();
Serial.print("a = ");
Serial.println(a);
Serial.println("Enter second integer: ");
b = Serial.parseInt();
Serial.print("b = ");
Serial.println(b);
a = a / b;
Serial.print( "a/b = ");
Serial.println(a);
Serial.println();
}

View File

@ -0,0 +1,80 @@
/*
Re: http://leaflabs.com/docs/hardware
Arduino 1.6.0rc1 modifications by m. ray burnette
Sketch uses 31,608 bytes (29%) of program storage space. Maximum is 108,000 bytes.
Global variables use 3,752 bytes of dynamic memory.
PUBLIC DOMAIN EXAMPLE
*/
//#include <stdio.h>
#include <libmaple/adc.h>
#define LED_PIN BOARD_LED_PIN
#define A_RANDOM_ANALOG_PIN 15
void setup_temperature_sensor() {
adc_reg_map *regs = ADC1->regs;
// 3. Set the TSVREFE bit in the ADC control register 2 (ADC_CR2) to wake up the
// temperature sensor from power down mode. Do this first 'cause according to
// the Datasheet section 5.3.21 it takes from 4 to 10 uS to power up the sensor.
regs->CR2 |= ADC_CR2_TSEREFE;
// 2. Select a sample time of 17.1 μs
// set channel 16 sample time to 239.5 cycles
// 239.5 cycles of the ADC clock (72MHz/6=12MHz) is over 17.1us (about 20us), but no smaller
// sample time exceeds 17.1us.
regs->SMPR1 = (0b111 << (3*6)); // set channel 16, the temp. sensor
}
void setup(void)
{
// Set up the LED to blink
pinMode(LED_PIN, OUTPUT);
// set up an analog input. We want to test and make sure other analog reads don't screw this up.
pinMode(A_RANDOM_ANALOG_PIN, INPUT_ANALOG);
// wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
{
toggleLED();
delay(100); // fast blink
}
// init tem psensor
setup_temperature_sensor();
// announce start up
if(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))
Serial.println("Temp mon startup");
}
//
// once per second perform a standard analog read and read the temperature sensor
// the analog read is to test whether our messing with the temp sensor will screw up analog reads
// or visa versa.
// Also compute and display the time each operation takes.
//
void loop(void)
{
uint16 vsense, alogpin;
uint32 t1, t2, t3;
char buf[64];
t1 = micros();
alogpin = analogRead(A_RANDOM_ANALOG_PIN);
t2 = micros();
vsense = adc_read(ADC1, 16);
t3 = micros();
if(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())) {
sprintf(buf,"%04x %08x %04x %08x" , vsense, t3-t2, alogpin, t2-t1);
Serial.println(buf);
}
toggleLED();
delay(1000);
}

View File

@ -0,0 +1,69 @@
/*
PrimeNos: by Nick Gammon
Maple Mini port m. ray burnette: Compiled under Arduino 1.6.0rc1
Sketch uses 13,644 bytes (12%) of program storage space. Maximum is 108,000 bytes.
Global variables use 2,656 bytes of dynamic memory.
PUBLIC DOMAIN EXAMPLE
*/
#define BAUD 9600
// just add more primes to the prime table for larger search
// byte data type to save memory - use a larger datatype with prime table entries above 255 :)
byte primes[]={
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101,
102, 107, 109, 113, 127, 131, 137 , 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197,
199, 211, 223, 227, 229, 233, 239, 241, 251 };
// if you change the datatype of primes array to int, change next line to
// "const int TopPrimeIndex = (sizeof(primes)/2) - 1;"
const unsigned int TopPrimeIndex = sizeof(primes) - 1;
const unsigned long TopPrimeSquared = (long)primes[TopPrimeIndex] * (long)primes[TopPrimeIndex];
int primeFlag;
void setup()
{
// initialize the digital pin as an output.
pinMode(BOARD_LED_PIN, OUTPUT);
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
// wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
{
toggleLED();
delay(100); // fast blink
}
Serial.println("Prime Number Generator");
Serial.print("Number of primes in prime table = ");
Serial.println(TopPrimeIndex);
Serial.println();
Serial.print("Last prime in table = ");
Serial.println((unsigned int)primes[TopPrimeIndex]);
Serial.println();
Serial.print("Calculating primes through ");
Serial.println(TopPrimeSquared);
Serial.println();
}
void loop() // run over and over again
{
for (long x = 1; x < TopPrimeSquared; x+=2){ // skips even numbers, including 2, which is prime, but it makes algorithm tad faster
for (long j=0; j < TopPrimeIndex; j++){
primeFlag = true;
if (x == primes[j]) break;
if (x % primes[j] == 0){ // if the test number modolo (next number from prime table) == 0
primeFlag = false; // then test number is not prime, bailout and check the next number
break;
}
}
if (primeFlag == true){ // found a prime - print it
Serial.println(x);
}
}
}

View File

@ -0,0 +1,41 @@
/*
PrimeNos3: by Nick Gammon
Maple Mini port m. ray burnette: Compiled under Arduino 1.6.0rc1
Sketch uses 16,616 bytes (15%) of program storage space. Maximum is 108,000 bytes.
Global variables use 2,624 bytes of dynamic memory.
PUBLIC DOMAIN EXAMPLE
*/
#define BAUD 9600
const int SHOW_EVERY = 500; // how often to echo a prime to the serial port
int candidate;
int found = 5; // Number we found
int count = found - 1;
void setup() {
// initialize the digital pin as an output.
pinMode(BOARD_LED_PIN, OUTPUT);
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
// wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
{
toggleLED();
delay(100); // fast blink
}
Serial.println("Prime Number Generator V2");
}
void loop() {
Serial.println("Prime numbers between 1 and 99999999 are:");
Serial.println("2 \t");
for (int i=3; i<99999999;i+=2) {
// This loop stops either when j*j>i or when i is divisible by j.
// The first condition means prime, the second, not prime.
int j=3;
for(;j*j<=i && i%j!=0; j+=2); // No loop body
if (j*j>i) Serial.print(i);Serial.print( "\t");
}
Serial.println("\r\n");
}

View File

@ -0,0 +1,41 @@
/*
PrimeNos3: by Nick Gammon
Maple Mini port m. ray burnette: Compiled under Arduino 1.6.0rc1
Sketch uses 13,420 bytes (12%) of program storage space. Maximum is 108,000 bytes.
Global variables use 2,600 bytes of dynamic memory.
PUBLIC DOMAIN EXAMPLE
*/
#define BAUD 9600
const int SHOW_EVERY = 500; // how often to echo a prime to the serial port
int candidate;
int found = 5; // Number we found
int count = found - 1;
void setup() {
// initialize the digital pin as an output.
pinMode(BOARD_LED_PIN, OUTPUT);
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
// wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
{
toggleLED();
delay(100); // fast blink
}
Serial.println("Prime Number Generator V2");
}
void loop() {
Serial.println("Prime numbers between 1 and 99999999 are:");
Serial.println("2 \t");
for (int i=3; i<99999999;i+=2) {
// This loop stops either when j*j>i or when i is divisible by j.
// The first condition means prime, the second, not prime.
int j=3;
for(;j*j<=i && i%j!=0; j+=2); // No loop body
if (j*j>i) Serial.print(i);Serial.print( "\n\r");
}
Serial.println("\r\n");
}

View File

@ -0,0 +1,66 @@
/* PRINT_BINARY - Arduino 1.6.0rc1
Adapted to Maple Mini by m. ray burnette
Sketch uses 11,672 bytes (10%) of program storage space. Maximum is 108,000 bytes.
Global variables use 2,592 bytes of dynamic memory
Prints a positive integer in binary format with a fixed withdth
copyright, Peter H Anderson, Baltimore, MD, Nov, '07
PUBLIC DOMAIN EXAMPLE
*/
#define BAUD 9600
void setup()
{
// initialize the digital pin as an output.
pinMode(BOARD_LED_PIN, OUTPUT);
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
// wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
{
toggleLED();
delay(100); // fast blink
}
Serial.println("Print Binary Format");
}
void loop()
{
while(1)
{
print_binary(1024+256+63, 12);
Serial.println();
delay(1000);
}
}
void print_binary(int v, int num_places)
{
int mask=0, n;
for (n=1; n<=num_places; n++)
{
mask = (mask << 1) | 0x0001;
}
v = v & mask; // truncate v to specified number of places
while(num_places)
{
if (v & (0x0001 << num_places-1))
{
Serial.print("1");
}
else
{
Serial.print("0");
}
--num_places;
if(((num_places%4) == 0) && (num_places != 0))
{
Serial.print("_");
}
}
}

View File

@ -0,0 +1,84 @@
/*
PRINT_FLOAT - Arduino 1.6.0rc1
Sketch uses 15,164 bytes (14%) of program storage space. Maximum is 108,000 bytes.
Global variables use 2,592 bytes of dynamic memory.
Adapted to Maple Mini by m. ray burnette
Illustrates how to display floats in the range of -999.999 to 999.999 with a specified
number of digits after the decimal point.
copyright, Peter H Anderson, Baltimore, MD, Nov, '07
PUBLIC DOMAIN EXAMPLE
*/
#define BAUD 9600
void setup() // run once, when the sketch starts
{
// initialize the digital pin as an output.
pinMode(BOARD_LED_PIN, OUTPUT);
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
// wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
{
toggleLED();
delay(100); // fast blink
}
Serial.println("Print Float Format");
}
void loop()
{
while(1)
{
print_float(0.6, 2); // illustrate various test cases
Serial.println();
print_float(1.2, 1);
Serial.println();
print_float(10.27, 2);
Serial.println();
print_float(10.345, 3);
Serial.println();
print_float(107.345, 3);
Serial.println();
delay(1000);
print_float(-0.6, 2);
Serial.println();
print_float(-1.2, 1);
Serial.println();
print_float(-10.27, 2);
Serial.println();
print_float(-10.345, 3);
Serial.println();
print_float(-107.345, 3);
Serial.println();
delay(1000);
}
}
void print_float(float f, int num_digits)
{
int f_int;
int pows_of_ten[4] = {1, 10, 100, 1000};
int multiplier, whole, fract, d, n;
multiplier = pows_of_ten[num_digits];
if (f < 0.0)
{
f = -f;
Serial.print("-");
}
whole = (int) f;
fract = (int) (multiplier * (f - (float)whole));
Serial.print(whole);
Serial.print(".");
for (n=num_digits-1; n>=0; n--) // print each digit with no leading zero suppression
{
d = fract / pows_of_ten[n];
Serial.print(d);
fract = fract % pows_of_ten[n];
}
}

View File

@ -0,0 +1,61 @@
/*
PRINT_HEX - Arduino 1.6.0rc1
Sketch uses 13,336 bytes (12%) of program storage space. Maximum is 108,000 bytes.
Global variables use 2,592 bytes of dynamic memory.
Adapted to the Maple Mini by m. ray burnette
Illustrates how to display a hexadecimal number with a fixed width.
opyright, Peter H Anderson, Baltimore, MD, Nov, '07
PUBLIC DOMAIN EXAMPLE
*/
#define BAUD 9600
void setup() // run once, when the sketch starts
{
// initialize the digital pin as an output.
pinMode(BOARD_LED_PIN, OUTPUT);
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
// wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
{
toggleLED();
delay(100); // fast blink
}
Serial.println("Print HEX Format");
}
void loop()
{
while(1)
{
print_hex(1024+256+63, 13);
Serial.println();
delay(1000);
}
}
void print_hex(int v, int num_places)
{
int mask=0, n, num_nibbles, digit;
for (n=1; n<=num_places; n++)
{
mask = (mask << 1) | 0x0001;
}
v = v & mask; // truncate v to specified number of places
num_nibbles = num_places / 4;
if ((num_places % 4) != 0)
{
++num_nibbles;
}
do
{
digit = ((v >> (num_nibbles-1) * 4)) & 0x0f;
Serial.print(digit, HEX);
} while(--num_nibbles);
}

View File

@ -0,0 +1,35 @@
// http://arduino.cc/forum/index.php?topic=114035.0 `
/* Sketch uses 13,836 bytes (12%) of program storage space. Maximum is 108,000 bytes.
Global variables use 3,696 bytes of dynamic memory.
Read an unknown length string of ASCII characters terminated
with a line feed from the UART
*/
#define BAUD 9600
void setup() {
// initialize the digital pin as an output.
pinMode(BOARD_LED_PIN, OUTPUT);
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UAR
// wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
{
toggleLED();
delay(100); // fast blink
}
Serial.println("Serial Read Until Example:");
Serial.print("Type a few characters & press ENTER\r\n(make certain serial monitor sends CR+LF)");
}
void loop() {
char serialdata[80];
int lf = 10;
Serial.readBytesUntil(lf, serialdata, 80);
Serial.println(serialdata);
}

View File

@ -0,0 +1,104 @@
/*
USBascii Example for Arduino 1.6.0rc1 on the Maple Mini STM32 platform
Sketch uses 13,572 bytes (12%) of program storage space. Maximum is 108,000 bytes.
Global variables use 2,600 bytes of dynamic memory.
Connect to the Maple Serial using the Serial Monitor, then press
any key and hit enter.
Prints out byte values in all possible formats:
* as raw binary values
* as ASCII-encoded decimal, hex, octal, and binary values
For more on ASCII, see:
http://www.asciitable.com
http://en.wikipedia.org/wiki/ASCII
No external hardware needed.
created 2006
by Nicholas Zambetti
modified 18 Jan 2009
by Tom Igoe
<http://www.zambetti.com>
Ported to the Maple 27 May 2010
by Bryan Newbold
Minor edits by m. ray burnette for Arduino 1.6.0
PUBLIC DOMAIN EXAMPLE
*/
void setup() {
// initialize the digital pin as an output.
pinMode(BOARD_LED_PIN, OUTPUT);
Serial.begin(); // USB does not require BAUD
// wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
{
toggleLED();
delay(100); // fast blink
}
Serial.println("ASCII Table ~ Character Map");
Serial.println("Press CR to start the printout");
}
// First visible ASCII character: '!' is number 33:
int thisByte = 33;
int junk = 0;
bool Virgin = true;
// You can also write ASCII characters in single quotes.
// for example. '!' is the same as 33, so you could also use this:
//int thisByte = '!';
void loop() {
Restart:
// Wait for the user to press a key
if (!Virgin) goto NextPhase;
while (!Serial.available())
continue;
while (Serial.available()) {
junk = Serial.read();
}
//continue;
NextPhase:
Virgin = false ;
// Prints value unaltered, i.e. the raw binary version of the
// byte. The serial monitor interprets all bytes as
// ASCII, so 33, the first number, will show up as '!'
Serial.print(thisByte, BYTE);
Serial.print(", dec: ");
// Prints value as string as an ASCII-encoded decimal (base 10).
// Decimal is the default format for Serial.print() and
// Serial.println(), so no modifier is needed:
Serial.print(thisByte);
// But you can declare the modifier for decimal if you want to.
// This also works if you uncomment it:
// Serial.print(thisByte, DEC);
Serial.print(", hex: ");
// Prints value as string in hexadecimal (base 16):
Serial.print(thisByte, HEX);
Serial.print(", oct: ");
// Prints value as string in octal (base 8);
Serial.print(thisByte, OCT);
Serial.print(", bin: ");
// Prints value as string in binary (base 2); also prints ending
// line break:
Serial.println(thisByte, BIN);
// If printed last visible character '~' or 126, stop:
if (thisByte == 126) { // You could also use if (thisByte == '~') {
thisByte = 33;
Virgin = true;
Serial.println("==============================");
Serial.println("Press CR to start the printout");
goto Restart ;
}
// Go on to the next character
thisByte++;
}

View File

@ -0,0 +1,41 @@
/*
Modified for Arduino from: http://www.cplusplus.com/reference/cstdlib/strtol/
Convert string to long integer: Maple Mini version by m. ray burnette: PUBLIC DOMAIN
Sketch uses 13,924 bytes (12%) of program storage space. Maximum is 108,000 bytes.
Global variables use 2,664 bytes of dynamic memory.
Following C++ libs not needed after Arduino 1.0.2
#include <stdio.h>
#include <stdlib.h>
*/
template<class T> inline Print &operator <<(Print &obj, T arg) { obj.print(arg); return obj; }
char szNumbers[] = "2001 60c0c0 -1101110100110100100000 0x6fffff";
char * pEnd;
long int li1, li2, li3, li4;
void setup() {
// initialize the digital pin as an output.
pinMode(BOARD_LED_PIN, OUTPUT);
Serial.begin(9600);
// wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
{
toggleLED();
delay(100); // fast blink
}
li1 = strtol (szNumbers,&pEnd,10); // BASE 10
li2 = strtol (pEnd,&pEnd,16); // HEX
li3 = strtol (pEnd,&pEnd,2); // Binary
li4 = strtol (pEnd,NULL,0); // Integer constant with prefixed base Octal or Hex
// Serial.print ("The decimal equivalents are: %ld, %ld, %ld and %ld.\n", li1, li2, li3, li4);
Serial << "The decimal equivalents are: " << li1 << " " << li2 << " " << li3 << " " << li4;
//return 0;
}
void loop() {
// put your main code here, to run repeatedly:
}