04 April 2022

Concept review

 Description:

 For my controller I will be playing a Pacman clone I made in game production called “Bite”. This game has a shark as a playable character and has an underwater theme. I will be decorating my controller with things that fit this theme. I plan to use two potentiometers to control the shark. One will be used for the up and down movement while the other is used for the left and right movements. I will be using a cardboard box as an enclosure for the controller and I will be wrapping it in blue paper and using stickers to decorate it

Questions: 

  1. What do you think about the overall design of the controller? Would you make any changes?

  2. Is the code difficult to read/follow?

code :


#include<Keyboard.h>

#include<Adafruit_CircuitPlayground.h>

#include<Adafruit_Circuit_Playground.h>


const int debounce = 100;//for button presses

const int threshold = 500;// for copasative touch

void setup() {

  // put your setup code here, to run once:

CircuitPlayground.begin();

pinMode(CPLAY_SLIDESWITCHPIN, INPUT_PULLUP);// switch

pinMode(CPLAY_LEFTBUTTON, INPUT_PULLDOWN);//BUTTON A

pinMode(CPLAY_RIGHTBUTTON , INPUT_PULLDOWN);//BUTTON B

Keyboard.begin();

}


void loop() {

  // put your main code here, to run repeatedly:

if(digitalRead(CPLAY_SLIDESWITCHPIN)){

  

if(digitalRead(CPLAY_LEFTBUTTON)){

  Keyboard.write('D');// send letter D

  delay(debounce);

  }

  if(digitalRead(CPLAY_RIGHTBUTTON)){

  Keyboard.write('65');

  delay(debounce);

  }

  //arrow keys have decimal values 215-218

  if(CircuitPlayground.readCap(A3)> threshold && digitalRead(CPLAY_SLIDESWITCHPIN)){

  Keyboard.write(' ');//write space

  delay(debounce);

  }

//up and arrow keys control

  int pot= analogRead(A2);

  if(pot > 300 && pot < 400) {

    Keyboard.write(215);//right

  }else if (pot > 400 && pot < 500){

    Keyboard.write(216);//left

  }

  int pot2 = analogRead(A4);

  if(pot2 > 300 && pot2 < 400) {

    Keyboard.write(217);//down

  }else if (pot2 > 4002 && pot < 500){

    Keyboard.write(218);//up

  }

 }

Serial.print(CircuitPlayground.readCap(A3));

Serial.print("/t");

Serial.print(analogRead(A2));

Serial.print(analogRead(A4));

}

  


Sketch- 

Schematic-

Video-

https://youtu.be/UBkHYg1oVng


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.