SlideShare a Scribd company logo
1 of 15
Download to read offline
Sensor project Page 1
Sensor project
Sensor project Page 2
1-About the Game ................................( page :3 )
2-The Accelemeter sensor ..................... (page : 4)
3-Interface between Arduino,Unity engine.. ......... (page : 5)
4-System of the Game............................ (page:6)
5-The Code Part.,,................................ (page:7-9)
6-Documentation(codes,datasheet).…page (9-14)
Students names :
Group 5
‫الرمام‬ ‫عبدالهادى‬ ‫عبدالمقصود‬ ‫خالد‬
‫عبدهللا‬ ‫األنور‬ ‫السيد‬ ‫دمحم‬ ‫عمرو‬
‫الزناتى‬ ‫احمد‬ ‫عبدالعال‬ ‫احمد‬ ‫شيماء‬
‫عبدالعزيز‬ ‫عبدالعزيز‬ ‫شفيق‬ ‫ياسمين‬
‫محمو‬ ‫سليمان‬ ‫عبدالمنعم‬ ‫مجدى‬‫د‬
Sensor project Page 3
The project is a 3D Game designed by Unity 3D engine & programmed
by c# language.
Idea of the game: We have a Plate object in our game and the
balls fall on the plate & by rotation the plate by Accelerometer sensor
The objects in the game: we have only 3 objects in the game
1- The camera object :(it’s the default object in unity and his position in the
3D space depend the screen of the game
2- The Plate object : the plate which we change his rotation by
Accelerometer sensor or Mouse and the balls fall on it
3- Balls : every 5Sec a ball will fall in the plate
Sensor project Page 4
Basic Understanding Of Accelerometers
(This part from a link in the Documentation )
Basic Understanding Of Accelerometers
Accelerometers measure acceleration, often caused by motion. But when they are standing
still, the only acceleration the accelerometer senses is due to gravity pulling down on it.
Imagine a box that has little springs sticking straight out from the sides of the box, and that
the accelerometer measures how hard gravity is stretching out those springs. The springs on
the side are all bending the same amount, the spring on the bottom is all stretched out, and the
one at the top is not stretched at all (because the spring is pull back into itself), so the
accelerometer sees it as feeling no gravity, or 0g (gravity). If you rotate the box 90º and follow
the spring on the top. It is now on the side and is hanging down some and the sensor sees it now
feels .5g. Rotate 90º again, and it is at the bottom, stretched out, and it feels 1g. Rotate again
90º and we are at the side again, with it feeling .5g, and 90º rotation again, we are back at the
top and it feels 0g. So we made a full rotation and the accelerometer saw this: 0g-> .5g -> 1g ->
.5g -> 0g.
Sensor project Page 5
Interface Arduino with unity :the arduino (which
connected to the Accelerometer sensor ) send the rotation angels to
serial port COM3 And by unity script (c#) we can read the
information which come from serial
The code in unity by C# to receive angels date to
unity(class plate)
Serial angels
Sensor project Page 6
Every 5 sec a ball fall into the plate and by rotation in the plate we will
try save all balls ....if 3 balls go out from the plate you will lose...
First scene in the Game
When the Game end you will
see your score and Text about
how good you are in the
Game like(really noob, not
bad,good…etc)
Then you can press the
mouse button to play
again
Sensor project Page 7
The Code Part: we have 2 parts in our project:
1 - The arudino code part which read the data from Accelerometer
sensor and send it to Script in unity
The Main part in the Arduino Code :
All the code in Documentation
 Map to the reading (xAng , yAng , ZAng) [-90,90]
 X,y,z, convert the reading to DEG
The values of angles in x,y,z in range [ 0,360]
Then we convert it to [ -180 , 180 ]to be like unity engine system
Sensor project Page 8
2- The Game Code which is programmed by C# in unity Engine
- The Game has 7 scripts ( classes )
- All class which we made inheritance from the main class
(MonoBehaviour) which designed by unity
Main Class :
MonoBehaviour
Text
ball
Level
Manger
Flag
Camera
Rotation
Plate
Score
To transform
between
scenes
Texts in the game
Score and health
variable
The main code to
take rotation
angels and move
by mouse
Make new
Balls
If the plate rotated
to up , the camera
will move up too Check if ball fall out
from plate
Sensor project Page 9
The Classes in objects :
Ball Object : has only one Script(Ball,)
Camera object :has 4 scripts (camera_rotation,Score,Text,flag)
Plate object :has only one Script :Plate
The Main class to transform between Scenes:Levelmanger
(we put it in empty object)
Sensor project Page 10
Arduino Board (Uno)
Sensor project Page 11
⦿ Arduino code:
}
USING THE SENSOR TURORIAL :
http://bildr.org/2011/04/sensing-orientation-with-the-
adxl335-arduino/
Sensor project Page 12
Plate Script
The main code to
take rotation
angels and move
by mouse
Camera_rotation
If the plate rotated
to up , the camera
will move up too
Sensor project Page 13
Score Script:
Score and health
variables
Sensor project Page 14
Text Script
Texts in the game
Flag Script
Check if ball fall out
from plate
To decrease the
Sum(Health)
Sensor project Page 15
LevelManger
Script:
To transform
between
scenes
Ball Script
Make new
Balls

More Related Content

Similar to 3D-game-Save-balls-with-real-board

Sonar Project Report
Sonar Project ReportSonar Project Report
Sonar Project ReportSumit Sapra
 
Advanced View Arduino Projects List - Use Arduino for Projects-4.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-4.pdfAdvanced View Arduino Projects List - Use Arduino for Projects-4.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-4.pdfWiseNaeem
 
The Ring programming language version 1.9 book - Part 58 of 210
The Ring programming language version 1.9 book - Part 58 of 210The Ring programming language version 1.9 book - Part 58 of 210
The Ring programming language version 1.9 book - Part 58 of 210Mahmoud Samir Fayed
 
Arduino and Circuits.docx
Arduino and Circuits.docxArduino and Circuits.docx
Arduino and Circuits.docxAjay578679
 
Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10stemplar
 
Project_report_on_Attendance_system
 Project_report_on_Attendance_system Project_report_on_Attendance_system
Project_report_on_Attendance_systemAmi Goswami
 
FinalThesisdraft
FinalThesisdraftFinalThesisdraft
FinalThesisdraftSyed Kazmi
 
Advanced view arduino projects list use arduino for projects
Advanced view arduino projects list   use arduino for projectsAdvanced view arduino projects list   use arduino for projects
Advanced view arduino projects list use arduino for projectsWiseNaeem
 
Letselectronic.blogspot.com robotic arm based on atmega mcu controlled by win...
Letselectronic.blogspot.com robotic arm based on atmega mcu controlled by win...Letselectronic.blogspot.com robotic arm based on atmega mcu controlled by win...
Letselectronic.blogspot.com robotic arm based on atmega mcu controlled by win...Aymen Lachkhem
 
arduino
arduinoarduino
arduinomurbz
 
NSTA 2013 Denver - ArduBlock and Arduino
NSTA 2013 Denver - ArduBlock and ArduinoNSTA 2013 Denver - ArduBlock and Arduino
NSTA 2013 Denver - ArduBlock and ArduinoBrian Huang
 
Arduino experimenters guide hq
Arduino experimenters guide hqArduino experimenters guide hq
Arduino experimenters guide hqAndreis Santos
 
Arduino experimenters guide ARDX
Arduino experimenters guide ARDXArduino experimenters guide ARDX
Arduino experimenters guide ARDXJohnny Parrales
 
Advanced View Arduino Projects List - Use Arduino for Projects-2.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-2.pdfAdvanced View Arduino Projects List - Use Arduino for Projects-2.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-2.pdfWiseNaeem
 
A 3D printing programming API
A 3D printing programming APIA 3D printing programming API
A 3D printing programming APIMax Kleiner
 
Arduino UNO based Projects List -Use Arduino for Projects.pdf
Arduino UNO based Projects List -Use Arduino for Projects.pdfArduino UNO based Projects List -Use Arduino for Projects.pdf
Arduino UNO based Projects List -Use Arduino for Projects.pdfIsmailkhan77481
 
Introduction to Game Development
Introduction to Game DevelopmentIntroduction to Game Development
Introduction to Game DevelopmentShaan Alam
 

Similar to 3D-game-Save-balls-with-real-board (20)

Sonar Project Report
Sonar Project ReportSonar Project Report
Sonar Project Report
 
Advanced View Arduino Projects List - Use Arduino for Projects-4.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-4.pdfAdvanced View Arduino Projects List - Use Arduino for Projects-4.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-4.pdf
 
The Ring programming language version 1.9 book - Part 58 of 210
The Ring programming language version 1.9 book - Part 58 of 210The Ring programming language version 1.9 book - Part 58 of 210
The Ring programming language version 1.9 book - Part 58 of 210
 
Arduino and Circuits.docx
Arduino and Circuits.docxArduino and Circuits.docx
Arduino and Circuits.docx
 
Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10
 
Project_report_on_Attendance_system
 Project_report_on_Attendance_system Project_report_on_Attendance_system
Project_report_on_Attendance_system
 
FinalThesisdraft
FinalThesisdraftFinalThesisdraft
FinalThesisdraft
 
Advanced view arduino projects list use arduino for projects
Advanced view arduino projects list   use arduino for projectsAdvanced view arduino projects list   use arduino for projects
Advanced view arduino projects list use arduino for projects
 
Letselectronic.blogspot.com robotic arm based on atmega mcu controlled by win...
Letselectronic.blogspot.com robotic arm based on atmega mcu controlled by win...Letselectronic.blogspot.com robotic arm based on atmega mcu controlled by win...
Letselectronic.blogspot.com robotic arm based on atmega mcu controlled by win...
 
G017534144
G017534144G017534144
G017534144
 
arduino
arduinoarduino
arduino
 
NSTA 2013 Denver - ArduBlock and Arduino
NSTA 2013 Denver - ArduBlock and ArduinoNSTA 2013 Denver - ArduBlock and Arduino
NSTA 2013 Denver - ArduBlock and Arduino
 
Arduino experimenters guide hq
Arduino experimenters guide hqArduino experimenters guide hq
Arduino experimenters guide hq
 
Arduino experimenters guide ARDX
Arduino experimenters guide ARDXArduino experimenters guide ARDX
Arduino experimenters guide ARDX
 
Ardx experimenters-guide-web
Ardx experimenters-guide-webArdx experimenters-guide-web
Ardx experimenters-guide-web
 
Advanced View Arduino Projects List - Use Arduino for Projects-2.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-2.pdfAdvanced View Arduino Projects List - Use Arduino for Projects-2.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-2.pdf
 
A 3D printing programming API
A 3D printing programming APIA 3D printing programming API
A 3D printing programming API
 
Arduino: Arduino starter kit
Arduino: Arduino starter kitArduino: Arduino starter kit
Arduino: Arduino starter kit
 
Arduino UNO based Projects List -Use Arduino for Projects.pdf
Arduino UNO based Projects List -Use Arduino for Projects.pdfArduino UNO based Projects List -Use Arduino for Projects.pdf
Arduino UNO based Projects List -Use Arduino for Projects.pdf
 
Introduction to Game Development
Introduction to Game DevelopmentIntroduction to Game Development
Introduction to Game Development
 

Recently uploaded

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 

Recently uploaded (20)

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 

3D-game-Save-balls-with-real-board

  • 1. Sensor project Page 1 Sensor project
  • 2. Sensor project Page 2 1-About the Game ................................( page :3 ) 2-The Accelemeter sensor ..................... (page : 4) 3-Interface between Arduino,Unity engine.. ......... (page : 5) 4-System of the Game............................ (page:6) 5-The Code Part.,,................................ (page:7-9) 6-Documentation(codes,datasheet).…page (9-14) Students names : Group 5 ‫الرمام‬ ‫عبدالهادى‬ ‫عبدالمقصود‬ ‫خالد‬ ‫عبدهللا‬ ‫األنور‬ ‫السيد‬ ‫دمحم‬ ‫عمرو‬ ‫الزناتى‬ ‫احمد‬ ‫عبدالعال‬ ‫احمد‬ ‫شيماء‬ ‫عبدالعزيز‬ ‫عبدالعزيز‬ ‫شفيق‬ ‫ياسمين‬ ‫محمو‬ ‫سليمان‬ ‫عبدالمنعم‬ ‫مجدى‬‫د‬
  • 3. Sensor project Page 3 The project is a 3D Game designed by Unity 3D engine & programmed by c# language. Idea of the game: We have a Plate object in our game and the balls fall on the plate & by rotation the plate by Accelerometer sensor The objects in the game: we have only 3 objects in the game 1- The camera object :(it’s the default object in unity and his position in the 3D space depend the screen of the game 2- The Plate object : the plate which we change his rotation by Accelerometer sensor or Mouse and the balls fall on it 3- Balls : every 5Sec a ball will fall in the plate
  • 4. Sensor project Page 4 Basic Understanding Of Accelerometers (This part from a link in the Documentation ) Basic Understanding Of Accelerometers Accelerometers measure acceleration, often caused by motion. But when they are standing still, the only acceleration the accelerometer senses is due to gravity pulling down on it. Imagine a box that has little springs sticking straight out from the sides of the box, and that the accelerometer measures how hard gravity is stretching out those springs. The springs on the side are all bending the same amount, the spring on the bottom is all stretched out, and the one at the top is not stretched at all (because the spring is pull back into itself), so the accelerometer sees it as feeling no gravity, or 0g (gravity). If you rotate the box 90º and follow the spring on the top. It is now on the side and is hanging down some and the sensor sees it now feels .5g. Rotate 90º again, and it is at the bottom, stretched out, and it feels 1g. Rotate again 90º and we are at the side again, with it feeling .5g, and 90º rotation again, we are back at the top and it feels 0g. So we made a full rotation and the accelerometer saw this: 0g-> .5g -> 1g -> .5g -> 0g.
  • 5. Sensor project Page 5 Interface Arduino with unity :the arduino (which connected to the Accelerometer sensor ) send the rotation angels to serial port COM3 And by unity script (c#) we can read the information which come from serial The code in unity by C# to receive angels date to unity(class plate) Serial angels
  • 6. Sensor project Page 6 Every 5 sec a ball fall into the plate and by rotation in the plate we will try save all balls ....if 3 balls go out from the plate you will lose... First scene in the Game When the Game end you will see your score and Text about how good you are in the Game like(really noob, not bad,good…etc) Then you can press the mouse button to play again
  • 7. Sensor project Page 7 The Code Part: we have 2 parts in our project: 1 - The arudino code part which read the data from Accelerometer sensor and send it to Script in unity The Main part in the Arduino Code : All the code in Documentation  Map to the reading (xAng , yAng , ZAng) [-90,90]  X,y,z, convert the reading to DEG The values of angles in x,y,z in range [ 0,360] Then we convert it to [ -180 , 180 ]to be like unity engine system
  • 8. Sensor project Page 8 2- The Game Code which is programmed by C# in unity Engine - The Game has 7 scripts ( classes ) - All class which we made inheritance from the main class (MonoBehaviour) which designed by unity Main Class : MonoBehaviour Text ball Level Manger Flag Camera Rotation Plate Score To transform between scenes Texts in the game Score and health variable The main code to take rotation angels and move by mouse Make new Balls If the plate rotated to up , the camera will move up too Check if ball fall out from plate
  • 9. Sensor project Page 9 The Classes in objects : Ball Object : has only one Script(Ball,) Camera object :has 4 scripts (camera_rotation,Score,Text,flag) Plate object :has only one Script :Plate The Main class to transform between Scenes:Levelmanger (we put it in empty object)
  • 10. Sensor project Page 10 Arduino Board (Uno)
  • 11. Sensor project Page 11 ⦿ Arduino code: } USING THE SENSOR TURORIAL : http://bildr.org/2011/04/sensing-orientation-with-the- adxl335-arduino/
  • 12. Sensor project Page 12 Plate Script The main code to take rotation angels and move by mouse Camera_rotation If the plate rotated to up , the camera will move up too
  • 13. Sensor project Page 13 Score Script: Score and health variables
  • 14. Sensor project Page 14 Text Script Texts in the game Flag Script Check if ball fall out from plate To decrease the Sum(Health)
  • 15. Sensor project Page 15 LevelManger Script: To transform between scenes Ball Script Make new Balls