/* This program was created by C.V.Hariharan on 10th April 2014. This program is a random topic generator for generating topics to write articles on. Connect an LDR to analog input A0. */ const int ldr = A0; int ldrread = 0; // To read the input from ldr and store it. int rnumber = 0; // int rselector = 0; int i = 0; char noun[200]; char* randargue1[] = {"History of ", "5 myths about ", "10 tips to get started with ", "10 misconceptions about "}; // Arrays having pre-stored prefixes to add to the sentence char* randargue2[] = {"What is ", "Why you should invest in ", "The ultimate cheat sheet on ","Disadvantages of "}; char* randargue3[] = {"Ultimate guide to ", "Advantages of ", "How to make a ", "The future of "}; char* randargue4[] = {"Science behind ", "Mathematics behind ", "How do they make a ", "5 upcoming "}; void setup() { pinMode(ldr, INPUT); // For randomseed randomSeed(analogRead(A0)); Serial.begin(9600); Serial.print("Enter a noun in singular form to get started: "); Serial.print('\n'); } void loop() { while(Serial.available()==0); Serial.readBytesUntil('\n', noun, 200); // Read the characters and store them in the char array noun till enter(\n) is detected while(i<=4){ rselector = i; switch(rselector) { case 1: rnumber = random(4); // In array 1 choose a random prefix Serial.print(randargue1[rnumber]); Serial.print(noun); Serial.print('\n'); delay(2000); break; case 2: rnumber = random(4); // In array 2 choose a random prefix Serial.print(randargue2[rnumber]); Serial.print(noun); Serial.print('\n'); delay(2000); break; case 3: rnumber = random(4); // In array 3 choose a random prefix Serial.print(randargue3[rnumber]); Serial.print(noun); Serial.print('\n'); delay(2000); break; case 4: rnumber = random(4); // In array 4 choose a random prefix Serial.print(randargue4[rnumber]); Serial.print(noun); Serial.print('\n'); delay(2000); break; } i++; } }